linux/drivers/usb
Tao Xue 8afb22aa06 usb: gadget : fix use-after-free in composite_dev_cleanup()
commit 151c0aa896 upstream.

1. In func configfs_composite_bind() -> composite_os_desc_req_prepare():
if kmalloc fails, the pointer cdev->os_desc_req will be freed but not
set to NULL. Then it will return a failure to the upper-level function.
2. in func configfs_composite_bind() -> composite_dev_cleanup():
it will checks whether cdev->os_desc_req is NULL. If it is not NULL, it
will attempt to use it.This will lead to a use-after-free issue.

BUG: KASAN: use-after-free in composite_dev_cleanup+0xf4/0x2c0
Read of size 8 at addr 0000004827837a00 by task init/1

CPU: 10 PID: 1 Comm: init Tainted: G           O      5.10.97-oh #1
 kasan_report+0x188/0x1cc
 __asan_load8+0xb4/0xbc
 composite_dev_cleanup+0xf4/0x2c0
 configfs_composite_bind+0x210/0x7ac
 udc_bind_to_driver+0xb4/0x1ec
 usb_gadget_probe_driver+0xec/0x21c
 gadget_dev_desc_UDC_store+0x264/0x27c

Fixes: 37a3a53342 ("usb: gadget: OS Feature Descriptors support")
Cc: stable <stable@kernel.org>
Signed-off-by: Tao Xue <xuetao09@huawei.com>
Link: https://lore.kernel.org/r/20250721093908.14967-1-xuetao09@huawei.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2025-08-28 16:24:14 +02:00
..
atm usb: atm: cxacru: fix a flaw in existing endpoint checks 2025-03-13 12:51:08 +01:00
c67x00 usb/c67x00: Replace tasklet with work 2021-01-26 18:36:37 +01:00
cdns3 usb: cdnsp: Fix issue with CV Bad Descriptor test 2025-07-17 18:30:51 +02:00
chipidea usb: chipidea: add USB PHY event 2025-08-28 16:24:05 +02:00
class usb: cdc-wdm: avoid setting WDM_READ for ZLP-s 2025-07-10 15:57:34 +02:00
common usb: common: usb-conn-gpio: use a unique name for usb connector device 2025-07-10 15:57:33 +02:00
core usb: hub: Fix flushing of delayed work used for post resume purposes 2025-08-28 16:24:02 +02:00
dwc2 usb: dwc2: also exit clock_gating when stopping udc while suspended 2025-07-10 15:57:33 +02:00
dwc3 usb: dwc3: qcom: Don't leave BCR asserted 2025-08-28 16:24:02 +02:00
early usb: early: xhci-dbc: Fix early_ioremap leak 2025-08-28 16:24:06 +02:00
gadget usb: gadget : fix use-after-free in composite_dev_cleanup() 2025-08-28 16:24:14 +02:00
host xhci: Disable stream for xHC controller with XHCI_BROKEN_STREAMS 2025-07-17 18:30:51 +02:00
image USB: microtek: use set_host_byte() 2020-09-16 12:42:10 +02:00
isp1760 usb: isp1760: Fix out-of-bounds array access 2022-06-09 10:22:27 +02:00
misc usb: misc: apple-mfi-fastcharge: Make power supply names unique 2025-08-28 16:24:06 +02:00
mon usb: mon: Fix atomicity violation in mon_bin_vma_fault 2024-01-25 14:52:47 -08:00
mtu3 usb: mtu3: fix kernel panic at qmu transfer done irq handler 2023-05-11 23:00:33 +09:00
musb usb: musb: fix gadget state on disconnect 2025-08-28 16:24:02 +02:00
phy usb: phy: mxs: disconnect line when USB charger is attached 2025-08-28 16:24:05 +02:00
renesas_usbhs usb: renesas_usbhs: Reorder clock handling and power management in probe 2025-06-27 11:05:16 +01:00
roles usb: roles: set switch registered flag early on 2025-03-13 12:50:37 +01:00
serial USB: serial: option: add Foxconn T99W709 2025-08-28 16:24:14 +02:00
storage usb: storage: Ignore UAS driver for SanDisk 3.2 Gen2 storage device 2025-06-27 11:05:09 +01:00
typec usb: typec: tcpm: apply vbus before data bringup in tcpm_src_attach 2025-08-28 16:24:05 +02:00
usbip usbip: Don't submit special requests twice 2024-09-12 11:07:41 +02:00
Kconfig usb: remove reference to deleted config STB03xxx 2021-08-18 15:32:19 +02:00
Makefile usb: host: remove line for obsolete config USB_HWA_HCD 2021-08-18 15:32:19 +02:00
usb-skeleton.c USB: usb-skeleton: drop redundant in-urb check 2019-10-10 12:41:19 +02:00