Skip to content
  1. Feb 16, 2022
    • Johan Hovold's avatar
      USB: serial: cp210x: add NCR Retail IO box id · 51b03a9b
      Johan Hovold authored
      commit b50f8f09
      
       upstream.
      
      Add the device id for NCR's Retail IO box (CP2105) used in NCR FastLane
      SelfServ Checkout - R6C:
      
      	https://www.ncr.com/product-catalog/ncr-fastlane-selfserv-checkout-r6c
      
      Reported-by: default avatarScott Russell <Scott.Russell2@ncr.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      51b03a9b
    • Stephan Brunner's avatar
      USB: serial: ch341: add support for GW Instek USB2.0-Serial devices · a21e6b2e
      Stephan Brunner authored
      commit fa77ce20
      
       upstream.
      
      Programmable lab power supplies made by GW Instek, such as the
      GPP-2323, have a USB port exposing a serial port to control the device.
      
      Stringing the supplied Windows driver, references to the ch341 chip are
      found. Binding the existing ch341 driver to the VID/PID of the GPP-2323
      ("GW Instek USB2.0-Serial" as per the USB product name) works out of the
      box, communication and control is now possible.
      
      This patch should work with any GPP series power supply due to
      similarities in the product line.
      
      Signed-off-by: default avatarStephan Brunner <s.brunner@stephan-brunner.net>
      Link: https://lore.kernel.org/r/4a47b864-0816-6f6a-efee-aa20e74bcdc6@stephan-brunner.net
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a21e6b2e
    • Pawel Dembicki's avatar
      USB: serial: option: add ZTE MF286D modem · 7113440a
      Pawel Dembicki authored
      commit d48384c7
      
       upstream.
      
      Modem from ZTE MF286D is an Qualcomm MDM9250 based 3G/4G modem.
      
      T:  Bus=02 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  3 Spd=5000 MxCh= 0
      D:  Ver= 3.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs=  1
      P:  Vendor=19d2 ProdID=1485 Rev=52.87
      S:  Manufacturer=ZTE,Incorporated
      S:  Product=ZTE Technologies MSM
      S:  SerialNumber=MF286DZTED000000
      C:* #Ifs= 7 Cfg#= 1 Atr=80 MxPwr=896mA
      A:  FirstIf#= 0 IfCount= 2 Cls=02(comm.) Sub=06 Prot=00
      I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=02 Prot=ff Driver=rndis_host
      E:  Ad=82(I) Atr=03(Int.) MxPS=   8 Ivl=32ms
      I:* If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=rndis_host
      E:  Ad=81(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
      E:  Ad=01(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
      I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
      E:  Ad=83(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
      E:  Ad=02(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
      I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
      E:  Ad=85(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
      E:  Ad=84(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
      E:  Ad=03(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
      I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
      E:  Ad=87(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
      E:  Ad=86(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
      E:  Ad=04(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
      I:* If#= 5 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
      E:  Ad=88(I) Atr=03(Int.) MxPS=   8 Ivl=32ms
      E:  Ad=8e(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
      E:  Ad=0f(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
      I:* If#= 6 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=usbfs
      E:  Ad=05(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
      E:  Ad=89(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms
      
      Signed-off-by: default avatarPawel Dembicki <paweldembicki@gmail.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7113440a
    • Cameron Williams's avatar
      USB: serial: ftdi_sio: add support for Brainboxes US-159/235/320 · b7ed2f96
      Cameron Williams authored
      commit fbb9b194
      
       upstream.
      
      This patch adds support for the Brainboxes US-159, US-235 and US-320
      USB-to-Serial devices.
      
      Signed-off-by: default avatarCameron Williams <cang1@live.co.uk>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b7ed2f96
    • Jann Horn's avatar
      usb: raw-gadget: fix handling of dual-direction-capable endpoints · e07dde31
      Jann Horn authored
      commit 292d2c82 upstream.
      
      Under dummy_hcd, every available endpoint is *either* IN or OUT capable.
      But with some real hardware, there are endpoints that support both IN and
      OUT. In particular, the PLX 2380 has four available endpoints that each
      support both IN and OUT.
      
      raw-gadget currently gets confused and thinks that any endpoint that is
      usable as an IN endpoint can never be used as an OUT endpoint.
      
      Fix it by looking at the direction in the configured endpoint descriptor
      instead of looking at the hardware capabilities.
      
      With this change, I can use the PLX 2380 with raw-gadget.
      
      Fixes: f2c2e717
      
       ("usb: gadget: add raw-gadget interface")
      Cc: stable <stable@vger.kernel.org>
      Tested-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
      Reviewed-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Link: https://lore.kernel.org/r/20220126205214.2149936-1-jannh@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e07dde31
    • Pavel Hofman's avatar
      usb: gadget: f_uac2: Define specific wTerminalType · e9f9b877
      Pavel Hofman authored
      commit 54321841
      
       upstream.
      
      Several users have reported that their Win10 does not enumerate UAC2
      gadget with the existing wTerminalType set to
      UAC_INPUT_TERMINAL_UNDEFINED/UAC_INPUT_TERMINAL_UNDEFINED, e.g.
      https://github.com/raspberrypi/linux/issues/4587#issuecomment-926567213.
      While the constant is officially defined by the USB terminal types
      document, e.g. XMOS firmware for UAC2 (commonly used for Win10) defines
      no undefined output terminal type in its usbaudio20.h header.
      
      Therefore wTerminalType of EP-IN is set to
      UAC_INPUT_TERMINAL_MICROPHONE and wTerminalType of EP-OUT to
      UAC_OUTPUT_TERMINAL_SPEAKER for the UAC2 gadget.
      
      Signed-off-by: default avatarPavel Hofman <pavel.hofman@ivitera.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20220131071813.7433-1-pavel.hofman@ivitera.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e9f9b877
    • Greg Kroah-Hartman's avatar
      usb: gadget: rndis: check size of RNDIS_MSG_SET command · fb4ff0f9
      Greg Kroah-Hartman authored
      commit 38ea1eac
      
       upstream.
      
      Check the size of the RNDIS_MSG_SET command given to us before
      attempting to respond to an invalid message size.
      
      Reported-by: default avatarSzymon Heidrich <szymon.heidrich@gmail.com>
      Cc: stable@kernel.org
      Tested-by: default avatarSzymon Heidrich <szymon.heidrich@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fb4ff0f9
    • Szymon Heidrich's avatar
      USB: gadget: validate interface OS descriptor requests · 22ec1004
      Szymon Heidrich authored
      commit 75e5b484
      
       upstream.
      
      Stall the control endpoint in case provided index exceeds array size of
      MAX_CONFIG_INTERFACES or when the retrieved function pointer is null.
      
      Signed-off-by: default avatarSzymon Heidrich <szymon.heidrich@gmail.com>
      Cc: stable@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      22ec1004
    • Adam Ford's avatar
      usb: gadget: udc: renesas_usb3: Fix host to USB_ROLE_NONE transition · 35115916
      Adam Ford authored
      commit 459702ee upstream.
      
      The support the external role switch a variety of situations were
      addressed, but the transition from USB_ROLE_HOST to USB_ROLE_NONE
      leaves the host up which can cause some error messages when
      switching from host to none, to gadget, to none, and then back
      to host again.
      
       xhci-hcd ee000000.usb: Abort failed to stop command ring: -110
       xhci-hcd ee000000.usb: xHCI host controller not responding, assume dead
       xhci-hcd ee000000.usb: HC died; cleaning up
       usb 4-1: device not accepting address 6, error -108
       usb usb4-port1: couldn't allocate usb_device
      
      After this happens it will not act as a host again.
      Fix this by releasing the host mode when transitioning to USB_ROLE_NONE.
      
      Fixes: 0604160d
      
       ("usb: gadget: udc: renesas_usb3: Enhance role switch support")
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Signed-off-by: default avatarAdam Ford <aford173@gmail.com>
      Link: https://lore.kernel.org/r/20220128223603.2362621-1-aford173@gmail.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      35115916
    • Udipto Goswami's avatar
      usb: dwc3: gadget: Prevent core from processing stale TRBs · 3bfca389
      Udipto Goswami authored
      commit 117b4e96 upstream.
      
      With CPU re-ordering on write instructions, there might
      be a chance that the HWO is set before the TRB is updated
      with the new mapped buffer address.
      And in the case where core is processing a list of TRBs
      it is possible that it fetched the TRBs when the HWO is set
      but before the buffer address is updated.
      Prevent this by adding a memory barrier before the HWO
      is updated to ensure that the core always process the
      updated TRBs.
      
      Fixes: f6bafc6a
      
       ("usb: dwc3: convert TRBs into bitshifts")
      Cc: stable <stable@vger.kernel.org>
      Reviewed-by: default avatarPavankumar Kondeti <quic_pkondeti@quicinc.com>
      Signed-off-by: default avatarUdipto Goswami <quic_ugoswami@quicinc.com>
      Link: https://lore.kernel.org/r/1644207958-18287-1-git-send-email-quic_ugoswami@quicinc.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3bfca389
    • Sean Anderson's avatar
      usb: ulpi: Call of_node_put correctly · 2a17bd9f
      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>
      2a17bd9f
    • Sean Anderson's avatar
      usb: ulpi: Move of_node_put to ulpi_dev_release · 8b89a691
      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>
      8b89a691
    • Jann Horn's avatar
      net: usb: ax88179_178a: Fix out-of-bounds accesses in RX fixup · 758290de
      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>
      758290de
    • Greg Kroah-Hartman's avatar
      Revert "usb: dwc2: drd: fix soft connect when gadget is unconfigured" · a66a2b17
      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>
      a66a2b17
    • Fabrice Gasnier's avatar
      usb: dwc2: drd: fix soft connect when gadget is unconfigured · 73961057
      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>
      73961057
    • Jonas Malaco's avatar
      eeprom: ee1004: limit i2c reads to I2C_SMBUS_BLOCK_MAX · a37960df
      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>
      a37960df
    • TATSUKAWA KOSUKE (立川 江介)'s avatar
      n_tty: wake up poll(POLLRDNORM) on receiving data · 1b99fe34
      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>
      1b99fe34
    • Jakob Koschel's avatar
      vt_ioctl: add array_index_nospec to VT_ACTIVATE · f1b25737
      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>
      f1b25737
    • Jakob Koschel's avatar
      vt_ioctl: fix array_index_nospec in vt_setactivate · 778302ca
      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>
      778302ca
    • Vladimir Oltean's avatar
      net: dsa: mv88e6xxx: fix use-after-free in mv88e6xxx_mdios_unregister · 22249886
      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>
      22249886
    • Colin Foster's avatar
      net: mscc: ocelot: fix mutex lock error during ethtool stats read · 3a3c65c4
      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>
      3a3c65c4
    • Jesse Brandeburg's avatar
      ice: fix IPIP and SIT TSO offload · 809f0307
      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>
      809f0307
    • Dan Carpenter's avatar
      ice: fix an error code in ice_cfg_phy_fec() · cf11949b
      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>
      cf11949b
    • Robert-Ionut Alexa's avatar
      dpaa2-eth: unregister the netdev before disconnecting from the PHY · f8edc6fe
      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>
      f8edc6fe
    • Raju Rangoju's avatar
      net: amd-xgbe: disable interrupts during pci removal · ff6c9e0f
      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>
      ff6c9e0f
    • Jon Maloy's avatar
      tipc: rate limit warning for received illegal binding update · 657aea78
      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>
      657aea78
    • Joel Stanley's avatar
      net: mdio: aspeed: Add missing MODULE_DEVICE_TABLE · ef5cdae8
      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>
      ef5cdae8
    • Eric Dumazet's avatar
      veth: fix races around rq->rx_notify_masked · bf99c144
      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>
      bf99c144
    • Antoine Tenart's avatar
      net: fix a memleak when uncloning an skb dst and its metadata · 00e6d6c3
      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>
      00e6d6c3
    • Antoine Tenart's avatar
      net: do not keep the dst cache when uncloning an skb dst and its metadata · 2e9fd2d0
      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>
      2e9fd2d0
    • Louis Peens's avatar
      nfp: flower: fix ida_idx not being released · 0bae953d
      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>
      0bae953d
    • Eric Dumazet's avatar
      ipmr,ip6mr: acquire RTNL before calling ip[6]mr_free_table() on failure path · 09ac0fcb
      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>
      09ac0fcb
    • Vladimir Oltean's avatar
      net: dsa: lantiq_gswip: don't use devres for mdiobus · e177d2e8
      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>
      e177d2e8
    • Vladimir Oltean's avatar
      net: dsa: felix: don't use devres for mdiobus · 95e5402f
      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>
      95e5402f
    • Vladimir Oltean's avatar
      net: dsa: bcm_sf2: don't use devres for mdiobus · 2770b795
      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>
      2770b795
    • Vladimir Oltean's avatar
      net: dsa: ar9331: register the mdiobus under devres · 475ce5dc
      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>
      475ce5dc
    • Vladimir Oltean's avatar
      net: dsa: mv88e6xxx: don't use devres for mdiobus · 8ccebe77
      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>
      8ccebe77
    • Mahesh Bandewar's avatar
      bonding: pair enable_port with slave_arr_updates · 4a384c1e
      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>
      4a384c1e
    • Niklas Cassel's avatar
      gpio: sifive: use the correct register to read output values · 1ba45dd3
      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>
      1ba45dd3
    • Rafael J. Wysocki's avatar
      ACPI: PM: s2idle: Cancel wakeup before dispatching EC GPE · 48e41308
      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>
      48e41308