Hello,
syzbot found the following issue on:
HEAD commit: 9abbc24128bc Merge branch 'for-next/core' into for-kernelci
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=12073622180000
kernel config: https://syzkaller.appspot.com/x/.config?x=af5c6c699e57bbb3
dashboard link: https://syzkaller.appspot.com/bug?extid=2622b51b35f91a00ea18
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=132173d2180000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10d7ec54180000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/ce13ec3ed5ad/disk-9abbc241.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/256cbd314121/vmlinux-9abbc241.xz
kernel image: https://storage.googleapis.com/syzbot-assets/0af86fb52109/Image-9abbc241.gz.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]
INFO: task kworker/0:1:10 blocked for more than 143 seconds.
Tainted: G B 6.8.0-rc5-syzkaller-g9abbc24128bc #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kworker/0:1 state:D stack:0 pid:10 tgid:10 ppid:2 flags:0x00000008
Workqueue: usb_hub_wq hub_event
Call trace:
__switch_to+0x314/0x560 arch/arm64/kernel/process.c:553
context_switch kernel/sched/core.c:5400 [inline]
__schedule+0x1498/0x24b4 kernel/sched/core.c:6727
__schedule_loop kernel/sched/core.c:6802 [inline]
schedule+0xb8/0x19c kernel/sched/core.c:6817
schedule_preempt_disabled+0x18/0x2c kernel/sched/core.c:6874
__mutex_lock_common+0xbd8/0x21a0 kernel/locking/mutex.c:684
__mutex_lock kernel/locking/mutex.c:752 [inline]
mutex_lock_nested+0x2c/0x38 kernel/locking/mutex.c:804
vb2_video_unregister_device+0x11c/0x1dc drivers/media/common/videobuf2/videobuf2-v4l2.c:1269
usbtv_video_free+0x4c/0x84 drivers/media/usb/usbtv/usbtv-video.c:970
usbtv_disconnect+0x6c/0xc4 drivers/media/usb/usbtv/usbtv-core.c:138
usb_unbind_interface+0x1a4/0x758 drivers/usb/core/driver.c:461
device_remove drivers/base/dd.c:569 [inline]
__device_release_driver drivers/base/dd.c:1272 [inline]
device_release_driver_internal+0x440/0x6a0 drivers/base/dd.c:1295
device_release_driver+0x28/0x38 drivers/base/dd.c:1318
bus_remove_device+0x314/0x3b4 drivers/base/bus.c:574
device_del+0x480/0x87c drivers/base/core.c:3828
usb_disable_device+0x354/0x760 drivers/usb/core/message.c:1416
usb_disconnect+0x290/0x808 drivers/usb/core/hub.c:2267
hub_port_connect drivers/usb/core/hub.c:5323 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5623 [inline]
port_event drivers/usb/core/hub.c:5783 [inline]
hub_event+0x18ec/0x435c drivers/usb/core/hub.c:5865
process_one_work+0x694/0x1204 kernel/workqueue.c:2633
process_scheduled_works kernel/workqueue.c:2706 [inline]
worker_thread+0x970/0xef4 kernel/workqueue.c:2787
kthread+0x288/0x310 kernel/kthread.c:388
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860
INFO: lockdep is turned off.
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at [email protected].
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
diff --git a/drivers/media/common/videobuf2/videobuf2-v4l2.c b/drivers/media/common/videobuf2/videobuf2-v4l2.c
index c575198e8354..437f80551a2d 100644
--- a/drivers/media/common/videobuf2/videobuf2-v4l2.c
+++ b/drivers/media/common/videobuf2/videobuf2-v4l2.c
@@ -1262,8 +1262,7 @@ void vb2_video_unregister_device(struct video_device *vdev)
get_device(&vdev->dev);
video_unregister_device(vdev);
if (vdev->queue) {
- struct mutex *lock = vdev->queue->lock ?
- vdev->queue->lock : vdev->lock;
+ struct mutex *lock = vdev->queue->lock;
if (lock)
mutex_lock(lock);
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
possible deadlock in vb2_video_unregister_device
usb 1-1: config 0 descriptor??
usbtv 1-1:0.0: Fushicai USBTV007 Audio-Video Grabber
usb 1-1: USB disconnect, device number 2
============================================
WARNING: possible recursive locking detected
6.8.0-rc6-syzkaller-g805d849d7c3c-dirty #0 Not tainted
--------------------------------------------
kworker/0:4/6186 is trying to acquire lock:
ffff0000cd544b90 (&usbtv->vb2q_lock){+.+.}-{3:3}, at: vb2_video_unregister_device+0xe8/0x1ac drivers/media/common/videobuf2/videobuf2-v4l2.c:1268
but task is already holding lock:
ffff0000cd544b90 (&usbtv->vb2q_lock){+.+.}-{3:3}, at: usbtv_video_free+0x2c/0x84 drivers/media/usb/usbtv/usbtv-video.c:966
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(&usbtv->vb2q_lock);
lock(&usbtv->vb2q_lock);
*** DEADLOCK ***
May be due to missing lock nesting notation
7 locks held by kworker/0:4/6186:
#0: ffff0000c252f138 ((wq_completion)usb_hub_wq){+.+.}-{0:0}, at: process_one_work+0x560/0x1204 kernel/workqueue.c:2606
#1: ffff800097b77c20 ((work_completion)(&hub->events)){+.+.}-{0:0}, at: process_one_work+0x5a0/0x1204 kernel/workqueue.c:2608
#2: ffff0000ccf38190 (&dev->mutex){....}-{3:3}, at: device_lock include/linux/device.h:990 [inline]
#2: ffff0000ccf38190 (&dev->mutex){....}-{3:3}, at: hub_event+0x1b4/0x435c drivers/usb/core/hub.c:5811
#3: ffff0000c73fb190 (&dev->mutex){....}-{3:3}, at: device_lock include/linux/device.h:990 [inline]
#3: ffff0000c73fb190 (&dev->mutex){....}-{3:3}, at: usb_disconnect+0xec/0x808 drivers/usb/core/hub.c:2258
#4: ffff0000d811b160 (&dev->mutex){....}-{3:3}, at: device_lock include/linux/device.h:990 [inline]
#4: ffff0000d811b160 (&dev->mutex){....}-{3:3}, at: __device_driver_lock drivers/base/dd.c:1095 [inline]
#4: ffff0000d811b160 (&dev->mutex){....}-{3:3}, at: device_release_driver_internal+0xbc/0x6a0 drivers/base/dd.c:1292
#5: ffff0000cd544b90 (&usbtv->vb2q_lock){+.+.}-{3:3}, at: usbtv_video_free+0x2c/0x84 drivers/media/usb/usbtv/usbtv-video.c:966
#6: ffff0000cd544b00 (&usbtv->v4l2_lock){+.+.}-{3:3}, at: usbtv_video_free+0x3c/0x84 drivers/media/usb/usbtv/usbtv-video.c:967
stack backtrace:
CPU: 0 PID: 6186 Comm: kworker/0:4 Not tainted 6.8.0-rc6-syzkaller-g805d849d7c3c-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
Workqueue: usb_hub_wq hub_event
Call trace:
dump_backtrace+0x1b8/0x1e4 arch/arm64/kernel/stacktrace.c:291
show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:298
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd0/0x124 lib/dump_stack.c:106
dump_stack+0x1c/0x28 lib/dump_stack.c:113
print_deadlock_bug+0x4e4/0x660 kernel/locking/lockdep.c:3012
check_deadlock kernel/locking/lockdep.c:3062 [inline]
validate_chain kernel/locking/lockdep.c:3856 [inline]
__lock_acquire+0x5fe4/0x763c kernel/locking/lockdep.c:5137
lock_acquire+0x23c/0x71c kernel/locking/lockdep.c:5754
__mutex_lock_common+0x190/0x21a0 kernel/locking/mutex.c:608
__mutex_lock kernel/locking/mutex.c:752 [inline]
mutex_lock_nested+0x2c/0x38 kernel/locking/mutex.c:804
vb2_video_unregister_device+0xe8/0x1ac drivers/media/common/videobuf2/videobuf2-v4l2.c:1268
usbtv_video_free+0x4c/0x84 drivers/media/usb/usbtv/usbtv-video.c:970
usbtv_disconnect+0x6c/0xc4 drivers/media/usb/usbtv/usbtv-core.c:138
usb_unbind_interface+0x1a4/0x758 drivers/usb/core/driver.c:461
device_remove drivers/base/dd.c:569 [inline]
__device_release_driver drivers/base/dd.c:1272 [inline]
device_release_driver_internal+0x440/0x6a0 drivers/base/dd.c:1295
device_release_driver+0x28/0x38 drivers/base/dd.c:1318
bus_remove_device+0x314/0x3b4 drivers/base/bus.c:574
device_del+0x480/0x87c drivers/base/core.c:3828
usb_disable_device+0x354/0x760 drivers/usb/core/message.c:1416
usb_disconnect+0x290/0x808 drivers/usb/core/hub.c:2267
hub_port_connect drivers/usb/core/hub.c:5323 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5623 [inline]
port_event drivers/usb/core/hub.c:5783 [inline]
hub_event+0x18ec/0x435c drivers/usb/core/hub.c:5865
process_one_work+0x694/0x1204 kernel/workqueue.c:2633
process_scheduled_works kernel/workqueue.c:2706 [inline]
worker_thread+0x970/0xef4 kernel/workqueue.c:2787
kthread+0x288/0x310 kernel/kthread.c:388
ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860
Tested on:
commit: 805d849d Merge tag 'acpi-6.8-rc7' of git://git.kernel...
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=12b53522180000
kernel config: https://syzkaller.appspot.com/x/.config?x=e412105d06db24c2
dashboard link: https://syzkaller.appspot.com/bug?extid=2622b51b35f91a00ea18
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64
patch: https://syzkaller.appspot.com/x/patch.diff?x=17181132180000
please test task hung in vb2_video_unregister_device
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
index 62a583040cd4..b55f432b44d4 100644
--- a/drivers/media/usb/usbtv/usbtv-video.c
+++ b/drivers/media/usb/usbtv/usbtv-video.c
@@ -963,7 +963,6 @@ int usbtv_video_init(struct usbtv *usbtv)
void usbtv_video_free(struct usbtv *usbtv)
{
- mutex_lock(&usbtv->vb2q_lock);
mutex_lock(&usbtv->v4l2_lock);
usbtv_stop(usbtv);
@@ -971,7 +970,6 @@ void usbtv_video_free(struct usbtv *usbtv)
v4l2_device_disconnect(&usbtv->v4l2_dev);
mutex_unlock(&usbtv->v4l2_lock);
- mutex_unlock(&usbtv->vb2q_lock);
v4l2_device_put(&usbtv->v4l2_dev);
}
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-and-tested-by: [email protected]
Tested on:
commit: 805d849d Merge tag 'acpi-6.8-rc7' of git://git.kernel...
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=126f27f6180000
kernel config: https://syzkaller.appspot.com/x/.config?x=e412105d06db24c2
dashboard link: https://syzkaller.appspot.com/bug?extid=2622b51b35f91a00ea18
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64
patch: https://syzkaller.appspot.com/x/patch.diff?x=1429a7aa180000
Note: testing is done by a robot and is best-effort only.
vb2_video_unregister_device() will get vb2q_lock, so usbtv_video_free() does
not need vb2q_lock.
Reported-and-tested-by: [email protected]
Signed-off-by: Edward Adam Davis <[email protected]>
---
drivers/media/usb/usbtv/usbtv-video.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
index 62a583040cd4..b55f432b44d4 100644
--- a/drivers/media/usb/usbtv/usbtv-video.c
+++ b/drivers/media/usb/usbtv/usbtv-video.c
@@ -963,7 +963,6 @@ int usbtv_video_init(struct usbtv *usbtv)
void usbtv_video_free(struct usbtv *usbtv)
{
- mutex_lock(&usbtv->vb2q_lock);
mutex_lock(&usbtv->v4l2_lock);
usbtv_stop(usbtv);
@@ -971,7 +970,6 @@ void usbtv_video_free(struct usbtv *usbtv)
v4l2_device_disconnect(&usbtv->v4l2_dev);
mutex_unlock(&usbtv->v4l2_lock);
- mutex_unlock(&usbtv->vb2q_lock);
v4l2_device_put(&usbtv->v4l2_dev);
}
--
2.43.0
On 2/29/24 13:21, Edward Adam Davis wrote:
> vb2_video_unregister_device() will get vb2q_lock, so usbtv_video_free() does
> not need vb2q_lock.
>
> Reported-and-tested-by: [email protected]
> Signed-off-by: Edward Adam Davis <[email protected]>
Duplicate of:
https://lore.kernel.org/linux-media/[email protected]/
I'm waiting for a v2 of that one.
Regards,
Hans
> ---
> drivers/media/usb/usbtv/usbtv-video.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c
> index 62a583040cd4..b55f432b44d4 100644
> --- a/drivers/media/usb/usbtv/usbtv-video.c
> +++ b/drivers/media/usb/usbtv/usbtv-video.c
> @@ -963,7 +963,6 @@ int usbtv_video_init(struct usbtv *usbtv)
>
> void usbtv_video_free(struct usbtv *usbtv)
> {
> - mutex_lock(&usbtv->vb2q_lock);
> mutex_lock(&usbtv->v4l2_lock);
>
> usbtv_stop(usbtv);
> @@ -971,7 +970,6 @@ void usbtv_video_free(struct usbtv *usbtv)
> v4l2_device_disconnect(&usbtv->v4l2_dev);
>
> mutex_unlock(&usbtv->v4l2_lock);
> - mutex_unlock(&usbtv->vb2q_lock);
>
> v4l2_device_put(&usbtv->v4l2_dev);
> }