possible deadlock in secretmem_fault (2)

Status: upstream: reported on 2026/12/04 13:06
Subsystems: nbd
Labels: prio:low
[Documentation on labels]
Reported-by: syzbot+bb13485947f1062540db@syzkaller.appspotmail.com
First crash: 1d00h, last: 1d00h
✨ AI cause bisection: introduced by (AI job) :
commit 9280e6edf65662b6aafc8b704ad065b54c08b519
Author: Deepanshu Kartikey <kartikey406@gmail.com>
Date: Sun Jun 21 23:52:55 2026 +0000

  nbd: don't warn when reclassifying a busy socket lock

✨ AI-generated root cause summary:

The lockdep circular locking dependency is caused by nbd_reclassify_socket() in drivers/block/nbd.c silently skipping lock-class reclassification when sock_allow_reclassification(sk) returns false. Because nbd_add_socket() accepts an arbitrary userspace socket fd, a concurrent syscall or softirq holding sk->sk_lock or sk->sk_lock.slock causes nbd_reclassify_socket() to return early without reclassifying sk->sk_lock to sk_lock-AF_INET6-NBD. Leaving the NBD socket in the generic sk_lock-AF_INET6 lockdep class causes lockdep to conflate NBD's socket lock (acquired under nsock->tx_lock, cmd->lock, set->srcu, q->elevator_lock, q->q_usage_counter(io), and fs_reclaim) with unrelated AF_INET6 sockets such as rawv6_sendmsg(), which acquire mm->mmap_lock (and subsequently mapping->invalidate_lock and fs_reclaim in secretmem_fault()).

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit d06ce6f1eb5e:

Root Cause Analysis

The circular locking dependency reported by lockdep is caused by nbd_reclassify_socket() in drivers/block/nbd.c silently skipping lockdep lock-class reclassification when sock_allow_reclassification(sk) is false, while nbd_add_socket() (and nbd_genl_reconnect_sock_cb()) still accept and use the socket.

Technical Mechanism

  1. Failed Lockdep Reclassification in drivers/block/nbd.c:

    • NBD obtains sockets from userspace file descriptors via nbd_get_socket() (sockfd_lookup()), which allows AF_INET, AF_INET6, and AF_UNIX stream sockets (sk_is_tcp() or sk_is_stream_unix()).
    • nbd_add_socket() (drivers/block/nbd.c:1277-1299) and nbd_genl_reconnect_sock_cb() (drivers/block/nbd.c:1348-1359) call nbd_reclassify_socket(sock) (drivers/block/nbd.c:1245-1272) to move sk->sk_lock and sk->sk_lock.slock into NBD-specific lockdep classes (nbd_key[] / nbd_slock_key[], e.g. "sk_lock-AF_INET6-NBD"), separating NBD's block-I/O socket lock from general userspace sockets.
    • However, nbd_reclassify_socket() checks sock_allow_reclassification(sk) (include/net/sock.h:1835-1841):
      if (!sock_allow_reclassification(sk))
          return;
      
      sock_allow_reclassification(sk) returns false whenever sock_owned_by_user_nocheck(sk) (sk->sk_lock.owned) or spin_is_locked(&sk->sk_lock.slock) is true. Because the socket fd comes from userspace (and may also receive network packets in softirq via bh_lock_sock), another thread holding lock_sock(sk) or softirq holding sk->sk_lock.slock at the moment nbd_add_socket() runs causes nbd_reclassify_socket() to return without reclassifying sk and without returning an error.
    • As a result, sk->sk_lock.dep_map remains in the generic sk_lock-AF_INET6 class (visible at #6 in the report instead of sk_lock-AF_INET6-NBD). Note also that sock_lock_init_class_and_name() (include/net/sock.h:1694-1705) re-initializes sk->sk_lock.owned and sk->sk_lock.slock without locking, so sock_allow_reclassification() is inherently racy on a userspace-shared or live socket.
  2. Resulting Lockdep Dependency Cycle:

    • fs_reclaim β†’ &q->q_usage_counter(io) (block/blk-core.c:502-505): blk_alloc_queue() teaches lockdep that memory reclaim may wait on block queue I/O (q->io_lockdep_map).
    • &q->q_usage_counter(io) β†’ &q->elevator_lock β†’ set->srcu: During nbd_genl_connect() β†’ nbd_start_device() β†’ blk_mq_update_nr_hw_queues() β†’ blk_mq_elv_switch_none() β†’ elevator_set_none() β†’ elevator_change() (block/elevator.c:668-682), the queue is frozen (q->io_lockdep_map write-acquired), q->elevator_lock is acquired, and elevator_switch() calls blk_mq_quiesce_queue() (block/elevator.c:576), synchronizing set->srcu.
    • set->srcu β†’ &cmd->lock β†’ &nsock->tx_lock: In nbd_queue_rq() (drivers/block/nbd.c:1184-1210) under srcu_read_lock(set->srcu), NBD locks cmd->lock and calls nbd_handle_cmd(), which locks nsock->tx_lock (drivers/block/nbd.c:1143).
    • &nsock->tx_lock β†’ sk_lock-AF_INET6: During teardown in nbd_genl_connect() β†’ nbd_config_put() β†’ nbd_clear_sock() β†’ sock_shutdown() (drivers/block/nbd.c:419-420), nsock->tx_lock is held while nbd_mark_nsock_dead() calls kernel_sock_shutdown(nsock->sock, SHUT_RDWR) β†’ inet_shutdown() (net/ipv4/af_inet.c:913), which calls lock_sock(sk) on the unclassified sk_lock-AF_INET6 socket.
    • sk_lock-AF_INET6 β†’ &mm->mmap_lock: In rawv6_sendmsg() (net/ipv6/raw.c:916-919), lock_sock(sk) (also using sk_lock-AF_INET6) is held across ip6_append_data() β†’ raw6_getfrag() β†’ ip_generic_getfrag() β†’ csum_and_copy_from_iter_full() β†’ copy_from_user() β†’ __might_fault().
    • &mm->mmap_lock β†’ mapping.invalidate_lock#9 β†’ fs_reclaim: On a page fault in secretmem_fault() (mm/secretmem.c:125-130), while holding mm->mmap_lock and mapping->invalidate_lock (filemap_invalidate_lock_shared()), folio_alloc(gfp | __GFP_ZERO, 0) is called with vmf->gfp_mask (GFP_USER | __GFP_FS | __GFP_IO), triggering fs_reclaim_acquire() and closing the cycle.
  3. Note on Userspace Socket Retention: Because userspace retains the original socket fd after passing it to nbd_add_socket(), even if lockdep reclassification succeeds, a privileged user (CAP_SYS_ADMIN) could still invoke sendmsg()/recvmsg() on that same NBD socket fd with faulting user buffers (lock_sock β†’ mm->mmap_lock β†’ fs_reclaim) concurrently with block reclaim I/O on the NBD device (nbd_queue_rq β†’ sock_xmit β†’ lock_sock). However, the reported cross-socket cycle between rawv6_sendmsg() and NBD is specifically caused by nbd_reclassify_socket() failing to reclassify the NBD socket out of sk_lock-AF_INET6.

Suggested Fix Direction

  • In drivers/block/nbd.c, do not silently ignore !sock_allow_reclassification(sk) in nbd_reclassify_socket()β€”either reject the socket (e.g., return -EBUSY from nbd_reclassify_socket() / nbd_add_socket() / nbd_genl_reconnect_sock_cb()) or prevent concurrent lock acquisition / user access before reclassifying sk->sk_lock (and avoid racy re-initialization of sk->sk_lock.slock while softirqs may acquire bh_lock_sock()).
▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
4d6caa57 bisect-cause IsRelease: ❌ ❓ possible deadlock in secretmem_fault (2) 2026/12/04 00:16 2026/12/04 00:16 2026/12/04 00:52 877371f2
e073087f assessment-security DenialOfService: ❌ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ possible deadlock in secretmem_fault (2) 2026/12/04 00:01 2026/12/04 00:01 2026/12/04 00:40 877371f2
▶ ▼ Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [nbd?] possible deadlock in secretmem_fault (2) 0 (1) 2026/12/04 13:06

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
syzkaller #0 Tainted: G             L     
------------------------------------------------------
syz.8.2498/12962 is trying to acquire lock:
ffffffff901db8a0 (fs_reclaim){+.+.}-{0:0}, at: might_alloc include/linux/sched/mm.h:316 [inline]
ffffffff901db8a0 (fs_reclaim){+.+.}-{0:0}, at: prepare_alloc_pages+0x166/0x5b0 mm/page_alloc.c:5165

but task is already holding lock:
ffff888057f03258 (mapping.invalidate_lock#9){++++}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:1092 [inline]
ffff888057f03258 (mapping.invalidate_lock#9){++++}-{4:4}, at: secretmem_fault+0x1c5/0xbe0 mm/secretmem.c:125

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #8 (mapping.invalidate_lock#9){++++}-{4:4}:
       lock_acquire kernel/locking/lockdep.c:5942 [inline]
       lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899
       down_read+0x94/0x4c0 kernel/locking/rwsem.c:1574
       filemap_invalidate_lock_shared include/linux/fs.h:1092 [inline]
       secretmem_fault+0x1c5/0xbe0 mm/secretmem.c:125
       __do_fault+0x10b/0x440 mm/memory.c:5693
       do_shared_fault mm/memory.c:6208 [inline]
       do_fault+0x524/0x1780 mm/memory.c:6282
       do_pte_missing mm/memory.c:4800 [inline]
       handle_pte_fault mm/memory.c:6697 [inline]
       __handle_mm_fault+0x1858/0x2f40 mm/memory.c:6849
       handle_mm_fault+0x363/0xa30 mm/memory.c:7016
       do_user_addr_fault+0x745/0x12f0 arch/x86/mm/fault.c:1394
       handle_page_fault arch/x86/mm/fault.c:1483 [inline]
       exc_page_fault+0x6f/0xd0 arch/x86/mm/fault.c:1536
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:595

-> #7 (&mm->mmap_lock){++++}-{4:4}:
       lock_acquire kernel/locking/lockdep.c:5942 [inline]
       lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899
       __might_fault+0xde/0x140 mm/memory.c:7607
       _inline_copy_from_user include/linux/uaccess.h:169 [inline]
       _copy_from_user+0x29/0xd0 lib/usercopy.c:18
       copy_from_user include/linux/uaccess.h:222 [inline]
       csum_and_copy_from_user include/net/checksum.h:31 [inline]
       copy_from_user_iter_csum net/core/skbuff.c:7703 [inline]
       iterate_ubuf include/linux/iov_iter.h:30 [inline]
       iterate_and_advance2 include/linux/iov_iter.h:302 [inline]
       csum_and_copy_from_iter_full+0x21a/0x1fe0 net/core/skbuff.c:7715
       ip_generic_getfrag+0x172/0x270 net/ipv4/ip_output.c:949
       raw6_getfrag+0x22c/0x290 net/ipv6/raw.c:743
       __ip6_append_data+0x37e8/0x4b10 net/ipv6/ip6_output.c:1739
       ip6_append_data net/ipv6/ip6_output.c:1894 [inline]
       ip6_append_data+0x10b/0x410 net/ipv6/ip6_output.c:1863
       rawv6_sendmsg+0x169c/0x4630 net/ipv6/raw.c:917
       inet_sendmsg+0x11c/0x140 net/ipv4/af_inet.c:866
       sock_sendmsg_nosec net/socket.c:800 [inline]
       __sock_sendmsg net/socket.c:818 [inline]
       ____sys_sendmsg+0x9a0/0xb90 net/socket.c:2713
       ___sys_sendmsg+0x208/0x270 net/socket.c:2770
       __sys_sendmsg+0x160/0x210 net/socket.c:2802
       do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
       do_syscall_64+0x123/0x7b0 arch/x86/entry/syscall_64.c:89
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #6 (sk_lock-AF_INET6){+.+.}-{0:0}:
       lock_acquire kernel/locking/lockdep.c:5942 [inline]
       lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899
       lock_sock_nested+0x41/0xf0 net/core/sock.c:3909
       lock_sock include/net/sock.h:1717 [inline]
       inet_shutdown+0x67/0x410 net/ipv4/af_inet.c:913
       nbd_mark_nsock_dead+0xae/0x5c0 drivers/block/nbd.c:319
       sock_shutdown+0x16b/0x200 drivers/block/nbd.c:420
       nbd_clear_sock drivers/block/nbd.c:1464 [inline]
       nbd_config_put+0x3d5/0x9b0 drivers/block/nbd.c:1493
       nbd_genl_connect+0xd72/0x1770 drivers/block/nbd.c:2320
       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:2585
       genl_rcv+0x28/0x40 net/netlink/genetlink.c:1218
       netlink_unicast_kernel net/netlink/af_netlink.c:1336 [inline]
       netlink_unicast+0x668/0x950 net/netlink/af_netlink.c:1362
       netlink_sendmsg+0x9ac/0x10c0 net/netlink/af_netlink.c:1921
       sock_sendmsg_nosec net/socket.c:800 [inline]
       __sock_sendmsg net/socket.c:818 [inline]
       ____sys_sendmsg+0xa13/0xb90 net/socket.c:2713
       ___sys_sendmsg+0x208/0x270 net/socket.c:2770
       __sys_sendmsg+0x160/0x210 net/socket.c:2802
       do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
       do_syscall_64+0x123/0x7b0 arch/x86/entry/syscall_64.c:89
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #5 (&nsock->tx_lock){+.+.}-{4:4}:
       lock_acquire kernel/locking/lockdep.c:5942 [inline]
       lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899
       __mutex_lock_common kernel/locking/mutex.c:646 [inline]
       __mutex_lock+0x19f/0x1c10 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:2141
       __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+0x130/0x380 block/blk-mq.c:2555
       process_one_work+0xaeb/0x1b40 kernel/workqueue.c:3497
       process_scheduled_works kernel/workqueue.c:3580 [inline]
       worker_thread+0x5ef/0xe50 kernel/workqueue.c:3661
       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 (&cmd->lock){+.+.}-{4:4}:
       lock_acquire kernel/locking/lockdep.c:5942 [inline]
       lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899
       __mutex_lock_common kernel/locking/mutex.c:646 [inline]
       __mutex_lock+0x19f/0x1c10 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:2141
       __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+0x130/0x380 block/blk-mq.c:2555
       process_one_work+0xaeb/0x1b40 kernel/workqueue.c:3497
       process_scheduled_works kernel/workqueue.c:3580 [inline]
       worker_thread+0x5ef/0xe50 kernel/workqueue.c:3661
       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

-> #3 (set->srcu){.+.+}-{0:0}:
       lock_sync kernel/locking/lockdep.c:5991 [inline]
       lock_sync+0xb5/0x120 kernel/locking/lockdep.c:5979
       srcu_lock_sync include/linux/srcu.h:261 [inline]
       __synchronize_srcu+0xa2/0x310 kernel/rcu/srcutree.c:1662
       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+0x49e/0x640 block/blk-sysfs.c:992
       __add_disk+0x7dd/0xf10 block/genhd.c:531
       add_disk_fwnode+0x118/0x480 block/genhd.c:600
       add_disk include/linux/blkdev.h:799 [inline]
       nbd_dev_add+0x779/0xb10 drivers/block/nbd.c:2027
       nbd_init+0x2c5/0x2e0 drivers/block/nbd.c:2744
       do_one_initcall+0x11c/0x6f0 init/main.c:1432
       do_initcall_level init/main.c:1494 [inline]
       do_initcalls init/main.c:1510 [inline]
       do_basic_setup init/main.c:1530 [inline]
       kernel_init_freeable+0x6ea/0x7b0 init/main.c:1745
       kernel_init+0x21/0x1e0 init/main.c:1635
       ret_from_fork+0x730/0xd60 arch/x86/kernel/process.c:158
       ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245

-> #2 (&q->elevator_lock){+.+.}-{4:4}:
       lock_acquire kernel/locking/lockdep.c:5942 [inline]
       lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899
       __mutex_lock_common kernel/locking/mutex.c:646 [inline]
       __mutex_lock+0x19f/0x1c10 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:5171 [inline]
       __blk_mq_update_nr_hw_queues block/blk-mq.c:5216 [inline]
       blk_mq_update_nr_hw_queues+0x4e1/0x1690 block/blk-mq.c:5284
       nbd_start_device+0x1a6/0xbd0 drivers/block/nbd.c:1531
       nbd_genl_connect+0xfc2/0x1770 drivers/block/nbd.c:2311
       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:2585
       genl_rcv+0x28/0x40 net/netlink/genetlink.c:1218
       netlink_unicast_kernel net/netlink/af_netlink.c:1336 [inline]
       netlink_unicast+0x668/0x950 net/netlink/af_netlink.c:1362
       netlink_sendmsg+0x9ac/0x10c0 net/netlink/af_netlink.c:1921
       sock_sendmsg_nosec net/socket.c:800 [inline]
       __sock_sendmsg net/socket.c:818 [inline]
       ____sys_sendmsg+0xa13/0xb90 net/socket.c:2713
       ___sys_sendmsg+0x208/0x270 net/socket.c:2770
       __sys_sendmsg+0x160/0x210 net/socket.c:2802
       do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
       do_syscall_64+0x123/0x7b0 arch/x86/entry/syscall_64.c:89
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #1 (&q->q_usage_counter(io)#49){++++}-{0:0}:
       lock_acquire kernel/locking/lockdep.c:5942 [inline]
       lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899
       blk_alloc_queue+0x610/0x790 block/blk-core.c:503
       blk_mq_alloc_queue+0x174/0x290 block/blk-mq.c:4471
       __blk_mq_alloc_disk+0x29/0x120 block/blk-mq.c:4518
       nbd_dev_add+0x491/0xb10 drivers/block/nbd.c:1997
       nbd_init+0x2c5/0x2e0 drivers/block/nbd.c:2744
       do_one_initcall+0x11c/0x6f0 init/main.c:1432
       do_initcall_level init/main.c:1494 [inline]
       do_initcalls init/main.c:1510 [inline]
       do_basic_setup init/main.c:1530 [inline]
       kernel_init_freeable+0x6ea/0x7b0 init/main.c:1745
       kernel_init+0x21/0x1e0 init/main.c:1635
       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 (fs_reclaim){+.+.}-{0:0}:
       check_prev_add+0xeb/0xe60 kernel/locking/lockdep.c:3209
       check_prevs_add kernel/locking/lockdep.c:3328 [inline]
       validate_chain kernel/locking/lockdep.c:3952 [inline]
       __lock_acquire+0x1528/0x1f40 kernel/locking/lockdep.c:5288
       lock_acquire kernel/locking/lockdep.c:5942 [inline]
       lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899
       __fs_reclaim_acquire mm/page_alloc.c:4388 [inline]
       fs_reclaim_acquire+0xc4/0x100 mm/page_alloc.c:4402
       might_alloc include/linux/sched/mm.h:316 [inline]
       prepare_alloc_pages+0x166/0x5b0 mm/page_alloc.c:5165
       __alloc_frozen_pages_noprof+0x1b9/0x31e0 mm/page_alloc.c:5490
       alloc_pages_mpol+0x201/0x560 mm/mempolicy.c:2520
       alloc_pages_noprof mm/mempolicy.c:2611 [inline]
       folio_alloc_noprof+0x22/0x250 mm/mempolicy.c:2621
       secretmem_fault+0x399/0xbe0 mm/secretmem.c:130
       __do_fault+0x10b/0x440 mm/memory.c:5693
       do_shared_fault mm/memory.c:6208 [inline]
       do_fault+0x524/0x1780 mm/memory.c:6282
       do_pte_missing mm/memory.c:4800 [inline]
       handle_pte_fault mm/memory.c:6697 [inline]
       __handle_mm_fault+0x1858/0x2f40 mm/memory.c:6849
       handle_mm_fault+0x363/0xa30 mm/memory.c:7016
       do_user_addr_fault+0x745/0x12f0 arch/x86/mm/fault.c:1394
       handle_page_fault arch/x86/mm/fault.c:1483 [inline]
       exc_page_fault+0x6f/0xd0 arch/x86/mm/fault.c:1536
       asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:595

other info that might help us debug this:

Chain exists of:
  fs_reclaim --> &mm->mmap_lock --> mapping.invalidate_lock#9

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  rlock(mapping.invalidate_lock#9);
                               lock(&mm->mmap_lock);
                               lock(mapping.invalidate_lock#9);
  lock(fs_reclaim);

 *** DEADLOCK ***

locks held by syz.8.2498/12962: 2, on CPU#0:
 #0: ffff888036dcccc0 (&mm->mmap_lock){++++}-{4:4}, at: mmap_read_trylock include/linux/mmap_lock.h:635 [inline]
 #0: ffff888036dcccc0 (&mm->mmap_lock){++++}-{4:4}, at: get_mmap_lock_carefully mm/mmap_lock.c:568 [inline]
 #0: ffff888036dcccc0 (&mm->mmap_lock){++++}-{4:4}, at: lock_mm_and_find_vma+0x35/0x750 mm/mmap_lock.c:628
 #1: ffff888057f03258 (mapping.invalidate_lock#9){++++}-{4:4}, at: filemap_invalidate_lock_shared include/linux/fs.h:1092 [inline]
 #1: ffff888057f03258 (mapping.invalidate_lock#9){++++}-{4:4}, at: secretmem_fault+0x1c5/0xbe0 mm/secretmem.c:125

stack backtrace:
CPU: 0 UID: 0 PID: 12962 Comm: syz.8.2498 Tainted: G             L      syzkaller #0 PREEMPT(full) 
Tainted: [L]=SOFTLOCKUP
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/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:2087
 check_noncircular+0x146/0x160 kernel/locking/lockdep.c:2219
 check_prev_add+0xeb/0xe60 kernel/locking/lockdep.c:3209
 check_prevs_add kernel/locking/lockdep.c:3328 [inline]
 validate_chain kernel/locking/lockdep.c:3952 [inline]
 __lock_acquire+0x1528/0x1f40 kernel/locking/lockdep.c:5288
 lock_acquire kernel/locking/lockdep.c:5942 [inline]
 lock_acquire+0x1d1/0x380 kernel/locking/lockdep.c:5899
 __fs_reclaim_acquire mm/page_alloc.c:4388 [inline]
 fs_reclaim_acquire+0xc4/0x100 mm/page_alloc.c:4402
 might_alloc include/linux/sched/mm.h:316 [inline]
 prepare_alloc_pages+0x166/0x5b0 mm/page_alloc.c:5165
 __alloc_frozen_pages_noprof+0x1b9/0x31e0 mm/page_alloc.c:5490
 alloc_pages_mpol+0x201/0x560 mm/mempolicy.c:2520
 alloc_pages_noprof mm/mempolicy.c:2611 [inline]
 folio_alloc_noprof+0x22/0x250 mm/mempolicy.c:2621
 secretmem_fault+0x399/0xbe0 mm/secretmem.c:130
 __do_fault+0x10b/0x440 mm/memory.c:5693
 do_shared_fault mm/memory.c:6208 [inline]
 do_fault+0x524/0x1780 mm/memory.c:6282
 do_pte_missing mm/memory.c:4800 [inline]
 handle_pte_fault mm/memory.c:6697 [inline]
 __handle_mm_fault+0x1858/0x2f40 mm/memory.c:6849
 handle_mm_fault+0x363/0xa30 mm/memory.c:7016
 do_user_addr_fault+0x745/0x12f0 arch/x86/mm/fault.c:1394
 handle_page_fault arch/x86/mm/fault.c:1483 [inline]
 exc_page_fault+0x6f/0xd0 arch/x86/mm/fault.c:1536
 asm_exc_page_fault+0x26/0x30 arch/x86/include/asm/idtentry.h:595
RIP: 0033:0x7f38c5468b82
Code: 30 48 8b 14 24 48 85 d2 74 17 8b 44 24 10 0f c8 89 c0 48 89 44 24 10 48 83 fa 01 0f 85 aa 02 00 00 48 8b 44 24 18 8b 74 24 10 <89> 30 e9 1e fe ff ff 48 8b 44 24 18 8b 10 48 8b 04 24 48 85 c0 0f
RSP: 002b:00007fffd3b1ef10 EFLAGS: 00010246
RAX: 0000200000000040 RBX: 0000000000000004 RCX: 0000000000000000
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 00005555634703d8
RBP: 00007fffd3b1f038 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000100000001 R11: 0000000000000004 R12: 00007f38c5835fac
R13: 00007fffd3b1f070 R14: 000000000006bddf R15: 00007f38c5835fa0
 </TASK>

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