WSL2-Linux-Kernel/drivers/media/usb
Duoming Zhou 784a8027b8 media: usb: siano: Fix warning due to null work_func_t function pointer
[ Upstream commit 6f489a966f ]

The previous commit ebad8e731c ("media: usb: siano: Fix use after
free bugs caused by do_submit_urb") adds cancel_work_sync() in
smsusb_stop_streaming(). But smsusb_stop_streaming() may be called,
even if the work_struct surb->wq has not been initialized. As a result,
the warning will occur. One of the processes that could lead to warning
is shown below:

smsusb_probe()
  smsusb_init_device()
    if (!dev->in_ep || !dev->out_ep || align < 0) {
         smsusb_term_device(intf);
           smsusb_stop_streaming()
             cancel_work_sync(&dev->surbs[i].wq);
               __cancel_work_timer()
                 __flush_work()
                   if (WARN_ON(!work->func)) // work->func is null

The log reported by syzbot is shown below:

WARNING: CPU: 0 PID: 897 at kernel/workqueue.c:3066 __flush_work+0x798/0xa80 kernel/workqueue.c:3063
Modules linked in:
CPU: 0 PID: 897 Comm: kworker/0:2 Not tainted 6.2.0-rc1-syzkaller #0
RIP: 0010:__flush_work+0x798/0xa80 kernel/workqueue.c:3066
...
RSP: 0018:ffffc9000464ebf8 EFLAGS: 00010246
RAX: 1ffff11002dbb420 RBX: 0000000000000021 RCX: 1ffffffff204fa4e
RDX: dffffc0000000000 RSI: 0000000000000001 RDI: ffff888016dda0e8
RBP: ffffc9000464ed98 R08: 0000000000000001 R09: ffffffff90253b2f
R10: 0000000000000001 R11: 0000000000000000 R12: ffff888016dda0e8
R13: ffff888016dda0e8 R14: ffff888016dda100 R15: 0000000000000001
FS:  0000000000000000(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffd4331efe8 CR3: 000000000b48e000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 __cancel_work_timer+0x315/0x460 kernel/workqueue.c:3160
 smsusb_stop_streaming drivers/media/usb/siano/smsusb.c:182 [inline]
 smsusb_term_device+0xda/0x2d0 drivers/media/usb/siano/smsusb.c:344
 smsusb_init_device+0x400/0x9ce drivers/media/usb/siano/smsusb.c:419
 smsusb_probe+0xbbd/0xc55 drivers/media/usb/siano/smsusb.c:567
...

This patch adds check before cancel_work_sync(). If surb->wq has not
been initialized, the cancel_work_sync() will not be executed.

Reported-by: syzbot+27b0b464864741b18b99@syzkaller.appspotmail.com
Fixes: ebad8e731c ("media: usb: siano: Fix use after free bugs caused by do_submit_urb")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-07-23 13:47:21 +02:00
..
airspy
as102
au0828 media: au0828: fix a NULL vs IS_ERR() check 2021-06-02 13:30:28 +02:00
b2c2 media: flexcop-usb: fix endpoint type check 2022-09-28 11:11:42 +02:00
cpia2 media: cpia2: fix control-message timeouts 2022-01-27 11:02:55 +01:00
cx231xx
dvb-usb media: dvb-usb: dw2102: fix uninit-value in su3000_read_mac_address 2023-06-09 10:32:23 +02:00
dvb-usb-v2 media: usb: Check az6007_read() return value 2023-07-23 13:47:21 +02:00
em28xx media: Revert "media: em28xx: add missing em28xx_close_extension" 2022-04-08 14:24:02 +02:00
go7007 media: usb: go7007: s2250-board: fix leak in probe() 2022-04-08 14:23:17 +02:00
gspca media: drivers/media/usb/gspca: fix typo Fliker -> Flicker 2021-07-12 09:16:33 +02:00
hackrf
hdpvr media: hdpvr: fix error value returns in hdpvr_read 2022-08-17 14:23:23 +02:00
msi2500
pvrusb2 media: pvrusb2: fix memory leak in pvr_probe 2022-09-05 10:30:07 +02:00
pwc
s2255 media: s2255: fix control-message timeouts 2022-01-27 11:02:55 +01:00
siano media: usb: siano: Fix warning due to null work_func_t function pointer 2023-07-23 13:47:21 +02:00
stk1160 media: stk1160: If start stream fails, return buffers with VB2_BUF_STATE_QUEUED 2022-04-08 14:23:20 +02:00
stkwebcam media: stkwebcam: fix memory leak in stk_camera_probe 2021-07-22 14:01:55 +02:00
tm6000 media: tm6000: Avoid card name truncation 2021-11-18 19:16:29 +01:00
ttusb-budget
ttusb-dec media: ttusb-dec: fix memory leak in ttusb_dec_exit_dvb() 2023-06-09 10:32:24 +02:00
usbtv
uvc media: uvcvideo: Don't expose unsupported formats to userspace 2023-06-09 10:32:27 +02:00
zr364xx media: zr364xx: fix memory leak in zr364xx_start_readpipe 2021-06-02 13:35:15 +02:00
Kconfig
Makefile