syzbot


possible deadlock in get_page_from_freelist

Status: upstream: reported on 2024/04/15 02:28
Subsystems: bpf
[Documentation on labels]
Reported-by: syzbot+a7f061d2d16154538c58@syzkaller.appspotmail.com
First crash: 236d, last: 12d
Discussions (2)
Title Replies (including bot) Last reply
[syzbot] [bpf?] WARNING: locking bug in trie_delete_elem 3 (5) 2024/11/13 11:04
[syzbot] [bpf?] possible deadlock in get_page_from_freelist 5 (6) 2024/05/20 11:44
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 possible deadlock in get_page_from_freelist 1 243d 243d 0/3 auto-obsoleted due to no activity on 2024/07/13 02:54

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.11.0-rc4-syzkaller-00011-g521b1e7f4cf0 #0 Not tainted
------------------------------------------------------
syz.1.1004/8477 is trying to acquire lock:
ffff88813fffad58 (&zone->lock){-.-.}-{2:2}, at: rmqueue_buddy mm/page_alloc.c:2863 [inline]
ffff88813fffad58 (&zone->lock){-.-.}-{2:2}, at: rmqueue mm/page_alloc.c:3042 [inline]
ffff88813fffad58 (&zone->lock){-.-.}-{2:2}, at: get_page_from_freelist+0xb68/0x2f10 mm/page_alloc.c:3436

but task is already holding lock:
ffff88806229e9f8 (&trie->lock){..-.}-{2:2}, at: trie_update_elem+0xc8/0xc00 kernel/bpf/lpm_trie.c:333

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&trie->lock){..-.}-{2:2}:
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5759
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0xd5/0x120 kernel/locking/spinlock.c:162
       trie_delete_elem+0x96/0x6a0 kernel/bpf/lpm_trie.c:462
       0xffffffffa000088a
       bpf_dispatcher_nop_func include/linux/bpf.h:1243 [inline]
       __bpf_prog_run include/linux/filter.h:691 [inline]
       bpf_prog_run include/linux/filter.h:698 [inline]
       __bpf_trace_run kernel/trace/bpf_trace.c:2406 [inline]
       bpf_trace_run2+0x2ec/0x540 kernel/trace/bpf_trace.c:2447
       trace_contention_end+0x114/0x140 include/trace/events/lock.h:122
       __pv_queued_spin_lock_slowpath+0xb7e/0xdb0 kernel/locking/qspinlock.c:557
       pv_queued_spin_lock_slowpath arch/x86/include/asm/paravirt.h:584 [inline]
       queued_spin_lock_slowpath+0x42/0x50 arch/x86/include/asm/qspinlock.h:51
       queued_spin_lock include/asm-generic/qspinlock.h:114 [inline]
       do_raw_spin_lock+0x272/0x370 kernel/locking/spinlock_debug.c:116
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:111 [inline]
       _raw_spin_lock_irqsave+0xe1/0x120 kernel/locking/spinlock.c:162
       rmqueue_bulk mm/page_alloc.c:2262 [inline]
       __rmqueue_pcplist+0x44a/0x22c0 mm/page_alloc.c:2957
       rmqueue_pcplist mm/page_alloc.c:2999 [inline]
       rmqueue mm/page_alloc.c:3036 [inline]
       get_page_from_freelist+0x85a/0x2f10 mm/page_alloc.c:3436
       __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4695
       alloc_pages_mpol_noprof+0x3e8/0x680 mm/mempolicy.c:2263
       stack_depot_save_flags+0x666/0x830 lib/stackdepot.c:627
       kasan_save_stack mm/kasan/common.c:48 [inline]
       kasan_save_track+0x51/0x80 mm/kasan/common.c:68
       poison_kmalloc_redzone mm/kasan/common.c:370 [inline]
       __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:387
       kasan_kmalloc include/linux/kasan.h:211 [inline]
       __do_kmalloc_node mm/slub.c:4158 [inline]
       __kmalloc_node_noprof+0x22a/0x440 mm/slub.c:4164
       kmalloc_array_node_noprof include/linux/slab.h:788 [inline]
       alloc_slab_obj_exts mm/slub.c:1976 [inline]
       account_slab mm/slub.c:2447 [inline]
       allocate_slab+0xb6/0x2f0 mm/slub.c:2502
       new_slab mm/slub.c:2537 [inline]
       ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3723
       __slab_alloc+0x58/0xa0 mm/slub.c:3813
       __slab_alloc_node mm/slub.c:3866 [inline]
       slab_alloc_node mm/slub.c:4025 [inline]
       __do_kmalloc_node mm/slub.c:4157 [inline]
       __kmalloc_noprof+0x25a/0x400 mm/slub.c:4170
       kmalloc_noprof include/linux/slab.h:685 [inline]
       kzalloc_noprof include/linux/slab.h:807 [inline]
       __register_sysctl_table+0x65/0x1550 fs/proc/proc_sysctl.c:1363
       __devinet_sysctl_register+0x1dc/0x2a0 net/ipv4/devinet.c:2602
       devinet_sysctl_register+0x17e/0x1f0 net/ipv4/devinet.c:2642
       inetdev_init+0x296/0x4d0 net/ipv4/devinet.c:291
       inetdev_event+0x32c/0x15c0 net/ipv4/devinet.c:1565
       notifier_call_chain+0x19f/0x3e0 kernel/notifier.c:93
       call_netdevice_notifiers_extack net/core/dev.c:2032 [inline]
       call_netdevice_notifiers net/core/dev.c:2046 [inline]
       register_netdevice+0x167f/0x1b00 net/core/dev.c:10477
       __ip_tunnel_create+0x2b4/0x380 net/ipv4/ip_tunnel.c:266
       ip_tunnel_init_net+0x21c/0x710 net/ipv4/ip_tunnel.c:1159
       ops_init+0x359/0x610 net/core/net_namespace.c:139
       setup_net+0x515/0xca0 net/core/net_namespace.c:343
       copy_net_ns+0x4e2/0x7b0 net/core/net_namespace.c:508
       create_new_namespaces+0x425/0x7b0 kernel/nsproxy.c:110
       unshare_nsproxy_namespaces+0x124/0x180 kernel/nsproxy.c:228
       ksys_unshare+0x619/0xc10 kernel/fork.c:3328
       __do_sys_unshare kernel/fork.c:3399 [inline]
       __se_sys_unshare kernel/fork.c:3397 [inline]
       __x64_sys_unshare+0x38/0x40 kernel/fork.c:3397
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

-> #0 (&zone->lock){-.-.}-{2:2}:
       check_prev_add kernel/locking/lockdep.c:3133 [inline]
       check_prevs_add kernel/locking/lockdep.c:3252 [inline]
       validate_chain+0x18e0/0x5900 kernel/locking/lockdep.c:3868
       __lock_acquire+0x137a/0x2040 kernel/locking/lockdep.c:5142
       lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5759
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0xd5/0x120 kernel/locking/spinlock.c:162
       rmqueue_buddy mm/page_alloc.c:2863 [inline]
       rmqueue mm/page_alloc.c:3042 [inline]
       get_page_from_freelist+0xb68/0x2f10 mm/page_alloc.c:3436
       __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4695
       __alloc_pages_node_noprof include/linux/gfp.h:269 [inline]
       alloc_pages_node_noprof include/linux/gfp.h:296 [inline]
       ___kmalloc_large_node+0x8b/0x1d0 mm/slub.c:4103
       __kmalloc_large_node_noprof+0x1a/0x80 mm/slub.c:4130
       __do_kmalloc_node mm/slub.c:4146 [inline]
       __kmalloc_node_noprof+0x2d2/0x440 mm/slub.c:4164
       kmalloc_node_noprof include/linux/slab.h:708 [inline]
       bpf_map_kmalloc_node+0xd3/0x1c0 kernel/bpf/syscall.c:422
       lpm_trie_node_alloc kernel/bpf/lpm_trie.c:299 [inline]
       trie_update_elem+0x1cd/0xc00 kernel/bpf/lpm_trie.c:342
       bpf_map_update_value+0x4d3/0x540 kernel/bpf/syscall.c:203
       map_update_elem+0x53a/0x6f0 kernel/bpf/syscall.c:1654
       __sys_bpf+0x76f/0x810 kernel/bpf/syscall.c:5698
       __do_sys_bpf kernel/bpf/syscall.c:5817 [inline]
       __se_sys_bpf kernel/bpf/syscall.c:5815 [inline]
       __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5815
       do_syscall_x64 arch/x86/entry/common.c:52 [inline]
       do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
       entry_SYSCALL_64_after_hwframe+0x77/0x7f

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&trie->lock);
                               lock(&zone->lock);
                               lock(&trie->lock);
  lock(&zone->lock);

 *** DEADLOCK ***

2 locks held by syz.1.1004/8477:
 #0: ffffffff8e738320 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire include/linux/rcupdate.h:326 [inline]
 #0: ffffffff8e738320 (rcu_read_lock){....}-{1:2}, at: rcu_read_lock include/linux/rcupdate.h:838 [inline]
 #0: ffffffff8e738320 (rcu_read_lock){....}-{1:2}, at: bpf_map_update_value+0x3c4/0x540 kernel/bpf/syscall.c:202
 #1: ffff88806229e9f8 (&trie->lock){..-.}-{2:2}, at: trie_update_elem+0xc8/0xc00 kernel/bpf/lpm_trie.c:333

stack backtrace:
CPU: 0 UID: 0 PID: 8477 Comm: syz.1.1004 Not tainted 6.11.0-rc4-syzkaller-00011-g521b1e7f4cf0 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:93 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119
 check_noncircular+0x36a/0x4a0 kernel/locking/lockdep.c:2186
 check_prev_add kernel/locking/lockdep.c:3133 [inline]
 check_prevs_add kernel/locking/lockdep.c:3252 [inline]
 validate_chain+0x18e0/0x5900 kernel/locking/lockdep.c:3868
 __lock_acquire+0x137a/0x2040 kernel/locking/lockdep.c:5142
 lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5759
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0xd5/0x120 kernel/locking/spinlock.c:162
 rmqueue_buddy mm/page_alloc.c:2863 [inline]
 rmqueue mm/page_alloc.c:3042 [inline]
 get_page_from_freelist+0xb68/0x2f10 mm/page_alloc.c:3436
 __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4695
 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline]
 alloc_pages_node_noprof include/linux/gfp.h:296 [inline]
 ___kmalloc_large_node+0x8b/0x1d0 mm/slub.c:4103
 __kmalloc_large_node_noprof+0x1a/0x80 mm/slub.c:4130
 __do_kmalloc_node mm/slub.c:4146 [inline]
 __kmalloc_node_noprof+0x2d2/0x440 mm/slub.c:4164
 kmalloc_node_noprof include/linux/slab.h:708 [inline]
 bpf_map_kmalloc_node+0xd3/0x1c0 kernel/bpf/syscall.c:422
 lpm_trie_node_alloc kernel/bpf/lpm_trie.c:299 [inline]
 trie_update_elem+0x1cd/0xc00 kernel/bpf/lpm_trie.c:342
 bpf_map_update_value+0x4d3/0x540 kernel/bpf/syscall.c:203
 map_update_elem+0x53a/0x6f0 kernel/bpf/syscall.c:1654
 __sys_bpf+0x76f/0x810 kernel/bpf/syscall.c:5698
 __do_sys_bpf kernel/bpf/syscall.c:5817 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5815 [inline]
 __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5815
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f873f379e79
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:00007f8740142038 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007f873f515f80 RCX: 00007f873f379e79
RDX: 0000000000000020 RSI: 0000000020000000 RDI: 0000000000000002
RBP: 00007f873f3e7916 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f873f515f80 R15: 00007ffc4b017cb8
 </TASK>

Crashes (18):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/08/21 05:31 upstream 521b1e7f4cf0 9f0ab3fb .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root possible deadlock in get_page_from_freelist
2024/06/22 09:09 upstream 4545981f33be edc5149a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in get_page_from_freelist
2024/06/17 04:30 upstream 2ccbdf43d5e7 f429ab00 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in get_page_from_freelist
2024/06/15 23:41 upstream 2ccbdf43d5e7 f429ab00 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-root possible deadlock in get_page_from_freelist
2024/06/15 16:37 upstream 2ccbdf43d5e7 f429ab00 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-badwrites-root possible deadlock in get_page_from_freelist
2024/06/04 06:56 upstream 2ab795141095 a1feae05 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root possible deadlock in get_page_from_freelist
2024/05/06 18:37 upstream dd5a440a31fa c035c6de .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root possible deadlock in get_page_from_freelist
2024/04/15 10:18 upstream 0bbac3facb5d 459f4b00 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream possible deadlock in get_page_from_freelist
2024/04/14 18:24 upstream 7efd0a74039f c8349e48 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream possible deadlock in get_page_from_freelist
2024/06/26 09:00 upstream 55027e689933 c2e07261 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 possible deadlock in get_page_from_freelist
2024/07/30 05:25 bpf 41c24102af7b 5187fc86 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-bpf-kasan-gce possible deadlock in get_page_from_freelist
2024/07/30 05:23 bpf 41c24102af7b 5187fc86 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-bpf-kasan-gce possible deadlock in get_page_from_freelist
2024/11/21 07:28 net-next dd7207838d38 4b25d554 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce possible deadlock in get_page_from_freelist
2024/09/24 18:16 bpf-next 494c3a797257 5643e0e9 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-bpf-next-kasan-gce possible deadlock in get_page_from_freelist
2024/05/29 22:38 bpf-next fbe3e8473f39 34889ee3 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-bpf-next-kasan-gce possible deadlock in get_page_from_freelist
2024/05/18 20:12 net-next 4b377b4868ef c0f1611a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce possible deadlock in get_page_from_freelist
2024/05/18 14:13 net-next 4b377b4868ef c0f1611a .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce possible deadlock in get_page_from_freelist
2024/04/11 02:21 linux-next 6ebf211bb11d 56086b24 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in get_page_from_freelist
* Struck through repros no longer work on HEAD.