possible deadlock in mtrr_add_page

Status: auto-obsoleted due to no activity on 2026/11/29 13:15
Subsystems: kernel
Labels: prio:low
[Documentation on labels]
First crash: 94d, last: 94d
▶ ▼ ✨ AI Jobs (3)
ID Workflow Result Correct Bug Created Started Finished Revision
f9b826d8 repro-c 💥 possible deadlock in mtrr_add_page 2026/09/26 17:14 2026/09/26 17:14 2026/09/26 18:59 a3c7249d
d0a6fdc6 repro-c 💥 possible deadlock in mtrr_add_page 2026/09/24 20:28 2026/09/24 20:28 2026/09/24 23:51 3c3cdf19
f615c9e2 assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ possible deadlock in mtrr_add_page 2026/09/02 00:00 2026/09/02 00:00 2026/09/02 00:41 587f6b29

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Tainted: G             L     
------------------------------------------------------
syz.6.6809/29738 is trying to acquire lock:
ffffffff8ec0ac60 (mtrr_mutex){+.+.}-{4:4}, at: mtrr_add_page+0x1ef/0xc00 arch/x86/kernel/cpu/mtrr/mtrr.c:261

but task is already holding lock:
ffffffff8ec7ca50 (cpu_hotplug_lock){++++}-{0:0}, at: mtrr_add_page+0x1e1/0xc00 arch/x86/kernel/cpu/mtrr/mtrr.c:258

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #8 (cpu_hotplug_lock){++++}-{0:0}:
       lock_acquire kernel/locking/lockdep.c:5908 [inline]
       lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5865
       percpu_down_read_internal include/linux/percpu-rwsem.h:53 [inline]
       percpu_down_read include/linux/percpu-rwsem.h:77 [inline]
       cpus_read_lock+0x42/0x170 kernel/cpu.c:490
       static_key_disable+0x12/0x20 kernel/jump_label.c:247
       __inet_hash_connect+0x143e/0x2000 net/ipv4/inet_hashtables.c:1081
       tcp_v4_connect+0xeb3/0x1b40 net/ipv4/tcp_ipv4.c:306
       __inet_stream_connect+0x208/0xf90 net/ipv4/af_inet.c:684
       inet_stream_connect+0x57/0xa0 net/ipv4/af_inet.c:755
       connect_socket net/socket.c:2141 [inline]
       connect_socket net/socket.c:2131 [inline]
       __sys_connect_file+0x146/0x1a0 net/socket.c:2166
       __sys_connect+0x141/0x170 net/socket.c:2183
       __do_sys_connect net/socket.c:2189 [inline]
       __se_sys_connect net/socket.c:2186 [inline]
       __x64_sys_connect+0x72/0xb0 net/socket.c:2186
       do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
       do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #7 (sk_lock-AF_INET){+.+.}-{0:0}:
       lock_acquire kernel/locking/lockdep.c:5908 [inline]
       lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5865
       lock_sock_nested+0x41/0xf0 net/core/sock.c:3827
       lock_sock include/net/sock.h:1713 [inline]
       inet_shutdown+0x67/0x410 net/ipv4/af_inet.c:913
       nbd_mark_nsock_dead+0xae/0x5c0 drivers/block/nbd.c:319
       recv_work+0x5fb/0x8c0 drivers/block/nbd.c:1030
       process_one_work+0xac7/0x1b10 kernel/workqueue.c:3387
       process_scheduled_works kernel/workqueue.c:3470 [inline]
       worker_thread+0x5ef/0xe50 kernel/workqueue.c:3551
       kthread+0x373/0x450 kernel/kthread.c:436
       ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

-> #6 (&nsock->tx_lock){+.+.}-{4:4}:
       lock_acquire kernel/locking/lockdep.c:5908 [inline]
       lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5865
       __mutex_lock_common kernel/locking/mutex.c:646 [inline]
       __mutex_lock+0x1a4/0x1bd0 kernel/locking/mutex.c:821
       nbd_handle_cmd drivers/block/nbd.c:1143 [inline]
       nbd_queue_rq+0x42d/0xfa0 drivers/block/nbd.c:1207
       blk_mq_dispatch_rq_list+0x428/0x1e60 block/blk-mq.c:2117
       __blk_mq_do_dispatch_sched block/blk-mq-sched.c:168 [inline]
       blk_mq_do_dispatch_sched block/blk-mq-sched.c:182 [inline]
       __blk_mq_sched_dispatch_requests+0xcea/0x1620 block/blk-mq-sched.c:307
       blk_mq_sched_dispatch_requests+0xd7/0x1c0 block/blk-mq-sched.c:329
       blk_mq_run_work_fn+0x135/0x380 block/blk-mq.c:2531
       process_one_work+0xac7/0x1b10 kernel/workqueue.c:3387
       process_scheduled_works kernel/workqueue.c:3470 [inline]
       worker_thread+0x5ef/0xe50 kernel/workqueue.c:3551
       kthread+0x373/0x450 kernel/kthread.c:436
       ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

-> #5 (&cmd->lock){+.+.}-{4:4}:
       lock_acquire kernel/locking/lockdep.c:5908 [inline]
       lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5865
       __mutex_lock_common kernel/locking/mutex.c:646 [inline]
       __mutex_lock+0x1a4/0x1bd0 kernel/locking/mutex.c:821
       nbd_queue_rq+0xba/0xfa0 drivers/block/nbd.c:1199
       blk_mq_dispatch_rq_list+0x428/0x1e60 block/blk-mq.c:2117
       __blk_mq_do_dispatch_sched block/blk-mq-sched.c:168 [inline]
       blk_mq_do_dispatch_sched block/blk-mq-sched.c:182 [inline]
       __blk_mq_sched_dispatch_requests+0xcea/0x1620 block/blk-mq-sched.c:307
       blk_mq_sched_dispatch_requests+0xd7/0x1c0 block/blk-mq-sched.c:329
       blk_mq_run_work_fn+0x135/0x380 block/blk-mq.c:2531
       process_one_work+0xac7/0x1b10 kernel/workqueue.c:3387
       process_scheduled_works kernel/workqueue.c:3470 [inline]
       worker_thread+0x5ef/0xe50 kernel/workqueue.c:3551
       kthread+0x373/0x450 kernel/kthread.c:436
       ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

-> #4 (set->srcu){.+.+}-{0:0}:
       lock_sync kernel/locking/lockdep.c:5957 [inline]
       lock_sync+0xb5/0x120 kernel/locking/lockdep.c:5945
       srcu_lock_sync include/linux/srcu.h:210 [inline]
       __synchronize_srcu+0xa2/0x300 kernel/rcu/srcutree.c:1462
       blk_mq_wait_quiesce_done block/blk-mq.c:284 [inline]
       blk_mq_wait_quiesce_done block/blk-mq.c:281 [inline]
       blk_mq_quiesce_queue block/blk-mq.c:304 [inline]
       blk_mq_quiesce_queue+0x149/0x1c0 block/blk-mq.c:299
       elevator_switch+0x17b/0x7e0 block/elevator.c:576
       elevator_change+0x352/0x530 block/elevator.c:681
       elevator_set_default+0x29e/0x360 block/elevator.c:754
       blk_register_queue+0x48e/0x630 block/blk-sysfs.c:992
       __add_disk+0x73f/0xe40 block/genhd.c:524
       add_disk_fwnode+0x118/0x480 block/genhd.c:593
       add_disk include/linux/blkdev.h:798 [inline]
       nbd_dev_add+0x779/0xb10 drivers/block/nbd.c:2026
       nbd_init+0x2c5/0x2e0 drivers/block/nbd.c:2743
       do_one_initcall+0x11c/0x6f0 init/main.c:1357
       do_initcall_level init/main.c:1419 [inline]
       do_initcalls init/main.c:1435 [inline]
       do_basic_setup init/main.c:1455 [inline]
       kernel_init_freeable+0x6ea/0x7b0 init/main.c:1670
       kernel_init+0x21/0x1e0 init/main.c:1560
       ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

-> #3 (&q->elevator_lock){+.+.}-{4:4}:
       lock_acquire kernel/locking/lockdep.c:5908 [inline]
       lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5865
       __mutex_lock_common kernel/locking/mutex.c:646 [inline]
       __mutex_lock+0x1a4/0x1bd0 kernel/locking/mutex.c:821
       elevator_change+0x1bc/0x530 block/elevator.c:679
       elevator_set_none+0x92/0xf0 block/elevator.c:769
       blk_mq_elv_switch_none block/blk-mq.c:5102 [inline]
       __blk_mq_update_nr_hw_queues block/blk-mq.c:5147 [inline]
       blk_mq_update_nr_hw_queues+0x4c1/0x15f0 block/blk-mq.c:5212
       nbd_start_device+0x1a6/0xbd0 drivers/block/nbd.c:1530
       nbd_genl_connect+0xfc2/0x1760 drivers/block/nbd.c:2310
       genl_family_rcv_msg_doit+0x214/0x300 net/netlink/genetlink.c:1114
       genl_family_rcv_msg net/netlink/genetlink.c:1194 [inline]
       genl_rcv_msg+0x560/0x800 net/netlink/genetlink.c:1209
       netlink_rcv_skb+0x159/0x420 net/netlink/af_netlink.c:2556
       genl_rcv+0x28/0x40 net/netlink/genetlink.c:1218
       netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
       netlink_unicast+0x585/0x850 net/netlink/af_netlink.c:1345
       netlink_sendmsg+0x8b0/0xda0 net/netlink/af_netlink.c:1900
       sock_sendmsg_nosec net/socket.c:800 [inline]
       __sock_sendmsg net/socket.c:815 [inline]
       ____sys_sendmsg+0xa4d/0xbe0 net/socket.c:2713
       ___sys_sendmsg+0x190/0x1e0 net/socket.c:2767
       __sys_sendmsg+0x160/0x210 net/socket.c:2799
       do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
       do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #2 (&q->q_usage_counter(io)#49){++++}-{0:0}:
       lock_acquire kernel/locking/lockdep.c:5908 [inline]
       lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5865
       blk_alloc_queue+0x610/0x790 block/blk-core.c:504
       blk_mq_alloc_queue+0x174/0x290 block/blk-mq.c:4420
       __blk_mq_alloc_disk+0x29/0x120 block/blk-mq.c:4467
       nbd_dev_add+0x491/0xb10 drivers/block/nbd.c:1996
       nbd_init+0x2c5/0x2e0 drivers/block/nbd.c:2743
       do_one_initcall+0x11c/0x6f0 init/main.c:1357
       do_initcall_level init/main.c:1419 [inline]
       do_initcalls init/main.c:1435 [inline]
       do_basic_setup init/main.c:1455 [inline]
       kernel_init_freeable+0x6ea/0x7b0 init/main.c:1670
       kernel_init+0x21/0x1e0 init/main.c:1560
       ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

-> #1 (fs_reclaim){+.+.}-{0:0}:
       lock_acquire kernel/locking/lockdep.c:5908 [inline]
       lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5865
       __fs_reclaim_acquire mm/page_alloc.c:4375 [inline]
       fs_reclaim_acquire+0xc4/0x100 mm/page_alloc.c:4389
       might_alloc include/linux/sched/mm.h:316 [inline]
       slab_pre_alloc_hook mm/slub.c:4636 [inline]
       slab_alloc_node mm/slub.c:4974 [inline]
       __do_kmalloc_node mm/slub.c:5413 [inline]
       __kmalloc_noprof+0xce/0x840 mm/slub.c:5439
       _kmalloc_noprof include/linux/slab.h:995 [inline]
       _kzalloc_noprof include/linux/slab.h:1312 [inline]
       mtrr_copy_map+0xc9/0x1b0 arch/x86/kernel/cpu/mtrr/generic.c:413
       mtrr_init_finalize+0xf/0xa0 arch/x86/kernel/cpu/mtrr/mtrr.c:618
       do_one_initcall+0x11c/0x6f0 init/main.c:1357
       do_initcall_level init/main.c:1419 [inline]
       do_initcalls init/main.c:1435 [inline]
       do_basic_setup init/main.c:1455 [inline]
       kernel_init_freeable+0x6ea/0x7b0 init/main.c:1670
       kernel_init+0x21/0x1e0 init/main.c:1560
       ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

-> #0 (mtrr_mutex){+.+.}-{4:4}:
       check_prev_add+0xeb/0xe60 kernel/locking/lockdep.c:3181
       check_prevs_add kernel/locking/lockdep.c:3300 [inline]
       validate_chain kernel/locking/lockdep.c:3924 [inline]
       __lock_acquire+0x1492/0x1ec0 kernel/locking/lockdep.c:5254
       lock_acquire kernel/locking/lockdep.c:5908 [inline]
       lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5865
       __mutex_lock_common kernel/locking/mutex.c:646 [inline]
       __mutex_lock+0x1a4/0x1bd0 kernel/locking/mutex.c:821
       mtrr_add_page+0x1ef/0xc00 arch/x86/kernel/cpu/mtrr/mtrr.c:261
       mtrr_write+0x2cf/0x3b0 arch/x86/kernel/cpu/mtrr/if.c:146
       pde_write fs/proc/inode.c:330 [inline]
       proc_reg_write+0x240/0x330 fs/proc/inode.c:342
       vfs_write+0x2aa/0x1050 fs/read_write.c:685
       ksys_write+0x12a/0x250 fs/read_write.c:739
       do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
       do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

Chain exists of:
  mtrr_mutex --> sk_lock-AF_INET --> cpu_hotplug_lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(cpu_hotplug_lock);
                               lock(sk_lock-AF_INET);
                               lock(cpu_hotplug_lock);
  lock(mtrr_mutex);

 *** DEADLOCK ***

locks held by syz.6.6809/29738: 3, last CPU#1:
 #0: ffff88807c2d00f0 (&f->f_pos_lock){+.+.}-{4:4}, at: fdget_pos+0x2aa/0x380 fs/file.c:1259
 #1: ffff888025ada460 (sb_writers#3){.+.+}-{0:0}, at: ksys_write+0x12a/0x250 fs/read_write.c:739
 #2: ffffffff8ec7ca50 (cpu_hotplug_lock){++++}-{0:0}, at: mtrr_add_page+0x1e1/0xc00 arch/x86/kernel/cpu/mtrr/mtrr.c:258

stack backtrace:
CPU: 1 UID: 0 PID: 29738 Comm: syz.6.6809 Tainted: G             L      syzkaller #0 PREEMPT(full) 
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/05/2026
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120
 print_circular_bug.cold+0x178/0x1be kernel/locking/lockdep.c:2059
 check_noncircular+0x146/0x160 kernel/locking/lockdep.c:2191
 check_prev_add+0xeb/0xe60 kernel/locking/lockdep.c:3181
 check_prevs_add kernel/locking/lockdep.c:3300 [inline]
 validate_chain kernel/locking/lockdep.c:3924 [inline]
 __lock_acquire+0x1492/0x1ec0 kernel/locking/lockdep.c:5254
 lock_acquire kernel/locking/lockdep.c:5908 [inline]
 lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5865
 __mutex_lock_common kernel/locking/mutex.c:646 [inline]
 __mutex_lock+0x1a4/0x1bd0 kernel/locking/mutex.c:821
 mtrr_add_page+0x1ef/0xc00 arch/x86/kernel/cpu/mtrr/mtrr.c:261
 mtrr_write+0x2cf/0x3b0 arch/x86/kernel/cpu/mtrr/if.c:146
 pde_write fs/proc/inode.c:330 [inline]
 proc_reg_write+0x240/0x330 fs/proc/inode.c:342
 vfs_write+0x2aa/0x1050 fs/read_write.c:685
 ksys_write+0x12a/0x250 fs/read_write.c:739
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x123/0x790 arch/x86/entry/syscall_64.c:84
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f7c08b9e159
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 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 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f7c06df6028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f7c08e25fa0 RCX: 00007f7c08b9e159
RDX: 000000000000002c RSI: 0000200000000200 RDI: 0000000000000003
RBP: 00007f7c08c35024 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f7c08e26038 R14: 00007f7c08e25fa0 R15: 00007ffc9d42a0c8
 </TASK>

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/08/31 13:06 upstream cee9395acd80 2f52988a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root possible deadlock in mtrr_add_page
* Struck through repros no longer work on HEAD.