All of lore.kernel.org
 help / color / mirror / Atom feed
* [syzbot] [media?] possible deadlock in v4l2_ctrl_handler_log_status
@ 2024-02-08  9:17 syzbot
  2024-02-09  8:11 ` Hillf Danton
  2024-02-09 13:58 ` syzbot
  0 siblings, 2 replies; 4+ messages in thread
From: syzbot @ 2024-02-08  9:17 UTC (permalink / raw)
  To: linux-kernel, linux-media, mchehab, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    b1d3a0e70c38 Add linux-next specific files for 20240208
git tree:       linux-next
console+strace: https://syzkaller.appspot.com/x/log.txt?x=105d3360180000
kernel config:  https://syzkaller.appspot.com/x/.config?x=bb693ba195662a06
dashboard link: https://syzkaller.appspot.com/bug?extid=9948f8e188482c5d1a3e
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=148953c4180000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1746f9b7e80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/176a6b395bbe/disk-b1d3a0e7.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/02d7d46f81bd/vmlinux-b1d3a0e7.xz
kernel image: https://storage.googleapis.com/syzbot-assets/18a5a5030e19/bzImage-b1d3a0e7.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+9948f8e188482c5d1a3e@syzkaller.appspotmail.com

vivid-000: =================  START STATUS  =================
vivid-000: Boolean: 
======================================================
WARNING: possible circular locking dependency detected
6.8.0-rc3-next-20240208-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor190/5068 is trying to acquire lock:
ffff8880253306e0 (vivid_ctrls:1606:(hdl_user_gen)->_lock){+.+.}-{3:3}, at: v4l2_ctrl_lock include/media/v4l2-ctrls.h:572 [inline]
ffff8880253306e0 (vivid_ctrls:1606:(hdl_user_gen)->_lock){+.+.}-{3:3}, at: log_ctrl drivers/media/v4l2-core/v4l2-ctrls-core.c:2518 [inline]
ffff8880253306e0 (vivid_ctrls:1606:(hdl_user_gen)->_lock){+.+.}-{3:3}, at: v4l2_ctrl_handler_log_status+0x2f3/0x540 drivers/media/v4l2-core/v4l2-ctrls-core.c:2556

but task is already holding lock:
ffff888025334278 (vivid_ctrls:1634:(hdl_sdr_cap)->_lock){+.+.}-{3:3}, at: v4l2_ctrl_handler_log_status+0x11f/0x540 drivers/media/v4l2-core/v4l2-ctrls-core.c:2551

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (vivid_ctrls:1634:(hdl_sdr_cap)->_lock){+.+.}-{3:3}:
       lock_acquire+0x1e4/0x530 kernel/locking/lockdep.c:5754
       __mutex_lock_common kernel/locking/mutex.c:608 [inline]
       __mutex_lock+0x136/0xd70 kernel/locking/mutex.c:752
       find_ref_lock+0x5b/0x470 drivers/media/v4l2-core/v4l2-ctrls-core.c:1647
       handler_new_ref+0x102/0x940 drivers/media/v4l2-core/v4l2-ctrls-core.c:1684
       v4l2_ctrl_add_handler+0x1a1/0x290 drivers/media/v4l2-core/v4l2-ctrls-core.c:2208
       vivid_create_controls+0x2b3c/0x3580 drivers/media/test-drivers/vivid/vivid-ctrls.c:1981
       vivid_create_instance drivers/media/test-drivers/vivid/vivid-core.c:1854 [inline]
       vivid_probe+0x4289/0x6fa0 drivers/media/test-drivers/vivid/vivid-core.c:2018
       platform_probe+0x13a/0x1c0 drivers/base/platform.c:1404
       really_probe+0x29e/0xc50 drivers/base/dd.c:658
       __driver_probe_device+0x1a2/0x3e0 drivers/base/dd.c:800
       driver_probe_device+0x50/0x430 drivers/base/dd.c:830
       __driver_attach+0x45f/0x710 drivers/base/dd.c:1216
       bus_for_each_dev+0x239/0x2b0 drivers/base/bus.c:368
       bus_add_driver+0x347/0x620 drivers/base/bus.c:673
       driver_register+0x23a/0x320 drivers/base/driver.c:246
       vivid_init+0x3d/0x70 drivers/media/test-drivers/vivid/vivid-core.c:2145
       do_one_initcall+0x238/0x830 init/main.c:1233
       do_initcall_level+0x157/0x210 init/main.c:1295
       do_initcalls+0x3f/0x80 init/main.c:1311
       kernel_init_freeable+0x430/0x5d0 init/main.c:1542
       kernel_init+0x1d/0x2b0 init/main.c:1432
       ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:242

-> #0 (vivid_ctrls:1606:(hdl_user_gen)->_lock){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3134 [inline]
       check_prevs_add kernel/locking/lockdep.c:3253 [inline]
       validate_chain+0x18cb/0x58e0 kernel/locking/lockdep.c:3869
       __lock_acquire+0x1346/0x1fd0 kernel/locking/lockdep.c:5137
       lock_acquire+0x1e4/0x530 kernel/locking/lockdep.c:5754
       __mutex_lock_common kernel/locking/mutex.c:608 [inline]
       __mutex_lock+0x136/0xd70 kernel/locking/mutex.c:752
       v4l2_ctrl_lock include/media/v4l2-ctrls.h:572 [inline]
       log_ctrl drivers/media/v4l2-core/v4l2-ctrls-core.c:2518 [inline]
       v4l2_ctrl_handler_log_status+0x2f3/0x540 drivers/media/v4l2-core/v4l2-ctrls-core.c:2556
       v4l2_ctrl_log_status+0xe3/0x100 drivers/media/v4l2-core/v4l2-ctrls-api.c:1206
       vidioc_log_status+0x63/0x110 drivers/media/test-drivers/vivid/vivid-core.c:426
       v4l_log_status+0x8f/0x110 drivers/media/v4l2-core/v4l2-ioctl.c:2562
       __video_do_ioctl+0xc26/0xde0 drivers/media/v4l2-core/v4l2-ioctl.c:3049
       video_usercopy+0x899/0x1180 drivers/media/v4l2-core/v4l2-ioctl.c:3390
       v4l2_ioctl+0x18c/0x1e0 drivers/media/v4l2-core/v4l2-dev.c:364
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:871 [inline]
       __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:857
       do_syscall_64+0xfb/0x240
       entry_SYSCALL_64_after_hwframe+0x6d/0x75

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(vivid_ctrls:1634:(hdl_sdr_cap)->_lock);
                               lock(vivid_ctrls:1606:(hdl_user_gen)->_lock);
                               lock(vivid_ctrls:1634:(hdl_sdr_cap)->_lock);
  lock(vivid_ctrls:1606:(hdl_user_gen)->_lock);

 *** DEADLOCK ***

2 locks held by syz-executor190/5068:
 #0: ffff888025335a58 (&dev->mutex#3){+.+.}-{3:3}, at: __video_do_ioctl+0x4ed/0xde0 drivers/media/v4l2-core/v4l2-ioctl.c:3017
 #1: ffff888025334278 (vivid_ctrls:1634:(hdl_sdr_cap)->_lock){+.+.}-{3:3}, at: v4l2_ctrl_handler_log_status+0x11f/0x540 drivers/media/v4l2-core/v4l2-ctrls-core.c:2551

stack backtrace:
CPU: 0 PID: 5068 Comm: syz-executor190 Not tainted 6.8.0-rc3-next-20240208-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:114
 check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2187
 check_prev_add kernel/locking/lockdep.c:3134 [inline]
 check_prevs_add kernel/locking/lockdep.c:3253 [inline]
 validate_chain+0x18cb/0x58e0 kernel/locking/lockdep.c:3869
 __lock_acquire+0x1346/0x1fd0 kernel/locking/lockdep.c:5137
 lock_acquire+0x1e4/0x530 kernel/locking/lockdep.c:5754
 __mutex_lock_common kernel/locking/mutex.c:608 [inline]
 __mutex_lock+0x136/0xd70 kernel/locking/mutex.c:752
 v4l2_ctrl_lock include/media/v4l2-ctrls.h:572 [inline]
 log_ctrl drivers/media/v4l2-core/v4l2-ctrls-core.c:2518 [inline]
 v4l2_ctrl_handler_log_status+0x2f3/0x540 drivers/media/v4l2-core/v4l2-ctrls-core.c:2556
 v4l2_ctrl_log_status+0xe3/0x100 drivers/media/v4l2-core/v4l2-ctrls-api.c:1206
 vidioc_log_status+0x63/0x110 drivers/media/test-drivers/vivid/vivid-core.c:426
 v4l_log_status+0x8f/0x110 drivers/media/v4l2-core/v4l2-ioctl.c:2562
 __video_do_ioctl+0xc26/0xde0 drivers/media/v4l2-core/v4l2-ioctl.c:3049
 video_usercopy+0x899/0x1180 drivers/media/v4l2-core/v4l2-ioctl.c:3390
 v4l2_ioctl+0x18c/0x1e0 drivers/media/v4l2-core/v4l2-dev.c:364
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:871 [inline]
 __se_sys_ioctl+0xfc/0x170 fs/ioctl.c:857
 do_syscall_64+0xfb/0x240
 entry_SYSCALL_64_after_hwframe+0x6d/0x75
RIP: 0033:0x7fc7060250e9
Code: 48 83 c4 28 c3 e8 37 17 00 00 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff130f5498 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fff130f5668 RCX: 00007fc7060250e9
RDX: 0000000000000000 RSI: 0000000000005646 RDI: 0000000000000003
RBP: 00007fc706098610 R08: 00236f6964617277 R09: 00007fff130f5668
R10: 000000000000000f R11: 0000000000000246 R12: 0000000000000001
R13: 00007fff130f5658 R14: 0000000000000001 R15: 0000000000000001
 </TASK>
true
vivid-000: Integer 32 Bits: 0
vivid-000: Integer 64 Bits: 0
vivid-000: Menu: Menu Item 3
vivid-000: String:   
vivid-000: Bitmask: 0x80002000
vivid-000: Integer Menu: 5
vivid-000: U32 1 Element Array: [1] 24
vivid-000: U16 8x16 Matrix: [8][16] 24
vivid-000: U8 2x3x4x5 Array: [2][3][4][5] 24
vivid-000: Area: unknown type 262
vivid-000: Read-Only Integer 32 Bits: 0
vivid-000: U32 Dynamic Array: [100] 50
vivid-000: U8 Pixel Array: [640][368] 128
vivid-000: S32 2 Element Array: [2] 2
vivid-000: S64 5 Element Array: [5] 4
vivid-000: Wrap Sequence Number: false
vivid-000: Wrap Timestamp: None
vivid-000: Percentage of Dropped Buffers: 0
vivid-000: FM Deviation: 75000
vivid-000: ==================  END STATUS  ========


---
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 syzkaller@googlegroups.com.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [syzbot] [media?] possible deadlock in v4l2_ctrl_handler_log_status
  2024-02-08  9:17 [syzbot] [media?] possible deadlock in v4l2_ctrl_handler_log_status syzbot
@ 2024-02-09  8:11 ` Hillf Danton
  2024-02-09  8:34   ` syzbot
  2024-02-09 13:58 ` syzbot
  1 sibling, 1 reply; 4+ messages in thread
From: Hillf Danton @ 2024-02-09  8:11 UTC (permalink / raw)
  To: syzbot; +Cc: linux-kernel, syzkaller-bugs

On Thu, 08 Feb 2024 01:17:28 -0800
> HEAD commit:    b1d3a0e70c38 Add linux-next specific files for 20240208
> git tree:       linux-next
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1746f9b7e80000

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git  master

--- x/drivers/media/v4l2-core/v4l2-ctrls-core.c
+++ y/drivers/media/v4l2-core/v4l2-ctrls-core.c
@@ -2550,7 +2550,7 @@ void v4l2_ctrl_handler_log_status(struct
 		colon = ": ";
 	mutex_lock(hdl->lock);
 	list_for_each_entry(ref, &hdl->ctrl_refs, node) {
-		if (ref->from_other_dev ||
+		if (ref->from_other_dev || ref->ctrl->handler != hdl ||
 		    (ref->ctrl->flags & V4L2_CTRL_FLAG_DISABLED))
 			continue;
 		log_ctrl(hdl, ref->ctrl, prefix, colon);
--

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [syzbot] [media?] possible deadlock in v4l2_ctrl_handler_log_status
  2024-02-09  8:11 ` Hillf Danton
@ 2024-02-09  8:34   ` syzbot
  0 siblings, 0 replies; 4+ messages in thread
From: syzbot @ 2024-02-09  8:34 UTC (permalink / raw)
  To: hdanton, linux-kernel, syzkaller-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+9948f8e188482c5d1a3e@syzkaller.appspotmail.com

Tested on:

commit:         445a555e Add linux-next specific files for 20240209
git tree:       https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=1613d304180000
kernel config:  https://syzkaller.appspot.com/x/.config?x=85aa3388229f9ea9
dashboard link: https://syzkaller.appspot.com/bug?extid=9948f8e188482c5d1a3e
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch:          https://syzkaller.appspot.com/x/patch.diff?x=11aee120180000

Note: testing is done by a robot and is best-effort only.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [syzbot] [media?] possible deadlock in v4l2_ctrl_handler_log_status
  2024-02-08  9:17 [syzbot] [media?] possible deadlock in v4l2_ctrl_handler_log_status syzbot
  2024-02-09  8:11 ` Hillf Danton
@ 2024-02-09 13:58 ` syzbot
  1 sibling, 0 replies; 4+ messages in thread
From: syzbot @ 2024-02-09 13:58 UTC (permalink / raw)
  To: benjamin.gaignard, daniel.almeida, hdanton, hverkuil-cisco,
	linux-kernel, linux-media, mchehab, nicolas.dufresne,
	syzkaller-bugs

syzbot has bisected this issue to:

commit 9801b5b28c6929139d6fceeee8d739cc67bb2739
Author: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Date:   Wed Jan 17 14:52:04 2024 +0000

    media: v4l2-ctrls: show all owned controls in log_status

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=1278acec180000
start commit:   b1d3a0e70c38 Add linux-next specific files for 20240208
git tree:       linux-next
final oops:     https://syzkaller.appspot.com/x/report.txt?x=1178acec180000
console output: https://syzkaller.appspot.com/x/log.txt?x=1678acec180000
kernel config:  https://syzkaller.appspot.com/x/.config?x=bb693ba195662a06
dashboard link: https://syzkaller.appspot.com/bug?extid=9948f8e188482c5d1a3e
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=148953c4180000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1746f9b7e80000

Reported-by: syzbot+9948f8e188482c5d1a3e@syzkaller.appspotmail.com
Fixes: 9801b5b28c69 ("media: v4l2-ctrls: show all owned controls in log_status")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-09 13:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-08  9:17 [syzbot] [media?] possible deadlock in v4l2_ctrl_handler_log_status syzbot
2024-02-09  8:11 ` Hillf Danton
2024-02-09  8:34   ` syzbot
2024-02-09 13:58 ` syzbot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.