WSL2-Linux-Kernel/drivers
Alan Stern 2191c00855 USB: gadget: Fix use-after-free Read in usb_udc_uevent()
The syzbot fuzzer found a race between uevent callbacks and gadget
driver unregistration that can cause a use-after-free bug:

---------------------------------------------------------------
BUG: KASAN: use-after-free in usb_udc_uevent+0x11f/0x130
drivers/usb/gadget/udc/core.c:1732
Read of size 8 at addr ffff888078ce2050 by task udevd/2968

CPU: 1 PID: 2968 Comm: udevd Not tainted 5.19.0-rc4-next-20220628-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google
06/29/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:317 [inline]
 print_report.cold+0x2ba/0x719 mm/kasan/report.c:433
 kasan_report+0xbe/0x1f0 mm/kasan/report.c:495
 usb_udc_uevent+0x11f/0x130 drivers/usb/gadget/udc/core.c:1732
 dev_uevent+0x290/0x770 drivers/base/core.c:2424
---------------------------------------------------------------

The bug occurs because usb_udc_uevent() dereferences udc->driver but
does so without acquiring the udc_lock mutex, which protects this
field.  If the gadget driver is unbound from the udc concurrently with
uevent processing, the driver structure may be accessed after it has
been deallocated.

To prevent the race, we make sure that the routine holds the mutex
around the racing accesses.

Link: <https://lore.kernel.org/all/0000000000004de90405a719c951@google.com>
CC: stable@vger.kernel.org # fc274c1e99
Reported-and-tested-by: syzbot+b0de012ceb1e2a97891b@syzkaller.appspotmail.com
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Link: https://lore.kernel.org/r/YtlrnhHyrHsSky9m@rowland.harvard.edu
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-27 14:31:37 +02:00
..
accessibility
acpi platform-drivers-x86 for v5.19-4 2022-07-15 10:12:22 -07:00
amba
android
ata
atm
auxdisplay
base
bcma
block
bluetooth
bus
cdrom
char random: cap jitter samples per bit to factor of HZ 2022-07-16 10:42:12 -07:00
clk
clocksource
comedi
connector
counter
cpufreq cpufreq arm fixes for 5.19-rc6 2022-07-15 13:54:14 +02:00
cpuidle
crypto
cxl
dax
dca
devfreq
dio
dma
dma-buf
edac
eisa
extcon
firewire
firmware platform-drivers-x86 for v5.19-4 2022-07-15 10:12:22 -07:00
fpga
fsi
gnss
gpio
gpu - Fix 32b build 2022-07-17 13:08:03 -07:00
greybus
hid
hsi
hte
hv
hwmon
hwspinlock
hwtracing
i2c
i3c
idle
iio
infiniband
input Input updates for v5.19-rc6 2022-07-17 07:52:46 -07:00
interconnect
iommu
ipack
irqchip
isdn
leds
macintosh
mailbox
mcb
md
media
memory
memstick
message
mfd
misc
mmc
most
mtd
mux
net
nfc
ntb
nubus
nvdimm
nvme
nvmem
of
opp
parisc
parport
pci
pcmcia
peci
perf
phy
pinctrl
platform Revert "platform/chrome: cros_typec_switch: Add switch driver" 2022-07-19 13:59:54 +02:00
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc
s390 s390 updates for 5.19-rc7 2022-07-16 11:00:40 -07:00
sbus
scsi
sh
siox
slimbus
soc
soundwire
spi
spmi
ssb
staging staging: gdm724x: drop unused CDC defines 2022-07-25 10:57:42 +02:00
target
tc
tee
thermal
thunderbolt
tty TTY / Serial driver fixes for 5.19-rc7 2022-07-16 11:11:56 -07:00
ufs
uio
usb USB: gadget: Fix use-after-free Read in usb_udc_uevent() 2022-07-27 14:31:37 +02:00
vdpa
vfio
vhost
video
virt
virtio
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile