syzbot


possible deadlock in uinput_request_submit

Status: upstream: reported C repro on 2024/05/05 13:52
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+2f445fb32f2350d20dee@syzkaller.appspotmail.com
First crash: 50d, last: 19d
Bug presence (1)
Date Name Commit Repro Result
2024/05/05 upstream (ToT) dd5a440a31fa C [report] possible deadlock in uinput_request_submit
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-49 possible deadlock in uinput_request_submit C 5 1788d 1898d 0/3 public: reported C repro on 2019/04/14 09:33
upstream possible deadlock in uinput_request_submit input C error 19 12d 59d 0/27 upstream: reported C repro on 2024/04/26 04:42
linux-5.15 possible deadlock in uinput_request_submit origin:upstream C 2 18d 50d 0/3 upstream: reported C repro on 2024/05/05 13:53
Fix bisection attempts (1)
Created Duration User Patch Repo Result
2024/06/05 19:47 1h26m bisect fix linux-6.1.y job log (0) log

Sample crash report:
input: syz1 as /devices/virtual/input/input5
======================================================
WARNING: possible circular locking dependency detected
6.1.90-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor159/3541 is trying to acquire lock:
ffff8880765b4070 (&newdev->mutex){+.+.}-{3:3}, at: uinput_request_send drivers/input/misc/uinput.c:150 [inline]
ffff8880765b4070 (&newdev->mutex){+.+.}-{3:3}, at: uinput_request_submit+0x198/0x730 drivers/input/misc/uinput.c:181

but task is already holding lock:
ffff8880765b48b0 (&ff->mutex){+.+.}-{3:3}, at: input_ff_upload+0x3e0/0xae0 drivers/input/ff-core.c:120

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&ff->mutex){+.+.}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
       input_ff_flush+0x5a/0x130 drivers/input/ff-core.c:240
       input_flush_device+0x94/0xc0 drivers/input/input.c:682
       evdev_release+0xf5/0x7c0 drivers/input/evdev.c:444
       __fput+0x3b7/0x890 fs/file_table.c:320
       task_work_run+0x246/0x300 kernel/task_work.c:179
       resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
       exit_to_user_mode_loop+0xde/0x100 kernel/entry/common.c:177
       exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:210
       __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline]
       syscall_exit_to_user_mode+0x60/0x270 kernel/entry/common.c:303
       do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #2 (&dev->mutex#2){+.+.}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
       input_register_handle+0x69/0x3a0 drivers/input/input.c:2555
       kbd_connect+0xbb/0x120 drivers/tty/vt/keyboard.c:1589
       input_attach_handler drivers/input/input.c:1060 [inline]
       input_register_device+0xcec/0x1080 drivers/input/input.c:2396
       acpi_button_add+0x62a/0x9f0 drivers/acpi/button.c:559
       acpi_device_probe+0xa0/0x2f0 drivers/acpi/bus.c:1023
       really_probe+0x2ab/0xcb0 drivers/base/dd.c:639
       __driver_probe_device+0x1a2/0x3d0 drivers/base/dd.c:785
       driver_probe_device+0x50/0x420 drivers/base/dd.c:815
       __driver_attach+0x458/0x6f0 drivers/base/dd.c:1201
       bus_for_each_dev+0x17c/0x1f0 drivers/base/bus.c:301
       bus_add_driver+0x334/0x600 drivers/base/bus.c:618
       driver_register+0x2bf/0x3a0 drivers/base/driver.c:246
       do_one_initcall+0x265/0x8f0 init/main.c:1299
       do_initcall_level+0x157/0x207 init/main.c:1372
       do_initcalls+0x49/0x86 init/main.c:1388
       kernel_init_freeable+0x45c/0x60f init/main.c:1627
       kernel_init+0x19/0x290 init/main.c:1515
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308

-> #1 (input_mutex){+.+.}-{3:3}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
       input_register_device+0xadd/0x1080 drivers/input/input.c:2389
       uinput_create_device+0x40e/0x620 drivers/input/misc/uinput.c:364
       uinput_ioctl_handler+0xa83/0x16d0 drivers/input/misc/uinput.c:870
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:870 [inline]
       __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:856
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #0 (&newdev->mutex){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __mutex_lock_common kernel/locking/mutex.c:603 [inline]
       __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
       uinput_request_send drivers/input/misc/uinput.c:150 [inline]
       uinput_request_submit+0x198/0x730 drivers/input/misc/uinput.c:181
       uinput_dev_upload_effect+0x195/0x230 drivers/input/misc/uinput.c:256
       input_ff_upload+0x5d7/0xae0 drivers/input/ff-core.c:150
       evdev_do_ioctl drivers/input/evdev.c:1183 [inline]
       evdev_ioctl_handler+0x16ee/0x2170 drivers/input/evdev.c:1272
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:870 [inline]
       __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:856
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

other info that might help us debug this:

Chain exists of:
  &newdev->mutex --> &dev->mutex#2 --> &ff->mutex

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ff->mutex);
                               lock(&dev->mutex#2);
                               lock(&ff->mutex);
  lock(&newdev->mutex);

 *** DEADLOCK ***

2 locks held by syz-executor159/3541:
 #0: ffff888021534110 (&evdev->mutex){+.+.}-{3:3}, at: evdev_ioctl_handler+0x124/0x2170 drivers/input/evdev.c:1263
 #1: ffff8880765b48b0 (&ff->mutex){+.+.}-{3:3}, at: input_ff_upload+0x3e0/0xae0 drivers/input/ff-core.c:120

stack backtrace:
CPU: 0 PID: 3541 Comm: syz-executor159 Not tainted 6.1.90-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2fa/0x3b0 kernel/locking/lockdep.c:2170
 check_prev_add kernel/locking/lockdep.c:3090 [inline]
 check_prevs_add kernel/locking/lockdep.c:3209 [inline]
 validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
 __mutex_lock_common kernel/locking/mutex.c:603 [inline]
 __mutex_lock+0x132/0xd80 kernel/locking/mutex.c:747
 uinput_request_send drivers/input/misc/uinput.c:150 [inline]
 uinput_request_submit+0x198/0x730 drivers/input/misc/uinput.c:181
 uinput_dev_upload_effect+0x195/0x230 drivers/input/misc/uinput.c:256
 input_ff_upload+0x5d7/0xae0 drivers/input/ff-core.c:150
 evdev_do_ioctl drivers/input/evdev.c:1183 [inline]
 evdev_ioctl_handler+0x16ee/0x2170 drivers/input/evdev.c:1272
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:870 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:856
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f78a76eb269
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:00007ffd827d23d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007ffd827d25a8 RCX: 00007f78a76eb269
RDX: 0000000020000300 RSI: 0000000040304580 RDI: 0000000000000004
RBP: 00007f78a775e610 R08: 0000000000000000 R09: 00007ffd827d25a8
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00007ffd827d2598 R14: 0000000000000001 R15: 0000000000000001
 </TASK>

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/05/05 14:06 linux-6.1.y 909ba1f1b414 610f2a54 .config console log report syz C [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in uinput_request_submit
2024/05/05 13:51 linux-6.1.y 909ba1f1b414 610f2a54 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in uinput_request_submit
* Struck through repros no longer work on HEAD.