syzbot


possible deadlock in trie_update_elem

Status: upstream: reported on 2024/04/04 11:38
Reported-by: syzbot+71d4df074d6dbe9f4799@syzkaller.appspotmail.com
First crash: 211d, last: 77d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 possible deadlock in trie_update_elem origin:lts-only C done 219 6d07h 227d 0/3 upstream: reported C repro on 2024/03/19 12:15
upstream possible deadlock in trie_update_elem bpf 136 13d 219d 0/28 upstream: reported on 2024/03/27 23:12

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.105-syzkaller #0 Not tainted
------------------------------------------------------
syz.1.292/4396 is trying to acquire lock:
ffffffff921e8a98 (&obj_hash[i].lock){-.-.}-{2:2}, at: debug_object_activate+0x68/0x4e0 lib/debugobjects.c:697

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

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&trie->lock){-.-.}-{2:2}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
       trie_delete_elem+0x90/0x690 kernel/bpf/lpm_trie.c:451
       0xffffffffa00008b5
       bpf_dispatcher_nop_func include/linux/bpf.h:989 [inline]
       __bpf_prog_run include/linux/filter.h:603 [inline]
       bpf_prog_run include/linux/filter.h:610 [inline]
       __bpf_trace_run kernel/trace/bpf_trace.c:2273 [inline]
       bpf_trace_run2+0x1fd/0x410 kernel/trace/bpf_trace.c:2312
       trace_contention_end+0x14c/0x190 include/trace/events/lock.h:122
       __pv_queued_spin_lock_slowpath+0x935/0xc50 kernel/locking/qspinlock.c:560
       pv_queued_spin_lock_slowpath arch/x86/include/asm/paravirt.h:591 [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+0x269/0x370 kernel/locking/spinlock_debug.c:115
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:111 [inline]
       _raw_spin_lock_irqsave+0xdd/0x120 kernel/locking/spinlock.c:162
       debug_object_activate+0x68/0x4e0 lib/debugobjects.c:697
       debug_rcu_head_queue kernel/rcu/rcu.h:189 [inline]
       kvfree_call_rcu+0xb4/0x8c0 kernel/rcu/tree.c:3391
       cfg80211_update_known_bss+0x16b/0x9e0
       cfg80211_bss_update+0x187/0x21e0 net/wireless/scan.c:1788
       cfg80211_inform_single_bss_frame_data net/wireless/scan.c:2449 [inline]
       cfg80211_inform_bss_frame_data+0xae4/0x1680 net/wireless/scan.c:2482
       ieee80211_bss_info_update+0x847/0xf00 net/mac80211/scan.c:190
       ieee80211_rx_bss_info net/mac80211/ibss.c:1120 [inline]
       ieee80211_rx_mgmt_probe_beacon net/mac80211/ibss.c:1609 [inline]
       ieee80211_ibss_rx_queued_mgmt+0x1962/0x2dd0 net/mac80211/ibss.c:1638
       ieee80211_iface_process_skb net/mac80211/iface.c:1632 [inline]
       ieee80211_iface_work+0x7aa/0xce0 net/mac80211/iface.c:1686
       process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292
       worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
       kthread+0x28d/0x320 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

-> #0 (&obj_hash[i].lock){-.-.}-{2:2}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
       debug_object_activate+0x68/0x4e0 lib/debugobjects.c:697
       debug_rcu_head_queue kernel/rcu/rcu.h:189 [inline]
       kvfree_call_rcu+0xb4/0x8c0 kernel/rcu/tree.c:3391
       trie_update_elem+0x808/0xc00 kernel/bpf/lpm_trie.c:385
       bpf_map_update_value+0x5cf/0x6f0 kernel/bpf/syscall.c:226
       generic_map_update_batch+0x579/0x920 kernel/bpf/syscall.c:1699
       bpf_map_do_batch+0x4d0/0x620
       __sys_bpf+0x658/0x6c0
       __do_sys_bpf kernel/bpf/syscall.c:5124 [inline]
       __se_sys_bpf kernel/bpf/syscall.c:5122 [inline]
       __x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:5122
       do_syscall_x64 arch/x86/entry/common.c:51 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&trie->lock);
                               lock(&obj_hash[i].lock);
                               lock(&trie->lock);
  lock(&obj_hash[i].lock);

 *** DEADLOCK ***

2 locks held by syz.1.292/4396:
 #0: ffffffff8d32afc0 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire include/linux/rcupdate.h:350 [inline]
 #0: ffffffff8d32afc0 (rcu_read_lock){....}-{1:2}, at: rcu_read_lock include/linux/rcupdate.h:791 [inline]
 #0: ffffffff8d32afc0 (rcu_read_lock){....}-{1:2}, at: bpf_map_update_value+0x207/0x6f0 kernel/bpf/syscall.c:225
 #1: ffff888023f13238 (&trie->lock){-.-.}-{2:2}, at: trie_update_elem+0xc5/0xc00 kernel/bpf/lpm_trie.c:324

stack backtrace:
CPU: 0 PID: 4396 Comm: syz.1.292 Not tainted 6.1.105-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/27/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 check_noncircular+0x2fa/0x3b0 kernel/locking/lockdep.c:2170
 check_prev_add kernel/locking/lockdep.c:3090 [inline]
 check_prevs_add kernel/locking/lockdep.c:3209 [inline]
 validate_chain+0x1661/0x5950 kernel/locking/lockdep.c:3825
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5049
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
 debug_object_activate+0x68/0x4e0 lib/debugobjects.c:697
 debug_rcu_head_queue kernel/rcu/rcu.h:189 [inline]
 kvfree_call_rcu+0xb4/0x8c0 kernel/rcu/tree.c:3391
 trie_update_elem+0x808/0xc00 kernel/bpf/lpm_trie.c:385
 bpf_map_update_value+0x5cf/0x6f0 kernel/bpf/syscall.c:226
 generic_map_update_batch+0x579/0x920 kernel/bpf/syscall.c:1699
 bpf_map_do_batch+0x4d0/0x620
 __sys_bpf+0x658/0x6c0
 __do_sys_bpf kernel/bpf/syscall.c:5124 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5122 [inline]
 __x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:5122
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
RIP: 0033:0x7f7351d799b9
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:00007f7352bea038 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007f7351f15f80 RCX: 00007f7351d799b9
RDX: 0000000000000038 RSI: 0000000020000240 RDI: 000000000000001a
RBP: 00007f7351de78d8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f7351f15f80 R15: 00007ffe485484e8
 </TASK>

Crashes (5):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/08/16 16:04 linux-6.1.y 117ac406ba90 e1c76ab2 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-perf possible deadlock in trie_update_elem
2024/05/08 23:45 linux-6.1.y 909ba1f1b414 20bf80e1 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-perf possible deadlock in trie_update_elem
2024/04/19 16:05 linux-6.1.y 6741e066ec76 af24b050 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-perf possible deadlock in trie_update_elem
2024/04/13 04:18 linux-6.1.y bf1e3b1cb1e0 c8349e48 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-perf possible deadlock in trie_update_elem
2024/04/04 11:37 linux-6.1.y 347385861c50 0ee3535e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in trie_update_elem
* Struck through repros no longer work on HEAD.