====================================================== WARNING: possible circular locking dependency detected 6.12.0-rc1-syzkaller #0 Not tainted ------------------------------------------------------ syz.3.920/9641 is trying to acquire lock: ffff88807ffdc220 (&pgdat->kswapd_wait){....}-{2:2}, at: __wake_up_common_lock kernel/sched/wait.c:105 [inline] ffff88807ffdc220 (&pgdat->kswapd_wait){....}-{2:2}, at: __wake_up+0x1c/0x60 kernel/sched/wait.c:127 but task is already holding lock: ffff88803735fa00 (&trie->lock){-.-.}-{2:2}, at: trie_update_elem+0xc8/0xe00 kernel/bpf/lpm_trie.c:333 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #3 (&trie->lock){-.-.}-{2:2}: __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x3a/0x60 kernel/locking/spinlock.c:162 trie_delete_elem+0xb0/0x820 kernel/bpf/lpm_trie.c:462 0xffffffffa000255a bpf_dispatcher_nop_func include/linux/bpf.h:1257 [inline] __bpf_prog_run include/linux/filter.h:701 [inline] bpf_prog_run include/linux/filter.h:708 [inline] __bpf_trace_run kernel/trace/bpf_trace.c:2318 [inline] bpf_trace_run2+0x231/0x590 kernel/trace/bpf_trace.c:2359 __bpf_trace_tlb_flush+0xd2/0x110 include/trace/events/tlb.h:38 __traceiter_tlb_flush+0x64/0xb0 include/trace/events/tlb.h:38 trace_tlb_flush+0xf3/0x170 include/trace/events/tlb.h:38 switch_mm_irqs_off+0x3fa/0xce0 arch/x86/mm/tlb.c:637 context_switch kernel/sched/core.c:5299 [inline] __schedule+0xd0c/0x5750 kernel/sched/core.c:6675 schedule_idle+0x5c/0x90 kernel/sched/core.c:6793 do_idle+0x287/0x3f0 kernel/sched/idle.c:354 cpu_startup_entry+0x4f/0x60 kernel/sched/idle.c:424 rest_init+0x16b/0x2b0 init/main.c:747 start_kernel+0x3e4/0x4d0 init/main.c:1105 x86_64_start_reservations+0x18/0x30 arch/x86/kernel/head64.c:507 x86_64_start_kernel+0xb2/0xc0 arch/x86/kernel/head64.c:488 common_startup_64+0x13e/0x148 -> #2 (&rq->__lock){-.-.}-{2:2}: _raw_spin_lock_nested+0x31/0x40 kernel/locking/spinlock.c:378 raw_spin_rq_lock_nested+0x29/0x130 kernel/sched/core.c:593 raw_spin_rq_lock kernel/sched/sched.h:1505 [inline] task_rq_lock+0xcf/0x3b0 kernel/sched/core.c:695 cgroup_move_task+0x82/0x250 kernel/sched/psi.c:1161 css_set_move_task+0x288/0x5f0 kernel/cgroup/cgroup.c:898 cgroup_post_fork+0x1c6/0x910 kernel/cgroup/cgroup.c:6692 copy_process+0x50e4/0x8dc0 kernel/fork.c:2601 kernel_clone+0xfd/0x960 kernel/fork.c:2787 user_mode_thread+0xb4/0xf0 kernel/fork.c:2865 rest_init+0x23/0x2b0 init/main.c:712 start_kernel+0x3e4/0x4d0 init/main.c:1105 x86_64_start_reservations+0x18/0x30 arch/x86/kernel/head64.c:507 x86_64_start_kernel+0xb2/0xc0 arch/x86/kernel/head64.c:488 common_startup_64+0x13e/0x148 -> #1 (&p->pi_lock){-.-.}-{2:2}: __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x3a/0x60 kernel/locking/spinlock.c:162 class_raw_spinlock_irqsave_constructor include/linux/spinlock.h:551 [inline] try_to_wake_up+0x9a/0x1440 kernel/sched/core.c:4154 autoremove_wake_function+0x16/0x150 kernel/sched/wait.c:384 __wake_up_common+0x131/0x1e0 kernel/sched/wait.c:89 __wake_up_common_lock kernel/sched/wait.c:106 [inline] __wake_up+0x31/0x60 kernel/sched/wait.c:127 wakeup_kswapd+0x45e/0x640 mm/vmscan.c:7286 rmqueue mm/page_alloc.c:3070 [inline] get_page_from_freelist+0x5e6/0x3070 mm/page_alloc.c:3454 __alloc_pages_noprof+0x223/0x25c0 mm/page_alloc.c:4733 alloc_pages_mpol_noprof+0x2c9/0x610 mm/mempolicy.c:2265 folio_alloc_mpol_noprof+0x36/0xd0 mm/mempolicy.c:2283 shmem_alloc_folio+0x135/0x160 mm/shmem.c:1774 shmem_alloc_and_add_folio+0x48b/0xc00 mm/shmem.c:1813 shmem_get_folio_gfp+0x689/0x1530 mm/shmem.c:2335 shmem_get_folio mm/shmem.c:2441 [inline] shmem_write_begin+0x161/0x300 mm/shmem.c:3046 generic_perform_write+0x2ba/0x920 mm/filemap.c:4054 shmem_file_write_iter+0x10e/0x140 mm/shmem.c:3221 new_sync_write fs/read_write.c:590 [inline] vfs_write+0x6b5/0x1140 fs/read_write.c:683 ksys_write+0x12f/0x260 fs/read_write.c:736 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f -> #0 (&pgdat->kswapd_wait){....}-{2:2}: 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+0x250b/0x3ce0 kernel/locking/lockdep.c:5202 lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5825 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x3a/0x60 kernel/locking/spinlock.c:162 __wake_up_common_lock kernel/sched/wait.c:105 [inline] __wake_up+0x1c/0x60 kernel/sched/wait.c:127 wakeup_kswapd+0x45e/0x640 mm/vmscan.c:7286 rmqueue mm/page_alloc.c:3070 [inline] get_page_from_freelist+0x5e6/0x3070 mm/page_alloc.c:3454 __alloc_pages_noprof+0x223/0x25c0 mm/page_alloc.c:4733 alloc_pages_mpol_noprof+0x2c9/0x610 mm/mempolicy.c:2265 alloc_slab_page mm/slub.c:2413 [inline] allocate_slab mm/slub.c:2579 [inline] new_slab+0x2ba/0x3f0 mm/slub.c:2632 ___slab_alloc+0xdac/0x1880 mm/slub.c:3819 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3909 __slab_alloc_node mm/slub.c:3962 [inline] slab_alloc_node mm/slub.c:4123 [inline] __do_kmalloc_node mm/slub.c:4264 [inline] __kmalloc_node_noprof+0x357/0x430 mm/slub.c:4271 kmalloc_node_noprof include/linux/slab.h:905 [inline] bpf_map_kmalloc_node+0x98/0x4a0 kernel/bpf/syscall.c:422 lpm_trie_node_alloc kernel/bpf/lpm_trie.c:299 [inline] trie_update_elem+0x1ef/0xe00 kernel/bpf/lpm_trie.c:342 bpf_map_update_value+0x2c1/0x6c0 kernel/bpf/syscall.c:203 generic_map_update_batch+0x454/0x5f0 kernel/bpf/syscall.c:1849 bpf_map_do_batch+0x5a8/0x670 kernel/bpf/syscall.c:5143 __sys_bpf+0x1ce4/0x49a0 kernel/bpf/syscall.c:5698 __do_sys_bpf kernel/bpf/syscall.c:5741 [inline] __se_sys_bpf kernel/bpf/syscall.c:5739 [inline] __x64_sys_bpf+0x78/0xc0 kernel/bpf/syscall.c:5739 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f other info that might help us debug this: Chain exists of: &pgdat->kswapd_wait --> &rq->__lock --> &trie->lock Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&trie->lock); lock(&rq->__lock); lock(&trie->lock); lock(&pgdat->kswapd_wait); *** DEADLOCK *** 2 locks held by syz.3.920/9641: #0: ffffffff8e1b8340 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire include/linux/rcupdate.h:337 [inline] #0: ffffffff8e1b8340 (rcu_read_lock){....}-{1:2}, at: rcu_read_lock include/linux/rcupdate.h:849 [inline] #0: ffffffff8e1b8340 (rcu_read_lock){....}-{1:2}, at: bpf_map_update_value+0x24b/0x6c0 kernel/bpf/syscall.c:202 #1: ffff88803735fa00 (&trie->lock){-.-.}-{2:2}, at: trie_update_elem+0xc8/0xe00 kernel/bpf/lpm_trie.c:333 stack backtrace: CPU: 3 UID: 0 PID: 9641 Comm: syz.3.920 Not tainted 6.12.0-rc1-syzkaller #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: __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+0x250b/0x3ce0 kernel/locking/lockdep.c:5202 lock_acquire.part.0+0x11b/0x380 kernel/locking/lockdep.c:5825 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline] _raw_spin_lock_irqsave+0x3a/0x60 kernel/locking/spinlock.c:162 __wake_up_common_lock kernel/sched/wait.c:105 [inline] __wake_up+0x1c/0x60 kernel/sched/wait.c:127 wakeup_kswapd+0x45e/0x640 mm/vmscan.c:7286 rmqueue mm/page_alloc.c:3070 [inline] get_page_from_freelist+0x5e6/0x3070 mm/page_alloc.c:3454 __alloc_pages_noprof+0x223/0x25c0 mm/page_alloc.c:4733 alloc_pages_mpol_noprof+0x2c9/0x610 mm/mempolicy.c:2265 alloc_slab_page mm/slub.c:2413 [inline] allocate_slab mm/slub.c:2579 [inline] new_slab+0x2ba/0x3f0 mm/slub.c:2632 ___slab_alloc+0xdac/0x1880 mm/slub.c:3819 __slab_alloc.constprop.0+0x56/0xb0 mm/slub.c:3909 __slab_alloc_node mm/slub.c:3962 [inline] slab_alloc_node mm/slub.c:4123 [inline] __do_kmalloc_node mm/slub.c:4264 [inline] __kmalloc_node_noprof+0x357/0x430 mm/slub.c:4271 kmalloc_node_noprof include/linux/slab.h:905 [inline] bpf_map_kmalloc_node+0x98/0x4a0 kernel/bpf/syscall.c:422 lpm_trie_node_alloc kernel/bpf/lpm_trie.c:299 [inline] trie_update_elem+0x1ef/0xe00 kernel/bpf/lpm_trie.c:342 bpf_map_update_value+0x2c1/0x6c0 kernel/bpf/syscall.c:203 generic_map_update_batch+0x454/0x5f0 kernel/bpf/syscall.c:1849 bpf_map_do_batch+0x5a8/0x670 kernel/bpf/syscall.c:5143 __sys_bpf+0x1ce4/0x49a0 kernel/bpf/syscall.c:5698 __do_sys_bpf kernel/bpf/syscall.c:5741 [inline] __se_sys_bpf kernel/bpf/syscall.c:5739 [inline] __x64_sys_bpf+0x78/0xc0 kernel/bpf/syscall.c:5739 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcd/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f6bd317dff9 Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 a8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007f6bd4063038 EFLAGS: 00000246 ORIG_RAX: 0000000000000141 RAX: ffffffffffffffda RBX: 00007f6bd3335f80 RCX: 00007f6bd317dff9 RDX: 0000000000000038 RSI: 0000000020000480 RDI: 000000000000001a RBP: 00007f6bd31f0296 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00007f6bd3335f80 R15: 00007ffe594d9ee8