linux-stable/drivers/usb
Badhri Jagan Sridharan 286d9975a8 usb: gadget: udc: core: Prevent soft_connect_store() race
usb_udc_connect_control(), soft_connect_store() and
usb_gadget_deactivate() can potentially race against each other to invoke
usb_gadget_connect()/usb_gadget_disconnect(). To prevent this, guard
udc->started, gadget->allow_connect, gadget->deactivate and
gadget->connect with connect_lock so that ->pullup() is only invoked when
the gadget is bound, started and not deactivated. The routines
usb_gadget_connect_locked(), usb_gadget_disconnect_locked(),
usb_udc_connect_control_locked(), usb_gadget_udc_start_locked(),
usb_gadget_udc_stop_locked() are called with this lock held.

An earlier version of this commit was reverted due to the crash reported in
https://lore.kernel.org/all/ZF4BvgsOyoKxdPFF@francesco-nb.int.toradex.com/.
commit 16737e78d190 ("usb: gadget: udc: core: Offload usb_udc_vbus_handler processing")
addresses the crash reported.

Cc: stable@vger.kernel.org
Fixes: 628ef0d273 ("usb: udc: add usb_udc_vbus_handler")
Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Message-ID: <20230609010227.978661-2-badhri@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-06-13 12:16:34 +02:00
..
atm
c67x00
cdns3 usb: cdns3: fix NCM gadget RX speed 20x slow than expection at iMX8QM 2023-05-29 15:23:59 +01:00
chipidea usb: chipidea: fix missing goto in ci_hdrc_probe 2023-04-20 11:16:42 +02:00
class USB: usbtmc: Fix direction for 0-length ioctl control messages 2023-05-13 17:25:49 +09:00
common Char/Misc drivers for 6.4-rc1 2023-04-27 12:07:50 -07:00
core usb: usbfs: Use consistent mmap functions 2023-05-29 16:14:28 +01:00
dwc2 usb: dwc2: platform: add support for utmi optional clock 2023-04-20 10:17:06 +02:00
dwc3 USB: dwc3: fix use-after-free on core driver unbind 2023-06-13 11:52:32 +02:00
early
fotg210
gadget usb: gadget: udc: core: Prevent soft_connect_store() race 2023-06-13 12:16:34 +02:00
host xhci: Fix incorrect tracking of free space on transfer rings 2023-05-16 16:57:49 +02:00
image
isp1760
misc USB: sisusbvga: Add endpoint checks 2023-04-20 11:43:22 +02:00
mon
mtu3 usb: mtu3: add optional clock xhci_ck and frmcnt_ck 2023-04-20 11:17:05 +02:00
musb
phy
renesas_usbhs
roles
serial USB: serial: option: add Quectel EM061KGL series 2023-06-02 11:06:50 +02:00
storage usb-storage: fix deadlock when a scsi command timeouts more than once 2023-05-13 18:53:03 +09:00
typec usb: typec: Fix fast_role_swap_current show function 2023-06-13 12:16:07 +02:00
usbip
Kconfig
Makefile
usb-skeleton.c