Skip to content
  1. Feb 16, 2022
    • Sean Anderson's avatar
      usb: ulpi: Call of_node_put correctly · 93feb2bd
      Sean Anderson authored
      commit 0a907ee9 upstream.
      
      of_node_put should always be called on device nodes gotten from
      of_get_*. Additionally, it should only be called after there are no
      remaining users. To address the first issue, call of_node_put if later
      steps in ulpi_register fail. To address the latter, call put_device if
      device_register fails, which will call ulpi_dev_release if necessary.
      
      Fixes: ef6a7bcf
      
       ("usb: ulpi: Support device discovery via DT")
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Signed-off-by: default avatarSean Anderson <sean.anderson@seco.com>
      Link: https://lore.kernel.org/r/20220127190004.1446909-3-sean.anderson@seco.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93feb2bd
    • Sean Anderson's avatar
      usb: ulpi: Move of_node_put to ulpi_dev_release · fc50f42e
      Sean Anderson authored
      commit 092f45b1 upstream.
      
      Drivers are not unbound from the device when ulpi_unregister_interface
      is called. Move of_node-freeing code to ulpi_dev_release which is called
      only after all users are gone.
      
      Fixes: ef6a7bcf
      
       ("usb: ulpi: Support device discovery via DT")
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: default avatarHeikki Krogerus <heikki.krogerus@linux.intel.com>
      Signed-off-by: default avatarSean Anderson <sean.anderson@seco.com>
      Link: https://lore.kernel.org/r/20220127190004.1446909-2-sean.anderson@seco.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fc50f42e
    • Jann Horn's avatar
      net: usb: ax88179_178a: Fix out-of-bounds accesses in RX fixup · ffd0393a
      Jann Horn authored
      commit 57bc3d3a upstream.
      
      ax88179_rx_fixup() contains several out-of-bounds accesses that can be
      triggered by a malicious (or defective) USB device, in particular:
      
       - The metadata array (hdr_off..hdr_off+2*pkt_cnt) can be out of bounds,
         causing OOB reads and (on big-endian systems) OOB endianness flips.
       - A packet can overlap the metadata array, causing a later OOB
         endianness flip to corrupt data used by a cloned SKB that has already
         been handed off into the network stack.
       - A packet SKB can be constructed whose tail is far beyond its end,
         causing out-of-bounds heap data to be considered part of the SKB's
         data.
      
      I have tested that this can be used by a malicious USB device to send a
      bogus ICMPv6 Echo Request and receive an ICMPv6 Echo Reply in response
      that contains random kernel heap data.
      It's probably also possible to get OOB writes from this on a
      little-endian system somehow - maybe by triggering skb_cow() via IP
      options processing -, but I haven't tested that.
      
      Fixes: e2ca90c2
      
       ("ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver")
      Cc: stable@kernel.org
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ffd0393a
    • Greg Kroah-Hartman's avatar
      Revert "usb: dwc2: drd: fix soft connect when gadget is unconfigured" · f4e72ad0
      Greg Kroah-Hartman authored
      commit 736e8d89 upstream.
      
      This reverts commit 269cbcf7
      
      .
      
      It causes build errors as reported by the kernel test robot.
      
      Link: https://lore.kernel.org/r/202202112236.AwoOTtHO-lkp@intel.com
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Fixes: 269cbcf7
      
       ("usb: dwc2: drd: fix soft connect when gadget is unconfigured")
      Cc: stable@kernel.org
      Cc: Amelie Delaunay <amelie.delaunay@foss.st.com>
      Cc: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
      Cc: Fabrice Gasnier <fabrice.gasnier@foss.st.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f4e72ad0
    • Fabrice Gasnier's avatar
      usb: dwc2: drd: fix soft connect when gadget is unconfigured · a6ef1bda
      Fabrice Gasnier authored
      commit 269cbcf7 upstream.
      
      When the gadget driver hasn't been (yet) configured, and the cable is
      connected to a HOST, the SFTDISCON gets cleared unconditionally, so the
      HOST tries to enumerate it.
      At the host side, this can result in a stuck USB port or worse. When
      getting lucky, some dmesg can be observed at the host side:
       new high-speed USB device number ...
       device descriptor read/64, error -110
      
      Fix it in drd, by checking the enabled flag before calling
      dwc2_hsotg_core_connect(). It will be called later, once configured,
      by the normal flow:
      - udc_bind_to_driver
       - usb_gadget_connect
         - dwc2_hsotg_pullup
           - dwc2_hsotg_core_connect
      
      Fixes: 17f93402
      
       ("usb: dwc2: override PHY input signals with usb role switch support")
      Cc: stable@kernel.org
      Reviewed-by: default avatarAmelie Delaunay <amelie.delaunay@foss.st.com>
      Acked-by: default avatarMinas Harutyunyan <Minas.Harutyunyan@synopsys.com>
      Signed-off-by: default avatarFabrice Gasnier <fabrice.gasnier@foss.st.com>
      Link: https://lore.kernel.org/r/1644423353-17859-1-git-send-email-fabrice.gasnier@foss.st.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a6ef1bda
    • Jonas Malaco's avatar
      eeprom: ee1004: limit i2c reads to I2C_SMBUS_BLOCK_MAX · 9a5f471a
      Jonas Malaco authored
      commit c0689e46 upstream.
      
      Commit effa4531 ("i2c: i801: Don't silently correct invalid transfer
      size") revealed that ee1004_eeprom_read() did not properly limit how
      many bytes to read at once.
      
      In particular, i2c_smbus_read_i2c_block_data_or_emulated() takes the
      length to read as an u8.  If count == 256 after taking into account the
      offset and page boundary, the cast to u8 overflows.  And this is common
      when user space tries to read the entire EEPROM at once.
      
      To fix it, limit each read to I2C_SMBUS_BLOCK_MAX (32) bytes, already
      the maximum length i2c_smbus_read_i2c_block_data_or_emulated() allows.
      
      Fixes: effa4531
      
       ("i2c: i801: Don't silently correct invalid transfer size")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
      Signed-off-by: default avatarJonas Malaco <jonas@protocubo.io>
      Link: https://lore.kernel.org/r/20220203165024.47767-1-jonas@protocubo.io
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9a5f471a
    • TATSUKAWA KOSUKE (立川 江介)'s avatar
      n_tty: wake up poll(POLLRDNORM) on receiving data · decb36e9
      TATSUKAWA KOSUKE (立川 江介) authored
      commit c816b2e6 upstream.
      
      The poll man page says POLLRDNORM is equivalent to POLLIN when used as
      an event.
      $ man poll
      <snip>
                    POLLRDNORM
                           Equivalent to POLLIN.
      
      However, in n_tty driver, POLLRDNORM does not return until timeout even
      if there is terminal input, whereas POLLIN returns.
      
      The following test program works until kernel-3.17, but the test stops
      in poll() after commit 57087d51 ("tty: Fix spurious poll() wakeups").
      
      [Steps to run test program]
        $ cc -o test-pollrdnorm test-pollrdnorm.c
        $ ./test-pollrdnorm
        foo          <-- Type in something from the terminal followed by [RET].
                         The string should be echoed back.
      
        ------------------------< test-pollrdnorm.c >------------------------
        #include <stdio.h>
        #include <errno.h>
        #include <poll.h>
        #include <unistd.h>
      
        void main(void)
        {
      	int		n;
      	unsigned char	buf[8];
      	struct pollfd	fds[1] = {{ 0, POLLRDNORM, 0 }};
      
      	n = poll(fds, 1, -1);
      	if (n < 0)
      		perror("poll");
      	n = read(0, buf, 8);
      	if (n < 0)
      		perror("read");
      	if (n > 0)
      		write(1, buf, n);
        }
        ------------------------------------------------------------------------
      
      The attached patch fixes this problem.  Many calls to
      wake_up_interruptible_poll() in the kernel source code already specify
      "POLLIN | POLLRDNORM".
      
      Fixes: 57087d51
      
       ("tty: Fix spurious poll() wakeups")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarKosuke Tatsukawa <tatsu-ab1@nec.com>
      Link: https://lore.kernel.org/r/TYCPR01MB81901C0F932203D30E452B3EA5209@TYCPR01MB8190.jpnprd01.prod.outlook.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      decb36e9
    • Jakob Koschel's avatar
      vt_ioctl: add array_index_nospec to VT_ACTIVATE · 573321db
      Jakob Koschel authored
      commit 28cb138f
      
       upstream.
      
      in vt_setactivate an almost identical code path has been patched
      with array_index_nospec. In the VT_ACTIVATE path the user input
      is from a system call argument instead of a usercopy.
      For consistency both code paths should have the same mitigations
      applied.
      
      Kasper Acknowledgements: Jakob Koschel, Brian Johannesmeyer, Kaveh
      Razavi, Herbert Bos, Cristiano Giuffrida from the VUSec group at VU
      Amsterdam.
      
      Co-developed-by: default avatarBrian Johannesmeyer <bjohannesmeyer@gmail.com>
      Signed-off-by: default avatarBrian Johannesmeyer <bjohannesmeyer@gmail.com>
      Signed-off-by: default avatarJakob Koschel <jakobkoschel@gmail.com>
      Link: https://lore.kernel.org/r/20220127144406.3589293-2-jakobkoschel@gmail.com
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      573321db
    • Jakob Koschel's avatar
      vt_ioctl: fix array_index_nospec in vt_setactivate · ffe54289
      Jakob Koschel authored
      commit 61cc70d9
      
       upstream.
      
      array_index_nospec ensures that an out-of-bounds value is set to zero
      on the transient path. Decreasing the value by one afterwards causes
      a transient integer underflow. vsa.console should be decreased first
      and then sanitized with array_index_nospec.
      
      Kasper Acknowledgements: Jakob Koschel, Brian Johannesmeyer, Kaveh
      Razavi, Herbert Bos, Cristiano Giuffrida from the VUSec group at VU
      Amsterdam.
      
      Co-developed-by: default avatarBrian Johannesmeyer <bjohannesmeyer@gmail.com>
      Signed-off-by: default avatarBrian Johannesmeyer <bjohannesmeyer@gmail.com>
      Signed-off-by: default avatarJakob Koschel <jakobkoschel@gmail.com>
      Link: https://lore.kernel.org/r/20220127144406.3589293-1-jakobkoschel@gmail.com
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ffe54289
    • Vladimir Oltean's avatar
      net: dsa: mv88e6xxx: fix use-after-free in mv88e6xxx_mdios_unregister · f9161816
      Vladimir Oltean authored
      [ Upstream commit 51a04ebf ]
      
      Since struct mv88e6xxx_mdio_bus *mdio_bus is the bus->priv of something
      allocated with mdiobus_alloc_size(), this means that mdiobus_free(bus)
      will free the memory backing the mdio_bus as well. Therefore, the
      mdio_bus->list element is freed memory, but we continue to iterate
      through the list of MDIO buses using that list element.
      
      To fix this, use the proper list iterator that handles element deletion
      by keeping a copy of the list element next pointer.
      
      Fixes: f53a2ce8
      
       ("net: dsa: mv88e6xxx: don't use devres for mdiobus")
      Reported-by: default avatarRafael Richter <rafael.richter@gin.de>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Link: https://lore.kernel.org/r/20220210174017.3271099-1-vladimir.oltean@nxp.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f9161816
    • Colin Foster's avatar
      net: mscc: ocelot: fix mutex lock error during ethtool stats read · d98ba26a
      Colin Foster authored
      [ Upstream commit 7fbf6795
      
       ]
      
      An ongoing workqueue populates the stats buffer. At the same time, a user
      might query the statistics. While writing to the buffer is mutex-locked,
      reading from the buffer wasn't. This could lead to buggy reads by ethtool.
      
      This patch fixes the former blamed commit, but the bug was introduced in
      the latter.
      
      Signed-off-by: default avatarColin Foster <colin.foster@in-advantage.com>
      Fixes: 1e1caa97 ("ocelot: Clean up stats update deferred work")
      Fixes: a556c76a
      
       ("net: mscc: Add initial Ocelot switch support")
      Reported-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Link: https://lore.kernel.org/all/20220210150451.416845-2-colin.foster@in-advantage.com/
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d98ba26a
    • Dave Ertman's avatar
      ice: Avoid RTNL lock when re-creating auxiliary device · 41a8c548
      Dave Ertman authored
      [ Upstream commit 5dbbbd01 ]
      
      If a call to re-create the auxiliary device happens in a context that has
      already taken the RTNL lock, then the call flow that recreates auxiliary
      device can hang if there is another attempt to claim the RTNL lock by the
      auxiliary driver.
      
      To avoid this, any call to re-create auxiliary devices that comes from
      an source that is holding the RTNL lock (e.g. netdev notifier when
      interface exits a bond) should execute in a separate thread.  To
      accomplish this, add a flag to the PF that will be evaluated in the
      service task and dealt with there.
      
      Fixes: f9f5301e
      
       ("ice: Register auxiliary device to provide RDMA")
      Signed-off-by: default avatarDave Ertman <david.m.ertman@intel.com>
      Reviewed-by: default avatarJonathan Toppins <jtoppins@redhat.com>
      Tested-by: default avatarGurucharan G <gurucharanx.g@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      41a8c548
    • Dave Ertman's avatar
      ice: Fix KASAN error in LAG NETDEV_UNREGISTER handler · f9daedc3
      Dave Ertman authored
      [ Upstream commit bea1898f ]
      
      Currently, the same handler is called for both a NETDEV_BONDING_INFO
      LAG unlink notification as for a NETDEV_UNREGISTER call.  This is
      causing a problem though, since the netdev_notifier_info passed has
      a different structure depending on which event is passed.  The problem
      manifests as a call trace from a BUG: KASAN stack-out-of-bounds error.
      
      Fix this by creating a handler specific to NETDEV_UNREGISTER that only
      is passed valid elements in the netdev_notifier_info struct for the
      NETDEV_UNREGISTER event.
      
      Also included is the removal of an unbalanced dev_put on the peer_netdev
      and related braces.
      
      Fixes: 6a8b3572
      
       ("ice: Respond to a NETDEV_UNREGISTER event for LAG")
      Signed-off-by: default avatarDave Ertman <david.m.ertman@intel.com>
      Acked-by: default avatarJonathan Toppins <jtoppins@redhat.com>
      Tested-by: default avatarSunitha Mekala <sunithax.d.mekala@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f9daedc3
    • Jesse Brandeburg's avatar
      ice: fix IPIP and SIT TSO offload · 52eb5c86
      Jesse Brandeburg authored
      [ Upstream commit 46b699c5 ]
      
      The driver was avoiding offload for IPIP (at least) frames due to
      parsing the inner header offsets incorrectly when trying to check
      lengths.
      
      This length check works for VXLAN frames but fails on IPIP frames
      because skb_transport_offset points to the inner header in IPIP
      frames, which meant the subtraction of transport_header from
      inner_network_header returns a negative value (-20).
      
      With the code before this patch, everything continued to work, but GSO
      was being used to segment, causing throughputs of 1.5Gb/s per thread.
      After this patch, throughput is more like 10Gb/s per thread for IPIP
      traffic.
      
      Fixes: e94d4478
      
       ("ice: Implement filter sync, NDO operations and bump version")
      Signed-off-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
      Reviewed-by: default avatarPaul Menzel <pmenzel@molgen.mpg.de>
      Tested-by: default avatarGurucharan G <gurucharanx.g@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      52eb5c86
    • Dan Carpenter's avatar
      ice: fix an error code in ice_cfg_phy_fec() · efd399e1
      Dan Carpenter authored
      [ Upstream commit 21338d58 ]
      
      Propagate the error code from ice_get_link_default_override() instead
      of returning success.
      
      Fixes: ea78ce4d
      
       ("ice: add link lenient and default override support")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Tested-by: default avatarGurucharan G <gurucharanx.g@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      efd399e1
    • Robert-Ionut Alexa's avatar
      dpaa2-eth: unregister the netdev before disconnecting from the PHY · 12e067a4
      Robert-Ionut Alexa authored
      [ Upstream commit 9ccc6e0c ]
      
      The netdev should be unregistered before we are disconnecting from the
      MAC/PHY so that the dev_close callback is called and the PHY and the
      phylink workqueues are actually stopped before we are disconnecting and
      destroying the phylink instance.
      
      Fixes: 71947923
      
       ("dpaa2-eth: add MAC/PHY support through phylink")
      Signed-off-by: default avatarRobert-Ionut Alexa <robert-ionut.alexa@nxp.com>
      Signed-off-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      12e067a4
    • Kishen Maloor's avatar
      mptcp: netlink: process IPv6 addrs in creating listening sockets · 29b25d5f
      Kishen Maloor authored
      [ Upstream commit 029744cd ]
      
      This change updates mptcp_pm_nl_create_listen_socket() to create
      listening sockets bound to IPv6 addresses (where IPv6 is supported).
      
      Fixes: 1729cf18
      
       ("mptcp: create the listening socket for new port")
      Acked-by: default avatarGeliang Tang <geliang.tang@suse.com>
      Signed-off-by: default avatarKishen Maloor <kishen.maloor@intel.com>
      Signed-off-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      29b25d5f
    • Yang Wang's avatar
      drm/amd/pm: fix hwmon node of power1_label create issue · dcd1c466
      Yang Wang authored
      [ Upstream commit a8b1e863 ]
      
      it will cause hwmon node of power1_label is not created.
      
      v2:
      the hwmon node of "power1_label" is always needed for all ASICs.
      and the patch will remove ASIC type check for "power1_label".
      
      Fixes: ae07970a
      
       ("drm/amd/pm: add support for hwmon control of slow and fast PPT limit on vangogh")
      
      Signed-off-by: default avatarYang Wang <KevinYang.Wang@amd.com>
      Reviewed-by: default avatarKenneth Feng <kenneth.feng@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dcd1c466
    • Raju Rangoju's avatar
      net: amd-xgbe: disable interrupts during pci removal · 4b24ef1d
      Raju Rangoju authored
      [ Upstream commit 68c2d6af ]
      
      Hardware interrupts are enabled during the pci probe, however,
      they are not disabled during pci removal.
      
      Disable all hardware interrupts during pci removal to avoid any
      issues.
      
      Fixes: e7537740
      
       ("amd-xgbe: Update PCI support to use new IRQ functions")
      Suggested-by: default avatarSelwin Sebastian <Selwin.Sebastian@amd.com>
      Signed-off-by: default avatarRaju Rangoju <Raju.Rangoju@amd.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4b24ef1d
    • Jon Maloy's avatar
      tipc: rate limit warning for received illegal binding update · 489d9fa7
      Jon Maloy authored
      [ Upstream commit c7223d68 ]
      
      It would be easy to craft a message containing an illegal binding table
      update operation. This is handled correctly by the code, but the
      corresponding warning printout is not rate limited as is should be.
      We fix this now.
      
      Fixes: b97bf3fd
      
       ("[TIPC] Initial merge")
      Signed-off-by: default avatarJon Maloy <jmaloy@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      489d9fa7
    • Joel Stanley's avatar
      net: mdio: aspeed: Add missing MODULE_DEVICE_TABLE · bb04b552
      Joel Stanley authored
      [ Upstream commit bc1c3c3b ]
      
      Fix loading of the driver when built as a module.
      
      Fixes: f160e994
      
       ("net: phy: Add mdio-aspeed")
      Signed-off-by: default avatarJoel Stanley <joel@jms.id.au>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Acked-by: default avatarAndrew Jeffery <andrew@aj.id.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bb04b552
    • Eric Dumazet's avatar
      veth: fix races around rq->rx_notify_masked · b8ac37e5
      Eric Dumazet authored
      [ Upstream commit 68468d8c ]
      
      veth being NETIF_F_LLTX enabled, we need to be more careful
      whenever we read/write rq->rx_notify_masked.
      
      BUG: KCSAN: data-race in veth_xmit / veth_xmit
      
      write to 0xffff888133d9a9f8 of 1 bytes by task 23552 on cpu 0:
       __veth_xdp_flush drivers/net/veth.c:269 [inline]
       veth_xmit+0x307/0x470 drivers/net/veth.c:350
       __netdev_start_xmit include/linux/netdevice.h:4683 [inline]
       netdev_start_xmit include/linux/netdevice.h:4697 [inline]
       xmit_one+0x105/0x2f0 net/core/dev.c:3473
       dev_hard_start_xmit net/core/dev.c:3489 [inline]
       __dev_queue_xmit+0x86d/0xf90 net/core/dev.c:4116
       dev_queue_xmit+0x13/0x20 net/core/dev.c:4149
       br_dev_queue_push_xmit+0x3ce/0x430 net/bridge/br_forward.c:53
       NF_HOOK include/linux/netfilter.h:307 [inline]
       br_forward_finish net/bridge/br_forward.c:66 [inline]
       NF_HOOK include/linux/netfilter.h:307 [inline]
       __br_forward+0x2e4/0x400 net/bridge/br_forward.c:115
       br_flood+0x521/0x5c0 net/bridge/br_forward.c:242
       br_dev_xmit+0x8b6/0x960
       __netdev_start_xmit include/linux/netdevice.h:4683 [inline]
       netdev_start_xmit include/linux/netdevice.h:4697 [inline]
       xmit_one+0x105/0x2f0 net/core/dev.c:3473
       dev_hard_start_xmit net/core/dev.c:3489 [inline]
       __dev_queue_xmit+0x86d/0xf90 net/core/dev.c:4116
       dev_queue_xmit+0x13/0x20 net/core/dev.c:4149
       neigh_hh_output include/net/neighbour.h:525 [inline]
       neigh_output include/net/neighbour.h:539 [inline]
       ip_finish_output2+0x6f8/0xb70 net/ipv4/ip_output.c:228
       ip_finish_output+0xfb/0x240 net/ipv4/ip_output.c:316
       NF_HOOK_COND include/linux/netfilter.h:296 [inline]
       ip_output+0xf3/0x1a0 net/ipv4/ip_output.c:430
       dst_output include/net/dst.h:451 [inline]
       ip_local_out net/ipv4/ip_output.c:126 [inline]
       ip_send_skb+0x6e/0xe0 net/ipv4/ip_output.c:1570
       udp_send_skb+0x641/0x880 net/ipv4/udp.c:967
       udp_sendmsg+0x12ea/0x14c0 net/ipv4/udp.c:1254
       inet_sendmsg+0x5f/0x80 net/ipv4/af_inet.c:819
       sock_sendmsg_nosec net/socket.c:705 [inline]
       sock_sendmsg net/socket.c:725 [inline]
       ____sys_sendmsg+0x39a/0x510 net/socket.c:2413
       ___sys_sendmsg net/socket.c:2467 [inline]
       __sys_sendmmsg+0x267/0x4c0 net/socket.c:2553
       __do_sys_sendmmsg net/socket.c:2582 [inline]
       __se_sys_sendmmsg net/socket.c:2579 [inline]
       __x64_sys_sendmmsg+0x53/0x60 net/socket.c:2579
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      read to 0xffff888133d9a9f8 of 1 bytes by task 23563 on cpu 1:
       __veth_xdp_flush drivers/net/veth.c:268 [inline]
       veth_xmit+0x2d6/0x470 drivers/net/veth.c:350
       __netdev_start_xmit include/linux/netdevice.h:4683 [inline]
       netdev_start_xmit include/linux/netdevice.h:4697 [inline]
       xmit_one+0x105/0x2f0 net/core/dev.c:3473
       dev_hard_start_xmit net/core/dev.c:3489 [inline]
       __dev_queue_xmit+0x86d/0xf90 net/core/dev.c:4116
       dev_queue_xmit+0x13/0x20 net/core/dev.c:4149
       br_dev_queue_push_xmit+0x3ce/0x430 net/bridge/br_forward.c:53
       NF_HOOK include/linux/netfilter.h:307 [inline]
       br_forward_finish net/bridge/br_forward.c:66 [inline]
       NF_HOOK include/linux/netfilter.h:307 [inline]
       __br_forward+0x2e4/0x400 net/bridge/br_forward.c:115
       br_flood+0x521/0x5c0 net/bridge/br_forward.c:242
       br_dev_xmit+0x8b6/0x960
       __netdev_start_xmit include/linux/netdevice.h:4683 [inline]
       netdev_start_xmit include/linux/netdevice.h:4697 [inline]
       xmit_one+0x105/0x2f0 net/core/dev.c:3473
       dev_hard_start_xmit net/core/dev.c:3489 [inline]
       __dev_queue_xmit+0x86d/0xf90 net/core/dev.c:4116
       dev_queue_xmit+0x13/0x20 net/core/dev.c:4149
       neigh_hh_output include/net/neighbour.h:525 [inline]
       neigh_output include/net/neighbour.h:539 [inline]
       ip_finish_output2+0x6f8/0xb70 net/ipv4/ip_output.c:228
       ip_finish_output+0xfb/0x240 net/ipv4/ip_output.c:316
       NF_HOOK_COND include/linux/netfilter.h:296 [inline]
       ip_output+0xf3/0x1a0 net/ipv4/ip_output.c:430
       dst_output include/net/dst.h:451 [inline]
       ip_local_out net/ipv4/ip_output.c:126 [inline]
       ip_send_skb+0x6e/0xe0 net/ipv4/ip_output.c:1570
       udp_send_skb+0x641/0x880 net/ipv4/udp.c:967
       udp_sendmsg+0x12ea/0x14c0 net/ipv4/udp.c:1254
       inet_sendmsg+0x5f/0x80 net/ipv4/af_inet.c:819
       sock_sendmsg_nosec net/socket.c:705 [inline]
       sock_sendmsg net/socket.c:725 [inline]
       ____sys_sendmsg+0x39a/0x510 net/socket.c:2413
       ___sys_sendmsg net/socket.c:2467 [inline]
       __sys_sendmmsg+0x267/0x4c0 net/socket.c:2553
       __do_sys_sendmmsg net/socket.c:2582 [inline]
       __se_sys_sendmmsg net/socket.c:2579 [inline]
       __x64_sys_sendmmsg+0x53/0x60 net/socket.c:2579
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      value changed: 0x00 -> 0x01
      
      Reported by Kernel Concurrency Sanitizer on:
      CPU: 1 PID: 23563 Comm: syz-executor.5 Not tainted 5.17.0-rc2-syzkaller-00064-gc36c04c2e132 #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      
      Fixes: 948d4f21
      
       ("veth: Add driver XDP")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b8ac37e5
    • Antoine Tenart's avatar
      net: fix a memleak when uncloning an skb dst and its metadata · fdcb263f
      Antoine Tenart authored
      [ Upstream commit 9eeabdf1 ]
      
      When uncloning an skb dst and its associated metadata, a new
      dst+metadata is allocated and later replaces the old one in the skb.
      This is helpful to have a non-shared dst+metadata attached to a specific
      skb.
      
      The issue is the uncloned dst+metadata is initialized with a refcount of
      1, which is increased to 2 before attaching it to the skb. When
      tun_dst_unclone returns, the dst+metadata is only referenced from a
      single place (the skb) while its refcount is 2. Its refcount will never
      drop to 0 (when the skb is consumed), leading to a memory leak.
      
      Fix this by removing the call to dst_hold in tun_dst_unclone, as the
      dst+metadata refcount is already 1.
      
      Fixes: fc4099f1
      
       ("openvswitch: Fix egress tunnel info.")
      Cc: Pravin B Shelar <pshelar@ovn.org>
      Reported-by: default avatarVlad Buslov <vladbu@nvidia.com>
      Tested-by: default avatarVlad Buslov <vladbu@nvidia.com>
      Signed-off-by: default avatarAntoine Tenart <atenart@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fdcb263f
    • Antoine Tenart's avatar
      net: do not keep the dst cache when uncloning an skb dst and its metadata · f1ab1ba3
      Antoine Tenart authored
      [ Upstream commit cfc56f85 ]
      
      When uncloning an skb dst and its associated metadata a new dst+metadata
      is allocated and the tunnel information from the old metadata is copied
      over there.
      
      The issue is the tunnel metadata has references to cached dst, which are
      copied along the way. When a dst+metadata refcount drops to 0 the
      metadata is freed including the cached dst entries. As they are also
      referenced in the initial dst+metadata, this ends up in UaFs.
      
      In practice the above did not happen because of another issue, the
      dst+metadata was never freed because its refcount never dropped to 0
      (this will be fixed in a subsequent patch).
      
      Fix this by initializing the dst cache after copying the tunnel
      information from the old metadata to also unshare the dst cache.
      
      Fixes: d71785ff
      
       ("net: add dst_cache to ovs vxlan lwtunnel")
      Cc: Paolo Abeni <pabeni@redhat.com>
      Reported-by: default avatarVlad Buslov <vladbu@nvidia.com>
      Tested-by: default avatarVlad Buslov <vladbu@nvidia.com>
      Signed-off-by: default avatarAntoine Tenart <atenart@kernel.org>
      Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f1ab1ba3
    • Louis Peens's avatar
      nfp: flower: fix ida_idx not being released · 6cbe14cc
      Louis Peens authored
      [ Upstream commit 7db788ad ]
      
      When looking for a global mac index the extra NFP_TUN_PRE_TUN_IDX_BIT
      that gets set if nfp_flower_is_supported_bridge is true is not taken
      into account. Consequently the path that should release the ida_index
      in cleanup is never triggered, causing messages like:
      
          nfp 0000:02:00.0: nfp: Failed to offload MAC on br-ex.
          nfp 0000:02:00.0: nfp: Failed to offload MAC on br-ex.
          nfp 0000:02:00.0: nfp: Failed to offload MAC on br-ex.
      
      after NFP_MAX_MAC_INDEX number of reconfigs. Ultimately this lead to
      new tunnel flows not being offloaded.
      
      Fix this by unsetting the NFP_TUN_PRE_TUN_IDX_BIT before checking if
      the port is of type OTHER.
      
      Fixes: 2e0bc7f3
      
       ("nfp: flower: encode mac indexes with pre-tunnel rule check")
      Signed-off-by: default avatarLouis Peens <louis.peens@corigine.com>
      Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
      Link: https://lore.kernel.org/r/20220208101453.321949-1-simon.horman@corigine.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6cbe14cc
    • Eric Dumazet's avatar
      ipmr,ip6mr: acquire RTNL before calling ip[6]mr_free_table() on failure path · 3cab045c
      Eric Dumazet authored
      [ Upstream commit 5611a006 ]
      
      ip[6]mr_free_table() can only be called under RTNL lock.
      
      RTNL: assertion failed at net/core/dev.c (10367)
      WARNING: CPU: 1 PID: 5890 at net/core/dev.c:10367 unregister_netdevice_many+0x1246/0x1850 net/core/dev.c:10367
      Modules linked in:
      CPU: 1 PID: 5890 Comm: syz-executor.2 Not tainted 5.16.0-syzkaller-11627-g422ee58dc0ef #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      RIP: 0010:unregister_netdevice_many+0x1246/0x1850 net/core/dev.c:10367
      Code: 0f 85 9b ee ff ff e8 69 07 4b fa ba 7f 28 00 00 48 c7 c6 00 90 ae 8a 48 c7 c7 40 90 ae 8a c6 05 6d b1 51 06 01 e8 8c 90 d8 01 <0f> 0b e9 70 ee ff ff e8 3e 07 4b fa 4c 89 e7 e8 86 2a 59 fa e9 ee
      RSP: 0018:ffffc900046ff6e0 EFLAGS: 00010286
      RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
      RDX: ffff888050f51d00 RSI: ffffffff815fa008 RDI: fffff520008dfece
      RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
      R10: ffffffff815f3d6e R11: 0000000000000000 R12: 00000000fffffff4
      R13: dffffc0000000000 R14: ffffc900046ff750 R15: ffff88807b7dc000
      FS:  00007f4ab736e700(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007fee0b4f8990 CR3: 000000001e7d2000 CR4: 00000000003506e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       <TASK>
       mroute_clean_tables+0x244/0xb40 net/ipv6/ip6mr.c:1509
       ip6mr_free_table net/ipv6/ip6mr.c:389 [inline]
       ip6mr_rules_init net/ipv6/ip6mr.c:246 [inline]
       ip6mr_net_init net/ipv6/ip6mr.c:1306 [inline]
       ip6mr_net_init+0x3f0/0x4e0 net/ipv6/ip6mr.c:1298
       ops_init+0xaf/0x470 net/core/net_namespace.c:140
       setup_net+0x54f/0xbb0 net/core/net_namespace.c:331
       copy_net_ns+0x318/0x760 net/core/net_namespace.c:475
       create_new_namespaces+0x3f6/0xb20 kernel/nsproxy.c:110
       copy_namespaces+0x391/0x450 kernel/nsproxy.c:178
       copy_process+0x2e0c/0x7300 kernel/fork.c:2167
       kernel_clone+0xe7/0xab0 kernel/fork.c:2555
       __do_sys_clone+0xc8/0x110 kernel/fork.c:2672
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      RIP: 0033:0x7f4ab89f9059
      Code: Unable to access opcode bytes at RIP 0x7f4ab89f902f.
      RSP: 002b:00007f4ab736e118 EFLAGS: 00000206 ORIG_RAX: 0000000000000038
      RAX: ffffffffffffffda RBX: 00007f4ab8b0bf60 RCX: 00007f4ab89f9059
      RDX: 0000000020000280 RSI: 0000000020000270 RDI: 0000000040200000
      RBP: 00007f4ab8a5308d R08: 0000000020000300 R09: 0000000020000300
      R10: 00000000200002c0 R11: 0000000000000206 R12: 0000000000000000
      R13: 00007ffc3977cc1f R14: 00007f4ab736e300 R15: 0000000000022000
       </TASK>
      
      Fixes: f243e5a7
      
       ("ipmr,ip6mr: call ip6mr_free_table() on failure path")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Cong Wang <cong.wang@bytedance.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Link: https://lore.kernel.org/r/20220208053451.2885398-1-eric.dumazet@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3cab045c
    • Vladimir Oltean's avatar
      net: dsa: lantiq_gswip: don't use devres for mdiobus · b5652bc5
      Vladimir Oltean authored
      [ Upstream commit 0d120dfb ]
      
      As explained in commits:
      74b6d7d1 ("net: dsa: realtek: register the MDIO bus under devres")
      5135e96a ("net: dsa: don't allocate the slave_mii_bus using devres")
      
      mdiobus_free() will panic when called from devm_mdiobus_free() <-
      devres_release_all() <- __device_release_driver(), and that mdiobus was
      not previously unregistered.
      
      The GSWIP switch is a platform device, so the initial set of constraints
      that I thought would cause this (I2C or SPI buses which call ->remove on
      ->shutdown) do not apply. But there is one more which applies here.
      
      If the DSA master itself is on a bus that calls ->remove from ->shutdown
      (like dpaa2-eth, which is on the fsl-mc bus), there is a device link
      between the switch and the DSA master, and device_links_unbind_consumers()
      will unbind the GSWIP switch driver on shutdown.
      
      So the same treatment must be applied to all DSA switch drivers, which
      is: either use devres for both the mdiobus allocation and registration,
      or don't use devres at all.
      
      The gswip driver has the code structure in place for orderly mdiobus
      removal, so just replace devm_mdiobus_alloc() with the non-devres
      variant, and add manual free where necessary, to ensure that we don't
      let devres free a still-registered bus.
      
      Fixes: ac3a68d5
      
       ("net: phy: don't abuse devres in devm_mdiobus_register()")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b5652bc5
    • Vladimir Oltean's avatar
      net: dsa: mt7530: fix kernel bug in mdiobus_free() when unbinding · 46b74723
      Vladimir Oltean authored
      [ Upstream commit 9ffe3d09 ]
      
      Nobody in this driver calls mdiobus_unregister(), which is necessary if
      mdiobus_register() completes successfully. So if the devres callbacks
      that free the mdiobus get invoked (this is the case when unbinding the
      driver), mdiobus_free() will BUG if the mdiobus is still registered,
      which it is.
      
      My speculation is that this is due to the fact that prior to commit
      ac3a68d5 ("net: phy: don't abuse devres in devm_mdiobus_register()")
      from June 2020, _devm_mdiobus_free() used to call mdiobus_unregister().
      But at the time that the mt7530 support was introduced in May 2021, the
      API was already changed. It's therefore likely that the blamed patch was
      developed on an older tree, and incorrectly adapted to net-next. This
      makes the Fixes: tag correct.
      
      Fix the problem by using the devres variant of mdiobus_register.
      
      Fixes: ba751e28
      
       ("net: dsa: mt7530: add interrupt support")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      46b74723
    • Vladimir Oltean's avatar
      net: dsa: felix: don't use devres for mdiobus · 8cda7577
      Vladimir Oltean authored
      [ Upstream commit 209bdb7e ]
      
      As explained in commits:
      74b6d7d1 ("net: dsa: realtek: register the MDIO bus under devres")
      5135e96a ("net: dsa: don't allocate the slave_mii_bus using devres")
      
      mdiobus_free() will panic when called from devm_mdiobus_free() <-
      devres_release_all() <- __device_release_driver(), and that mdiobus was
      not previously unregistered.
      
      The Felix VSC9959 switch is a PCI device, so the initial set of
      constraints that I thought would cause this (I2C or SPI buses which call
      ->remove on ->shutdown) do not apply. But there is one more which
      applies here.
      
      If the DSA master itself is on a bus that calls ->remove from ->shutdown
      (like dpaa2-eth, which is on the fsl-mc bus), there is a device link
      between the switch and the DSA master, and device_links_unbind_consumers()
      will unbind the felix switch driver on shutdown.
      
      So the same treatment must be applied to all DSA switch drivers, which
      is: either use devres for both the mdiobus allocation and registration,
      or don't use devres at all.
      
      The felix driver has the code structure in place for orderly mdiobus
      removal, so just replace devm_mdiobus_alloc_size() with the non-devres
      variant, and add manual free where necessary, to ensure that we don't
      let devres free a still-registered bus.
      
      Fixes: ac3a68d5
      
       ("net: phy: don't abuse devres in devm_mdiobus_register()")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8cda7577
    • Vladimir Oltean's avatar
      net: dsa: bcm_sf2: don't use devres for mdiobus · caabb5f6
      Vladimir Oltean authored
      [ Upstream commit 08f1a208 ]
      
      As explained in commits:
      74b6d7d1 ("net: dsa: realtek: register the MDIO bus under devres")
      5135e96a ("net: dsa: don't allocate the slave_mii_bus using devres")
      
      mdiobus_free() will panic when called from devm_mdiobus_free() <-
      devres_release_all() <- __device_release_driver(), and that mdiobus was
      not previously unregistered.
      
      The Starfighter 2 is a platform device, so the initial set of
      constraints that I thought would cause this (I2C or SPI buses which call
      ->remove on ->shutdown) do not apply. But there is one more which
      applies here.
      
      If the DSA master itself is on a bus that calls ->remove from ->shutdown
      (like dpaa2-eth, which is on the fsl-mc bus), there is a device link
      between the switch and the DSA master, and device_links_unbind_consumers()
      will unbind the bcm_sf2 switch driver on shutdown.
      
      So the same treatment must be applied to all DSA switch drivers, which
      is: either use devres for both the mdiobus allocation and registration,
      or don't use devres at all.
      
      The bcm_sf2 driver has the code structure in place for orderly mdiobus
      removal, so just replace devm_mdiobus_alloc() with the non-devres
      variant, and add manual free where necessary, to ensure that we don't
      let devres free a still-registered bus.
      
      Fixes: ac3a68d5
      
       ("net: phy: don't abuse devres in devm_mdiobus_register()")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      caabb5f6
    • Vladimir Oltean's avatar
      net: dsa: ar9331: register the mdiobus under devres · aae1c6a1
      Vladimir Oltean authored
      [ Upstream commit 50facd86 ]
      
      As explained in commits:
      74b6d7d1 ("net: dsa: realtek: register the MDIO bus under devres")
      5135e96a ("net: dsa: don't allocate the slave_mii_bus using devres")
      
      mdiobus_free() will panic when called from devm_mdiobus_free() <-
      devres_release_all() <- __device_release_driver(), and that mdiobus was
      not previously unregistered.
      
      The ar9331 is an MDIO device, so the initial set of constraints that I
      thought would cause this (I2C or SPI buses which call ->remove on
      ->shutdown) do not apply. But there is one more which applies here.
      
      If the DSA master itself is on a bus that calls ->remove from ->shutdown
      (like dpaa2-eth, which is on the fsl-mc bus), there is a device link
      between the switch and the DSA master, and device_links_unbind_consumers()
      will unbind the ar9331 switch driver on shutdown.
      
      So the same treatment must be applied to all DSA switch drivers, which
      is: either use devres for both the mdiobus allocation and registration,
      or don't use devres at all.
      
      The ar9331 driver doesn't have a complex code structure for mdiobus
      removal, so just replace of_mdiobus_register with the devres variant in
      order to be all-devres and ensure that we don't free a still-registered
      bus.
      
      Fixes: ac3a68d5
      
       ("net: phy: don't abuse devres in devm_mdiobus_register()")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Tested-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      aae1c6a1
    • Vladimir Oltean's avatar
      net: dsa: mv88e6xxx: don't use devres for mdiobus · 8b626d45
      Vladimir Oltean authored
      [ Upstream commit f53a2ce8 ]
      
      As explained in commits:
      74b6d7d1 ("net: dsa: realtek: register the MDIO bus under devres")
      5135e96a ("net: dsa: don't allocate the slave_mii_bus using devres")
      
      mdiobus_free() will panic when called from devm_mdiobus_free() <-
      devres_release_all() <- __device_release_driver(), and that mdiobus was
      not previously unregistered.
      
      The mv88e6xxx is an MDIO device, so the initial set of constraints that
      I thought would cause this (I2C or SPI buses which call ->remove on
      ->shutdown) do not apply. But there is one more which applies here.
      
      If the DSA master itself is on a bus that calls ->remove from ->shutdown
      (like dpaa2-eth, which is on the fsl-mc bus), there is a device link
      between the switch and the DSA master, and device_links_unbind_consumers()
      will unbind the Marvell switch driver on shutdown.
      
      systemd-shutdown[1]: Powering off.
      mv88e6085 0x0000000008b96000:00 sw_gl0: Link is Down
      fsl-mc dpbp.9: Removing from iommu group 7
      fsl-mc dpbp.8: Removing from iommu group 7
      ------------[ cut here ]------------
      kernel BUG at drivers/net/phy/mdio_bus.c:677!
      Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
      Modules linked in:
      CPU: 0 PID: 1 Comm: systemd-shutdow Not tainted 5.16.5-00040-gdc05f73788e5 #15
      pc : mdiobus_free+0x44/0x50
      lr : devm_mdiobus_free+0x10/0x20
      Call trace:
       mdiobus_free+0x44/0x50
       devm_mdiobus_free+0x10/0x20
       devres_release_all+0xa0/0x100
       __device_release_driver+0x190/0x220
       device_release_driver_internal+0xac/0xb0
       device_links_unbind_consumers+0xd4/0x100
       __device_release_driver+0x4c/0x220
       device_release_driver_internal+0xac/0xb0
       device_links_unbind_consumers+0xd4/0x100
       __device_release_driver+0x94/0x220
       device_release_driver+0x28/0x40
       bus_remove_device+0x118/0x124
       device_del+0x174/0x420
       fsl_mc_device_remove+0x24/0x40
       __fsl_mc_device_remove+0xc/0x20
       device_for_each_child+0x58/0xa0
       dprc_remove+0x90/0xb0
       fsl_mc_driver_remove+0x20/0x5c
       __device_release_driver+0x21c/0x220
       device_release_driver+0x28/0x40
       bus_remove_device+0x118/0x124
       device_del+0x174/0x420
       fsl_mc_bus_remove+0x80/0x100
       fsl_mc_bus_shutdown+0xc/0x1c
       platform_shutdown+0x20/0x30
       device_shutdown+0x154/0x330
       kernel_power_off+0x34/0x6c
       __do_sys_reboot+0x15c/0x250
       __arm64_sys_reboot+0x20/0x30
       invoke_syscall.constprop.0+0x4c/0xe0
       do_el0_svc+0x4c/0x150
       el0_svc+0x24/0xb0
       el0t_64_sync_handler+0xa8/0xb0
       el0t_64_sync+0x178/0x17c
      
      So the same treatment must be applied to all DSA switch drivers, which
      is: either use devres for both the mdiobus allocation and registration,
      or don't use devres at all.
      
      The Marvell driver already has a good structure for mdiobus removal, so
      just plug in mdiobus_free and get rid of devres.
      
      Fixes: ac3a68d5
      
       ("net: phy: don't abuse devres in devm_mdiobus_register()")
      Reported-by: default avatarRafael Richter <Rafael.Richter@gin.de>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Tested-by: default avatarDaniel Klauer <daniel.klauer@gin.de>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8b626d45
    • Mahesh Bandewar's avatar
      bonding: pair enable_port with slave_arr_updates · 147540ca
      Mahesh Bandewar authored
      [ Upstream commit 23de0d7b ]
      
      When 803.2ad mode enables a participating port, it should update
      the slave-array. I have observed that the member links are participating
      and are part of the active aggregator while the traffic is egressing via
      only one member link (in a case where two links are participating). Via
      kprobes I discovered that slave-arr has only one link added while
      the other participating link wasn't part of the slave-arr.
      
      I couldn't see what caused that situation but the simple code-walk
      through provided me hints that the enable_port wasn't always associated
      with the slave-array update.
      
      Fixes: ee637714
      
       ("bonding: Simplify the xmit function for modes that use xmit_hash")
      Signed-off-by: default avatarMahesh Bandewar <maheshb@google.com>
      Acked-by: default avatarJay Vosburgh <jay.vosburgh@canonical.com>
      Link: https://lore.kernel.org/r/20220207222901.1795287-1-maheshb@google.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      147540ca
    • Helge Deller's avatar
      fbcon: Avoid 'cap' set but not used warning · 3523167d
      Helge Deller authored
      [ Upstream commit 50b10528 ]
      
      Fix this kernel test robot warning:
      
        drivers/video/fbdev/core/fbcon.c: In function 'fbcon_init':
        drivers/video/fbdev/core/fbcon.c:1028:6: warning: variable 'cap' set but not used [-Wunused-but-set-variable]
      
      The cap variable is only used when CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION
      is enabled. Drop the temporary variable and use info->flags instead.
      
      Fixes: 87ab9f6b
      
       ("Revert "fbcon: Disable accelerated scrolling")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/YgFB4xqI+As196FR@p100
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3523167d
    • Niklas Cassel's avatar
      gpio: sifive: use the correct register to read output values · ef2cb1fc
      Niklas Cassel authored
      [ Upstream commit cc38ef93 ]
      
      Setting the output of a GPIO to 1 using gpiod_set_value(), followed by
      reading the same GPIO using gpiod_get_value(), will currently yield an
      incorrect result.
      
      This is because the SiFive GPIO device stores the output values in reg_set,
      not reg_dat.
      
      Supply the flag BGPIOF_READ_OUTPUT_REG_SET to bgpio_init() so that the
      generic driver reads the correct register.
      
      Fixes: 96868dce
      
       ("gpio/sifive: Add GPIO driver for SiFive SoCs")
      Signed-off-by: default avatarNiklas Cassel <niklas.cassel@wdc.com>
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      [Bartosz: added the Fixes tag]
      Signed-off-by: default avatarBartosz Golaszewski <brgl@bgdev.pl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ef2cb1fc
    • Andy Shevchenko's avatar
      gpiolib: Never return internal error codes to user space · d9daa2b7
      Andy Shevchenko authored
      [ Upstream commit 95a4eed7 ]
      
      Currently it's possible that character device interface may return
      the error codes which are not supposed to be seen by user space.
      In this case it's EPROBE_DEFER.
      
      Wrap it to return -ENODEV instead as sysfs does.
      
      Fixes: d7c51b47 ("gpio: userspace ABI for reading/writing GPIO lines")
      Fixes: 61f922db ("gpio: userspace ABI for reading GPIO line events")
      Fixes: 3c0d9c63
      
       ("gpiolib: cdev: support GPIO_V2_GET_LINE_IOCTL and GPIO_V2_LINE_GET_VALUES_IOCTL")
      Reported-by: default avatarSuresh Balakrishnan <suresh.balakrishnan@intel.com>
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarBartosz Golaszewski <brgl@bgdev.pl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d9daa2b7
    • Rafael J. Wysocki's avatar
      ACPI: PM: s2idle: Cancel wakeup before dispatching EC GPE · e799974e
      Rafael J. Wysocki authored
      [ Upstream commit dc0075ba ]
      
      Commit 4a9af6ca ("ACPI: EC: Rework flushing of EC work while
      suspended to idle") made acpi_ec_dispatch_gpe() check
      pm_wakeup_pending(), but that is before canceling the SCI wakeup,
      so pm_wakeup_pending() is always true.  This causes the loop in
      acpi_ec_dispatch_gpe() to always terminate after one iteration which
      may not be correct.
      
      Address this issue by canceling the SCI wakeup earlier, from
      acpi_ec_dispatch_gpe() itself.
      
      Fixes: 4a9af6ca
      
       ("ACPI: EC: Rework flushing of EC work while suspended to idle")
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e799974e
    • Christoph Niedermaier's avatar
      drm/panel: simple: Assign data from panel_dpi_probe() correctly · ab142ea5
      Christoph Niedermaier authored
      [ Upstream commit 6df4432a ]
      
      In the function panel_simple_probe() the pointer panel->desc is
      assigned to the passed pointer desc. If function panel_dpi_probe()
      is called panel->desc will be updated, but further on only desc
      will be evaluated. So update the desc pointer to be able to use
      the data from the function panel_dpi_probe().
      
      Fixes: 4a1d0dbc
      
       ("drm/panel: simple: add panel-dpi support")
      
      Signed-off-by: default avatarChristoph Niedermaier <cniedermaier@dh-electronics.com>
      Cc: Marek Vasut <marex@denx.de>
      Cc: Thierry Reding <thierry.reding@gmail.com>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      To: dri-devel@lists.freedesktop.org
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220201110153.3479-1-cniedermaier@dh-electronics.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ab142ea5
    • Samuel Mendoza-Jonas's avatar
      ixgbevf: Require large buffers for build_skb on 82599VF · 9e3dd491
      Samuel Mendoza-Jonas authored
      [ Upstream commit fe68195d ]
      
      From 4.17 onwards the ixgbevf driver uses build_skb() to build an skb
      around new data in the page buffer shared with the ixgbe PF.
      This uses either a 2K or 3K buffer, and offsets the DMA mapping by
      NET_SKB_PAD + NET_IP_ALIGN. When using a smaller buffer RXDCTL is set to
      ensure the PF does not write a full 2K bytes into the buffer, which is
      actually 2K minus the offset.
      
      However on the 82599 virtual function, the RXDCTL mechanism is not
      available. The driver attempts to work around this by using the SET_LPE
      mailbox method to lower the maximm frame size, but the ixgbe PF driver
      ignores this in order to keep the PF and all VFs in sync[0].
      
      This means the PF will write up to the full 2K set in SRRCTL, causing it
      to write NET_SKB_PAD + NET_IP_ALIGN bytes past the end of the buffer.
      With 4K pages split into two buffers, this means it either writes
      NET_SKB_PAD + NET_IP_ALIGN bytes past the first buffer (and into the
      second), or NET_SKB_PAD + NET_IP_ALIGN bytes past the end of the DMA
      mapping.
      
      Avoid this by only enabling build_skb when using "large" buffers (3K).
      These are placed in each half of an order-1 page, preventing the PF from
      writing past the end of the mapping.
      
      [0]: Technically it only ever raises the max frame size, see
      ixgbe_set_vf_lpe() in ixgbe_sriov.c
      
      Fixes: f15c5ba5
      
       ("ixgbevf: add support for using order 1 pages to receive large frames")
      Signed-off-by: default avatarSamuel Mendoza-Jonas <samjonas@amazon.com>
      Tested-by: default avatarKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9e3dd491
    • Lutz Koschorreck's avatar
      arm64: dts: meson-sm1-odroid: fix boot loop after reboot · 51eece9f
      Lutz Koschorreck authored
      [ Upstream commit e6b03375 ]
      
      Since the correct gpio pin is used for enabling tf-io regulator the
      system did not boot correctly after calling reboot.
      
      [   36.862443] reboot: Restarting system
      bl31 reboot reason: 0xd
      bl31 reboot reason: 0x0
      system cmd  1.
      SM1:BL:511f6b:81ca2f;FEAT:A0F83180:20282000;POC:B;RCY:0;SPINOR:0;CHK:1F;EMMC:800;NAND:81;SD?:0;SD:0;READ:0;0.0;CHK:0;
      bl2_stage_init 0x01
      bl2_stage_init 0x81
      hw id:
      SM1:BL:511f6b:81ca2f;FEAT:A0F83180:20282000;POC:B;RCY:0;SPINOR:0;CHK:1F;EMMC:800;NAND:81;SD?:0;SD:400;USB:8;LOOP:1;...
      
      Setting the gpio to open drain solves the issue.
      
      Fixes: 1f80a5cf
      
       ("arm64: dts: meson-sm1-odroid: add missing enable gpio and supply for tf_io regulator")
      Signed-off-by: default avatarLutz Koschorreck <theleks@ko-hh.de>
      Reviewed-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
      [narmstrong: reduced serial log & removed invalid character in commit message]
      Signed-off-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
      Link: https://lore.kernel.org/r/20220128193150.GA1304381@odroid-VirtualBox
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      51eece9f