syzbot


possible deadlock in bpf_trace_printk

Status: upstream: reported C repro on 2022/06/09 17:07
Reported-by: syzbot+c49e17557ddb5725583d@syzkaller.appspotmail.com
First crash: 16d, last: 4d02h

Cause bisection: introduced by (bisect log) :
commit dc1f7893a70fe403983bd8492f177bf993940e2c
Author: Peter Zijlstra <peterz@infradead.org>
Date: Wed Mar 30 11:06:54 2022 +0000

  locking/mutex: Make contention tracepoints more consistent wrt adaptive spinning

Crash: possible deadlock in bpf_trace_printk (log)
Repro: C syz .config
Patch testing requests:
Created Duration User Patch Repo Result
2022/06/11 00:56 18m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git d678cbd2f867 OK log
2022/06/10 15:17 9m hdanton@sina.com patch https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git d678cbd2f867 report log

Sample crash report:
============================================
WARNING: possible recursive locking detected
5.18.0-syzkaller-12122-gd678cbd2f867 #0 Not tainted
--------------------------------------------
syz-executor354/3616 is trying to acquire lock:
ffffffff8be0d6d8 (trace_printk_lock){..-.}-{2:2}, at: ____bpf_trace_printk kernel/trace/bpf_trace.c:388 [inline]
ffffffff8be0d6d8 (trace_printk_lock){..-.}-{2:2}, at: bpf_trace_printk+0xcf/0x170 kernel/trace/bpf_trace.c:374

but task is already holding lock:
ffffffff8be0d6d8 (trace_printk_lock){..-.}-{2:2}, at: ____bpf_trace_printk kernel/trace/bpf_trace.c:388 [inline]
ffffffff8be0d6d8 (trace_printk_lock){..-.}-{2:2}, at: bpf_trace_printk+0xcf/0x170 kernel/trace/bpf_trace.c:374

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(trace_printk_lock);
  lock(trace_printk_lock);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

4 locks held by syz-executor354/3616:
 #0: ffffffff8be67668 (delayed_uprobe_lock){+.+.}-{3:3}, at: uprobe_clear_state+0x47/0x420 kernel/events/uprobes.c:1544
 #1: ffffffff8bd86be0 (rcu_read_lock){....}-{1:2}, at: bpf_trace_run2+0x0/0x340 kernel/trace/./bpf_trace.h:11
 #2: ffffffff8be0d6d8 (trace_printk_lock){..-.}-{2:2}, at: ____bpf_trace_printk kernel/trace/bpf_trace.c:388 [inline]
 #2: ffffffff8be0d6d8 (trace_printk_lock){..-.}-{2:2}, at: bpf_trace_printk+0xcf/0x170 kernel/trace/bpf_trace.c:374
 #3: ffffffff8bd86be0 (rcu_read_lock){....}-{1:2}, at: bpf_trace_run2+0x0/0x340 kernel/trace/./bpf_trace.h:11

stack backtrace:
CPU: 1 PID: 3616 Comm: syz-executor354 Not tainted 5.18.0-syzkaller-12122-gd678cbd2f867 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
 print_deadlock_bug kernel/locking/lockdep.c:2988 [inline]
 check_deadlock kernel/locking/lockdep.c:3031 [inline]
 validate_chain kernel/locking/lockdep.c:3816 [inline]
 __lock_acquire.cold+0x1f5/0x3b4 kernel/locking/lockdep.c:5053
 lock_acquire kernel/locking/lockdep.c:5665 [inline]
 lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5630
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0x39/0x50 kernel/locking/spinlock.c:162
 ____bpf_trace_printk kernel/trace/bpf_trace.c:388 [inline]
 bpf_trace_printk+0xcf/0x170 kernel/trace/bpf_trace.c:374
 bpf_prog_0605f9f479290f07+0x2f/0x33
 bpf_dispatcher_nop_func include/linux/bpf.h:869 [inline]
 __bpf_prog_run include/linux/filter.h:628 [inline]
 bpf_prog_run include/linux/filter.h:635 [inline]
 __bpf_trace_run kernel/trace/bpf_trace.c:2046 [inline]
 bpf_trace_run2+0x110/0x340 kernel/trace/bpf_trace.c:2083
 __bpf_trace_contention_begin+0xb5/0xf0 include/trace/events/lock.h:95
 trace_contention_begin.constprop.0+0xda/0x1b0 include/trace/events/lock.h:95
 __pv_queued_spin_lock_slowpath+0x103/0xb50 kernel/locking/qspinlock.c:405
 pv_queued_spin_lock_slowpath arch/x86/include/asm/paravirt.h:591 [inline]
 queued_spin_lock_slowpath arch/x86/include/asm/qspinlock.h:51 [inline]
 queued_spin_lock include/asm-generic/qspinlock.h:114 [inline]
 do_raw_spin_lock+0x200/0x2a0 kernel/locking/spinlock_debug.c:115
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:111 [inline]
 _raw_spin_lock_irqsave+0x41/0x50 kernel/locking/spinlock.c:162
 ____bpf_trace_printk kernel/trace/bpf_trace.c:388 [inline]
 bpf_trace_printk+0xcf/0x170 kernel/trace/bpf_trace.c:374
 bpf_prog_0605f9f479290f07+0x2f/0x33
 bpf_dispatcher_nop_func include/linux/bpf.h:869 [inline]
 __bpf_prog_run include/linux/filter.h:628 [inline]
 bpf_prog_run include/linux/filter.h:635 [inline]
 __bpf_trace_run kernel/trace/bpf_trace.c:2046 [inline]
 bpf_trace_run2+0x110/0x340 kernel/trace/bpf_trace.c:2083
 __bpf_trace_contention_begin+0xb5/0xf0 include/trace/events/lock.h:95
 trace_contention_begin+0xc0/0x150 include/trace/events/lock.h:95
 __mutex_lock_common kernel/locking/mutex.c:605 [inline]
 __mutex_lock+0x13c/0x1350 kernel/locking/mutex.c:747
 uprobe_clear_state+0x47/0x420 kernel/events/uprobes.c:1544
 __mmput+0x73/0x4b0 kernel/fork.c:1183
 mmput+0x56/0x60 kernel/fork.c:1208
 exit_mm kernel/exit.c:510 [inline]
 do_exit+0xa12/0x2a00 kernel/exit.c:782
 do_group_exit+0xd2/0x2f0 kernel/exit.c:925
 __do_sys_exit_group kernel/exit.c:936 [inline]
 __se_sys_exit_group kernel/exit.c:934 [inline]
 __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:934
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x46/0xb0
RIP: 0033:0x7f15c46e1139
Code: Unable to access opcode bytes at RIP 0x7f15c46e110f.
RSP: 002b:00007ffd3b43d738 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007f15c475c330 RCX: 00007f15c46e1139
RDX: 000000000000003c RSI: 00000000000000e7 RDI: 0000000000000000
RBP: 0000000000000000 R08: ffffffffffffffc0 R09: 00007f15c4756ec0
R10: 00007ffd3b43d200 R11: 0000000000000246 R12: 00007f15c475c330
R13: 0000000000000001 R14: 0000000000000000 R15: 0000000000000001
 </TASK>

Crashes (9):
Manager Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Title
ci-upstream-bpf-kasan-gce 2022/06/09 00:39 bpf d678cbd2f867 b2706118 .config log report syz C possible deadlock in bpf_trace_printk
ci-upstream-net-this-kasan-gce 2022/06/09 00:08 net f5826c8c9d57 b2706118 .config log report syz C possible deadlock in bpf_trace_printk
ci-upstream-net-kasan-gce 2022/06/09 01:27 net-next da6e113ff010 b2706118 .config log report syz C possible deadlock in bpf_trace_printk
ci-upstream-bpf-next-kasan-gce 2022/06/09 00:44 bpf-next d352bd889b6a b2706118 .config log report syz C possible deadlock in bpf_trace_printk
ci-upstream-kasan-gce-selinux-root 2022/06/21 09:20 upstream 78ca55889a54 0fc5c330 .config log report info possible deadlock in bpf_trace_printk
ci-upstream-kasan-gce-smack-root 2022/06/16 07:10 upstream 979086f5e006 1719ee24 .config log report info possible deadlock in bpf_trace_printk
ci-upstream-kasan-gce-root 2022/06/11 00:24 upstream 874c8ca1e60b 0d5abf15 .config log report info possible deadlock in bpf_trace_printk
ci-upstream-net-this-kasan-gce 2022/06/18 02:38 net b4a028c4d031 cb58b3b2 .config log report info possible deadlock in bpf_trace_printk
ci-upstream-net-this-kasan-gce 2022/06/08 23:38 net f5826c8c9d57 b2706118 .config log report info possible deadlock in bpf_trace_printk