syzbot


possible deadlock in uinput_request_submit

Status: upstream: reported C repro on 2024/05/05 13:53
Bug presence: origin:upstream
[Documentation on labels]
Reported-by: syzbot+51d6626c6b035ff47f4f@syzkaller.appspotmail.com
First crash: 200d, last: 3d11h
Bug presence (1)
Date Name Commit Repro Result
2024/05/07 upstream (ToT) dccb07f2914c C [report] possible deadlock in uinput_request_submit
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in uinput_request_submit origin:upstream C error 2 84d 200d 0/3 upstream: reported C repro on 2024/05/05 13:52
android-49 possible deadlock in uinput_request_submit C 5 1938d 2048d 0/3 public: reported C repro on 2019/04/14 09:33
upstream possible deadlock in uinput_request_submit input C error 21 4d13h 209d 0/28 upstream: reported C repro on 2024/04/26 04:42
Fix bisection attempts (5)
Created Duration User Patch Repo Result
2024/11/18 07:06 1h31m bisect fix linux-5.15.y OK (0) job log log
2024/10/14 06:06 2h10m bisect fix linux-5.15.y OK (0) job log log
2024/08/27 00:19 1h11m bisect fix linux-5.15.y OK (0) job log log
2024/07/17 10:39 2h43m bisect fix linux-5.15.y OK (0) job log log
2024/06/05 21:17 1h22m bisect fix linux-5.15.y OK (0) job log log

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

but task is already holding lock:
ffff88807d5cd8b0 (&ff->mutex){+.+.}-{3:3}, at: input_ff_upload+0x3a5/0xa00 drivers/input/ff-core.c:123

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&ff->mutex){+.+.}-{3:3}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       __mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_nested+0x17/0x20 kernel/locking/mutex.c:743
       input_ff_flush+0x5a/0x130 drivers/input/ff-core.c:243
       input_flush_device+0x94/0xc0 drivers/input/input.c:672
       evdev_release+0xf5/0x7c0 drivers/input/evdev.c:444
       __fput+0x3bf/0x890 fs/file_table.c:280
       task_work_run+0x129/0x1a0 kernel/task_work.c:164
       tracehook_notify_resume include/linux/tracehook.h:189 [inline]
       exit_to_user_mode_loop+0x106/0x130 kernel/entry/common.c:181
       exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:214
       __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline]
       syscall_exit_to_user_mode+0x5d/0x240 kernel/entry/common.c:307
       do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:86
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #2 (&dev->mutex#2){+.+.}-{3:3}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       __mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_interruptible_nested+0x17/0x20 kernel/locking/mutex.c:765
       input_register_handle+0x69/0x3a0 drivers/input/input.c:2513
       kbd_connect+0xbb/0x120 drivers/tty/vt/keyboard.c:1577
       input_attach_handler drivers/input/input.c:1046 [inline]
       input_register_device+0xdae/0x1150 drivers/input/input.c:2354
       acpi_button_add+0x62d/0x9f0 drivers/acpi/button.c:568
       acpi_device_probe+0xa3/0x2f0 drivers/acpi/bus.c:1005
       really_probe+0x24e/0xb60 drivers/base/dd.c:595
       __driver_probe_device+0x1a2/0x3d0 drivers/base/dd.c:755
       driver_probe_device+0x50/0x420 drivers/base/dd.c:785
       __driver_attach+0x479/0x690 drivers/base/dd.c:1164
       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:240
       do_one_initcall+0x22b/0x7a0 init/main.c:1302
       do_initcall_level+0x157/0x210 init/main.c:1375
       do_initcalls+0x49/0x90 init/main.c:1391
       kernel_init_freeable+0x425/0x5c0 init/main.c:1615
       kernel_init+0x19/0x290 init/main.c:1506
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:300

-> #1 (input_mutex){+.+.}-{3:3}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       __mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_interruptible_nested+0x17/0x20 kernel/locking/mutex.c:765
       input_register_device+0xb81/0x1150 drivers/input/input.c:2347
       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:874 [inline]
       __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #0 (&newdev->mutex){+.+.}-{3:3}:
       check_prev_add kernel/locking/lockdep.c:3053 [inline]
       check_prevs_add kernel/locking/lockdep.c:3172 [inline]
       validate_chain+0x1649/0x5930 kernel/locking/lockdep.c:3788
       __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       __mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
       __mutex_lock kernel/locking/mutex.c:729 [inline]
       mutex_lock_interruptible_nested+0x17/0x20 kernel/locking/mutex.c:765
       uinput_request_send drivers/input/misc/uinput.c:150 [inline]
       uinput_request_submit+0x19a/0x730 drivers/input/misc/uinput.c:181
       uinput_dev_upload_effect+0x195/0x230 drivers/input/misc/uinput.c:256
       input_ff_upload+0x59c/0xa00 drivers/input/ff-core.c:153
       evdev_do_ioctl drivers/input/evdev.c:1183 [inline]
       evdev_ioctl_handler+0x178b/0x2090 drivers/input/evdev.c:1272
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:874 [inline]
       __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

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-executor233/3500:
 #0: ffff888078cfa110 (&evdev->mutex){+.+.}-{3:3}, at: evdev_ioctl_handler+0x124/0x2090 drivers/input/evdev.c:1263
 #1: ffff88807d5cd8b0 (&ff->mutex){+.+.}-{3:3}, at: input_ff_upload+0x3a5/0xa00 drivers/input/ff-core.c:123

stack backtrace:
CPU: 0 PID: 3500 Comm: syz-executor233 Not tainted 5.15.158-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/0x2d0 lib/dump_stack.c:106
 check_noncircular+0x2f8/0x3b0 kernel/locking/lockdep.c:2133
 check_prev_add kernel/locking/lockdep.c:3053 [inline]
 check_prevs_add kernel/locking/lockdep.c:3172 [inline]
 validate_chain+0x1649/0x5930 kernel/locking/lockdep.c:3788
 __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
 lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
 __mutex_lock_common+0x1da/0x25a0 kernel/locking/mutex.c:596
 __mutex_lock kernel/locking/mutex.c:729 [inline]
 mutex_lock_interruptible_nested+0x17/0x20 kernel/locking/mutex.c:765
 uinput_request_send drivers/input/misc/uinput.c:150 [inline]
 uinput_request_submit+0x19a/0x730 drivers/input/misc/uinput.c:181
 uinput_dev_upload_effect+0x195/0x230 drivers/input/misc/uinput.c:256
 input_ff_upload+0x59c/0xa00 drivers/input/ff-core.c:153
 evdev_do_ioctl drivers/input/evdev.c:1183 [inline]
 evdev_ioctl_handler+0x178b/0x2090 drivers/input/evdev.c:1272
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:874 [inline]
 __se_sys_ioctl+0xf1/0x160 fs/ioctl.c:860
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f8499890979
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 c1 17 00 00 90 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:00007ffc1c1a74b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f8499890979
RDX: 0000000020000300 RSI: 0000000040304580 RDI: 0000000000000004
RBP: 00007f84999035f0 R08: 0000000000000006 R09: 0000000000000006
R10: 000000000000001f R11: 0000000000000246 R12: 0000000000000001
R13: 431bde82d7b634db 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 15:11 linux-5.15.y 284087d4f7d5 610f2a54 .config console log report syz C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in uinput_request_submit
2024/05/05 13:53 linux-5.15.y 284087d4f7d5 610f2a54 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in uinput_request_submit
* Struck through repros no longer work on HEAD.