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: 72d, last: 37d
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 160 1d19h 88d 0/3 upstream: reported C repro on 2024/03/19 12:15
upstream possible deadlock in trie_update_elem bpf 74 1d19h 79d 0/27 upstream: reported on 2024/03/27 23:12

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

but task is already holding lock:
ffff88807d500238 (&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
       0xffffffffa000081d
       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_active_state+0x6b/0x380 lib/debugobjects.c:925
       debug_rcu_head_unqueue kernel/rcu/rcu.h:198 [inline]
       rcu_do_batch kernel/rcu/tree.c:2289 [inline]
       rcu_core+0xa55/0x1810 kernel/rcu/tree.c:2556
       __do_softirq+0x2e9/0xa4c kernel/softirq.c:571
       run_ksoftirqd+0xc1/0x120 kernel/softirq.c:934
       smpboot_thread_fn+0x52c/0xa30 kernel/smpboot.c:164
       kthread+0x28d/0x320 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308

-> #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:1684
       bpf_map_do_batch+0x4d0/0x620
       __sys_bpf+0x658/0x6c0
       __do_sys_bpf kernel/bpf/syscall.c:5109 [inline]
       __se_sys_bpf kernel/bpf/syscall.c:5107 [inline]
       __x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:5107
       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-executor.3/4618:
 #0: ffffffff8d12ac80 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire include/linux/rcupdate.h:350 [inline]
 #0: ffffffff8d12ac80 (rcu_read_lock){....}-{1:2}, at: rcu_read_lock include/linux/rcupdate.h:791 [inline]
 #0: ffffffff8d12ac80 (rcu_read_lock){....}-{1:2}, at: bpf_map_update_value+0x207/0x6f0 kernel/bpf/syscall.c:225
 #1: ffff88807d500238 (&trie->lock){-.-.}-{2:2}, at: trie_update_elem+0xc5/0xc00 kernel/bpf/lpm_trie.c:324

stack backtrace:
CPU: 1 PID: 4618 Comm: syz-executor.3 Not tainted 6.1.90-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/02/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:1684
 bpf_map_do_batch+0x4d0/0x620
 __sys_bpf+0x658/0x6c0
 __do_sys_bpf kernel/bpf/syscall.c:5109 [inline]
 __se_sys_bpf kernel/bpf/syscall.c:5107 [inline]
 __x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:5107
 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:0x7f37fba7dd69
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 20 00 00 90 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 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f37fc8800c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007f37fbbabf80 RCX: 00007f37fba7dd69
RDX: 0000000000000038 RSI: 0000000020000240 RDI: 000000000000001a
RBP: 00007f37fbaca49e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f37fbbabf80 R15: 00007ffe678df488
 </TASK>

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
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.