syzbot


possible deadlock in kvm_arch_pm_notifier

Status: upstream: reported on 2025/01/06 17:13
Subsystems: kvm
[Documentation on labels]
Reported-by: syzbot+352e553a86e0d75f5120@syzkaller.appspotmail.com
First crash: 6d04h, last: 6d04h
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [kvm?] possible deadlock in kvm_arch_pm_notifier 1 (2) 2025/01/07 15:18

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.13.0-rc5-syzkaller-00012-g0bc21e701a6f #0 Not tainted
------------------------------------------------------
syz.8.2149/14842 is trying to acquire lock:
ffffc90006bccb58 (&kvm->lock){+.+.}-{4:4}, at: kvm_arch_suspend_notifier arch/x86/kvm/x86.c:6919 [inline]
ffffc90006bccb58 (&kvm->lock){+.+.}-{4:4}, at: kvm_arch_pm_notifier+0xf5/0x2b0 arch/x86/kvm/x86.c:6941

but task is already holding lock:
ffffffff8dcbeb10 ((pm_chain_head).rwsem){++++}-{4:4}, at: blocking_notifier_call_chain_robust kernel/notifier.c:344 [inline]
ffffffff8dcbeb10 ((pm_chain_head).rwsem){++++}-{4:4}, at: blocking_notifier_call_chain_robust+0xa9/0x170 kernel/notifier.c:333

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #4 ((pm_chain_head).rwsem){++++}-{4:4}:
       down_write+0x93/0x200 kernel/locking/rwsem.c:1577
       __blocking_notifier_chain_register kernel/notifier.c:263 [inline]
       blocking_notifier_chain_register+0x69/0xd0 kernel/notifier.c:282
       hci_register_suspend_notifier+0xcb/0x100 net/bluetooth/hci_core.c:2769
       hci_register_dev+0x616/0xc60 net/bluetooth/hci_core.c:2652
       hci_uart_register_dev drivers/bluetooth/hci_ldisc.c:686 [inline]
       hci_uart_set_proto drivers/bluetooth/hci_ldisc.c:710 [inline]
       hci_uart_tty_ioctl+0x7d0/0xc10 drivers/bluetooth/hci_ldisc.c:762
       tty_compat_ioctl+0x381/0x4d0 drivers/tty/tty_io.c:2991
       __do_compat_sys_ioctl+0x1cb/0x2c0 fs/ioctl.c:1004
       do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
       __do_fast_syscall_32+0x73/0x120 arch/x86/entry/common.c:386
       do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411
       entry_SYSENTER_compat_after_hwframe+0x84/0x8e

-> #3 (&tty->ldisc_sem){++++}-{0:0}:
       __ldsem_down_read_nested+0xbe/0x920 drivers/tty/tty_ldsem.c:300
       tty_ldisc_ref_wait+0x24/0x80 drivers/tty/tty_ldisc.c:243
       tty_poll+0x94/0x1d0 drivers/tty/tty_io.c:2204
       vfs_poll include/linux/poll.h:84 [inline]
       io_file_supports_nowait io_uring/rw.c:43 [inline]
       io_file_supports_nowait+0x200/0x290 io_uring/rw.c:34
       __io_read+0xbd2/0x1190 io_uring/rw.c:855
       io_read+0x1e/0x70 io_uring/rw.c:947
       io_issue_sqe+0x175/0x1360 io_uring/io_uring.c:1740
       io_queue_sqe io_uring/io_uring.c:1950 [inline]
       io_submit_sqe io_uring/io_uring.c:2205 [inline]
       io_submit_sqes+0x951/0x25f0 io_uring/io_uring.c:2322
       __do_sys_io_uring_enter+0xd43/0x1620 io_uring/io_uring.c:3395
       do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
       __do_fast_syscall_32+0x73/0x120 arch/x86/entry/common.c:386
       do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411
       entry_SYSENTER_compat_after_hwframe+0x84/0x8e

-> #2 (&ctx->uring_lock){+.+.}-{4:4}:
       __mutex_lock_common kernel/locking/mutex.c:585 [inline]
       __mutex_lock+0x19b/0xa60 kernel/locking/mutex.c:735
       io_handle_tw_list+0x27c/0x540 io_uring/io_uring.c:1054
       tctx_task_work_run+0xac/0x390 io_uring/io_uring.c:1121
       tctx_task_work+0x7b/0xd0 io_uring/io_uring.c:1139
       task_work_run+0x14e/0x250 kernel/task_work.c:239
       resume_user_mode_work include/linux/resume_user_mode.h:50 [inline]
       xfer_to_guest_mode_work kernel/entry/kvm.c:20 [inline]
       xfer_to_guest_mode_handle_work+0xbe/0xf0 kernel/entry/kvm.c:47
       vcpu_run+0x1393/0x4c00 arch/x86/kvm/x86.c:11267
       kvm_arch_vcpu_ioctl_run+0x44a/0x1740 arch/x86/kvm/x86.c:11560
       kvm_vcpu_ioctl+0x6ce/0x1520 virt/kvm/kvm_main.c:4340
       kvm_vcpu_compat_ioctl+0x210/0x3f0 virt/kvm/kvm_main.c:4555
       __do_compat_sys_ioctl+0x1cb/0x2c0 fs/ioctl.c:1004
       do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
       __do_fast_syscall_32+0x73/0x120 arch/x86/entry/common.c:386
       do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411
       entry_SYSENTER_compat_after_hwframe+0x84/0x8e

-> #1 (&vcpu->mutex){+.+.}-{4:4}:
       __mutex_lock_common kernel/locking/mutex.c:585 [inline]
       __mutex_lock+0x19b/0xa60 kernel/locking/mutex.c:735
       kvm_vm_ioctl_create_vcpu virt/kvm/kvm_main.c:4121 [inline]
       kvm_vm_ioctl+0x1043/0x3df0 virt/kvm/kvm_main.c:5019
       kvm_vm_compat_ioctl+0x399/0x440 virt/kvm/kvm_main.c:5321
       __do_compat_sys_ioctl+0x1cb/0x2c0 fs/ioctl.c:1004
       do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
       __do_fast_syscall_32+0x73/0x120 arch/x86/entry/common.c:386
       do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411
       entry_SYSENTER_compat_after_hwframe+0x84/0x8e

-> #0 (&kvm->lock){+.+.}-{4:4}:
       check_prev_add kernel/locking/lockdep.c:3161 [inline]
       check_prevs_add kernel/locking/lockdep.c:3280 [inline]
       validate_chain kernel/locking/lockdep.c:3904 [inline]
       __lock_acquire+0x249e/0x3c40 kernel/locking/lockdep.c:5226
       lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5849
       __mutex_lock_common kernel/locking/mutex.c:585 [inline]
       __mutex_lock+0x19b/0xa60 kernel/locking/mutex.c:735
       kvm_arch_suspend_notifier arch/x86/kvm/x86.c:6919 [inline]
       kvm_arch_pm_notifier+0xf5/0x2b0 arch/x86/kvm/x86.c:6941
       notifier_call_chain+0xb7/0x410 kernel/notifier.c:85
       notifier_call_chain_robust kernel/notifier.c:120 [inline]
       blocking_notifier_call_chain_robust kernel/notifier.c:345 [inline]
       blocking_notifier_call_chain_robust+0xc9/0x170 kernel/notifier.c:333
       pm_notifier_call_chain_robust+0x27/0x60 kernel/power/main.c:102
       snapshot_open+0x189/0x2b0 kernel/power/user.c:77
       misc_open+0x35a/0x420 drivers/char/misc.c:165
       chrdev_open+0x237/0x6a0 fs/char_dev.c:414
       do_dentry_open+0xf59/0x1ea0 fs/open.c:945
       vfs_open+0x82/0x3f0 fs/open.c:1075
       do_open fs/namei.c:3828 [inline]
       path_openat+0x1e6a/0x2d60 fs/namei.c:3987
       do_filp_open+0x20c/0x470 fs/namei.c:4014
       do_sys_openat2+0x17a/0x1e0 fs/open.c:1402
       do_sys_open fs/open.c:1417 [inline]
       __do_compat_sys_openat fs/open.c:1479 [inline]
       __se_compat_sys_openat fs/open.c:1477 [inline]
       __ia32_compat_sys_openat+0x16e/0x210 fs/open.c:1477
       do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
       __do_fast_syscall_32+0x73/0x120 arch/x86/entry/common.c:386
       do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411
       entry_SYSENTER_compat_after_hwframe+0x84/0x8e

other info that might help us debug this:

Chain exists of:
  &kvm->lock --> &tty->ldisc_sem --> (pm_chain_head).rwsem

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock((pm_chain_head).rwsem);
                               lock(&tty->ldisc_sem);
                               lock((pm_chain_head).rwsem);
  lock(&kvm->lock);

 *** DEADLOCK ***

3 locks held by syz.8.2149/14842:
 #0: ffffffff8eaa1cc8 (misc_mtx){+.+.}-{4:4}, at: misc_open+0x63/0x420 drivers/char/misc.c:129
 #1: ffffffff8dc80d08 (system_transition_mutex){+.+.}-{4:4}, at: lock_system_sleep+0x87/0xa0 kernel/power/main.c:56
 #2: ffffffff8dcbeb10 ((pm_chain_head).rwsem){++++}-{4:4}, at: blocking_notifier_call_chain_robust kernel/notifier.c:344 [inline]
 #2: ffffffff8dcbeb10 ((pm_chain_head).rwsem){++++}-{4:4}, at: blocking_notifier_call_chain_robust+0xa9/0x170 kernel/notifier.c:333

stack backtrace:
CPU: 0 UID: 0 PID: 14842 Comm: syz.8.2149 Not tainted 6.13.0-rc5-syzkaller-00012-g0bc21e701a6f #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
 print_circular_bug+0x41c/0x610 kernel/locking/lockdep.c:2074
 check_noncircular+0x31a/0x400 kernel/locking/lockdep.c:2206
 check_prev_add kernel/locking/lockdep.c:3161 [inline]
 check_prevs_add kernel/locking/lockdep.c:3280 [inline]
 validate_chain kernel/locking/lockdep.c:3904 [inline]
 __lock_acquire+0x249e/0x3c40 kernel/locking/lockdep.c:5226
 lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5849
 __mutex_lock_common kernel/locking/mutex.c:585 [inline]
 __mutex_lock+0x19b/0xa60 kernel/locking/mutex.c:735
 kvm_arch_suspend_notifier arch/x86/kvm/x86.c:6919 [inline]
 kvm_arch_pm_notifier+0xf5/0x2b0 arch/x86/kvm/x86.c:6941
 notifier_call_chain+0xb7/0x410 kernel/notifier.c:85
 notifier_call_chain_robust kernel/notifier.c:120 [inline]
 blocking_notifier_call_chain_robust kernel/notifier.c:345 [inline]
 blocking_notifier_call_chain_robust+0xc9/0x170 kernel/notifier.c:333
 pm_notifier_call_chain_robust+0x27/0x60 kernel/power/main.c:102
 snapshot_open+0x189/0x2b0 kernel/power/user.c:77
 misc_open+0x35a/0x420 drivers/char/misc.c:165
 chrdev_open+0x237/0x6a0 fs/char_dev.c:414
 do_dentry_open+0xf59/0x1ea0 fs/open.c:945
 vfs_open+0x82/0x3f0 fs/open.c:1075
 do_open fs/namei.c:3828 [inline]
 path_openat+0x1e6a/0x2d60 fs/namei.c:3987
 do_filp_open+0x20c/0x470 fs/namei.c:4014
 do_sys_openat2+0x17a/0x1e0 fs/open.c:1402
 do_sys_open fs/open.c:1417 [inline]
 __do_compat_sys_openat fs/open.c:1479 [inline]
 __se_compat_sys_openat fs/open.c:1477 [inline]
 __ia32_compat_sys_openat+0x16e/0x210 fs/open.c:1477
 do_syscall_32_irqs_on arch/x86/entry/common.c:165 [inline]
 __do_fast_syscall_32+0x73/0x120 arch/x86/entry/common.c:386
 do_fast_syscall_32+0x32/0x80 arch/x86/entry/common.c:411
 entry_SYSENTER_compat_after_hwframe+0x84/0x8e
RIP: 0023:0xf715e579
Code: b8 01 10 06 03 74 b4 01 10 07 03 74 b0 01 10 08 03 74 d8 01 00 00 00 00 00 00 00 00 00 00 00 00 00 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d b4 26 00 00 00 00 8d b4 26 00 00 00 00
RSP: 002b:00000000f512f55c EFLAGS: 00000296 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 00000000ffffff9c RCX: 0000000020000000
RDX: 0000000000040000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000296 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>
----------------
Code disassembly (best guess), 2 bytes skipped:
   0:	10 06                	adc    %al,(%rsi)
   2:	03 74 b4 01          	add    0x1(%rsp,%rsi,4),%esi
   6:	10 07                	adc    %al,(%rdi)
   8:	03 74 b0 01          	add    0x1(%rax,%rsi,4),%esi
   c:	10 08                	adc    %cl,(%rax)
   e:	03 74 d8 01          	add    0x1(%rax,%rbx,8),%esi
  1e:	00 51 52             	add    %dl,0x52(%rcx)
  21:	55                   	push   %rbp
  22:	89 e5                	mov    %esp,%ebp
  24:	0f 34                	sysenter
  26:	cd 80                	int    $0x80
* 28:	5d                   	pop    %rbp <-- trapping instruction
  29:	5a                   	pop    %rdx
  2a:	59                   	pop    %rcx
  2b:	c3                   	ret
  2c:	90                   	nop
  2d:	90                   	nop
  2e:	90                   	nop
  2f:	90                   	nop
  30:	8d b4 26 00 00 00 00 	lea    0x0(%rsi,%riz,1),%esi
  37:	8d b4 26 00 00 00 00 	lea    0x0(%rsi,%riz,1),%esi

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/01/03 07:24 upstream 0bc21e701a6f d3ccff63 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in kvm_arch_pm_notifier
* Struck through repros no longer work on HEAD.