linux/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 usb: move from strlcpy with unused retval to strscpy 2022-08-19 11:08:54 +02:00
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 usb: early: xhci-dbc: Use memcpy_and_pad() 2023-01-31 10:40:54 +01:00
fotg210 USB: fotg210: fix memory leak with using debugfs_lookup() 2023-02-06 13:46:42 +01:00
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 scsi: usb: uas: Declare two host templates and host template pointers const 2023-03-24 19:20:00 -04:00
isp1760
misc USB: sisusbvga: Add endpoint checks 2023-04-20 11:43:22 +02:00
mon driver core: class: remove module * from class_create() 2023-03-17 15:16:33 +01:00
mtu3 usb: mtu3: add optional clock xhci_ck and frmcnt_ck 2023-04-20 11:17:05 +02:00
musb usb: musb: ux500: Convert to platform remove callback returning void 2023-04-05 19:07:42 +02:00
phy usb: phy: twl6030: Convert to platform remove callback returning void 2023-03-23 17:35:27 +01:00
renesas_usbhs usb: renesas_usbhs: drop of_match_ptr for ID table 2023-03-16 12:15:23 +01:00
roles driver core: class: remove module * from class_create() 2023-03-17 15:16:33 +01:00
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 Including fixes from bpf, netfilter and can. 2022-12-21 08:41:32 -08:00
Kconfig usb: move config USB_USS720 to usb's misc Kconfig 2023-03-29 10:34:08 +02:00
Makefile usb: host: u132-hcd: Delete driver 2023-03-21 14:06:11 +01:00
usb-skeleton.c usb: add usb_set_intfdata() documentation 2022-11-29 08:56:09 +01:00