Hello,
syzbot found the following issue on:
HEAD commit: d678cbd2f867 xsk: Fix handling of invalid descriptors in X..
git tree: bpf
console+strace: https://syzkaller.appspot.com/x/log.txt?x=15ea1120080000
kernel config: https://syzkaller.appspot.com/x/.config?x=fc5a30a131480a80
dashboard link: https://syzkaller.appspot.com/bug?extid=c49e17557ddb5725583d
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1342b1f7f00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15ca7880080000
The issue was bisected to:
commit dc1f7893a70fe403983bd8492f177bf993940e2c
Author: Peter Zijlstra <[email protected]>
Date: Wed Mar 30 11:06:54 2022 +0000
locking/mutex: Make contention tracepoints more consistent wrt adaptive spinning
bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=14c55dcff00000
final oops: https://syzkaller.appspot.com/x/report.txt?x=16c55dcff00000
console output: https://syzkaller.appspot.com/x/log.txt?x=12c55dcff00000
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]
Fixes: dc1f7893a70f ("locking/mutex: Make contention tracepoints more consistent wrt adaptive spinning")
============================================
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>
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at [email protected].
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches
Hello,
syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING in bpf_bprintf_prepare
------------[ cut here ]------------
WARNING: CPU: 1 PID: 2971 at kernel/bpf/helpers.c:791 try_get_fmt_tmp_buf kernel/bpf/helpers.c:791 [inline]
WARNING: CPU: 1 PID: 2971 at kernel/bpf/helpers.c:791 bpf_bprintf_prepare+0xf31/0x11a0 kernel/bpf/helpers.c:839
Modules linked in:
CPU: 1 PID: 2971 Comm: udevd Not tainted 5.18.0-syzkaller-12122-gd678cbd2f867-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:try_get_fmt_tmp_buf kernel/bpf/helpers.c:791 [inline]
RIP: 0010:bpf_bprintf_prepare+0xf31/0x11a0 kernel/bpf/helpers.c:839
Code: ff e8 93 f8 ea ff 48 83 7c 24 08 00 41 bd 04 00 00 00 0f 85 8a fa ff ff e8 7c f8 ea ff 8d 6b 03 e9 f7 f6 ff ff e8 6f f8 ea ff <0f> 0b 65 ff 0d de b4 73 7e bf 01 00 00 00 41 bc f0 ff ff ff e8 16
RSP: 0018:ffffc90002d7e780 EFLAGS: 00010093
RAX: 0000000000000000 RBX: 0000000000000002 RCX: 0000000000000000
RDX: ffff88807dfabb00 RSI: ffffffff818f8be1 RDI: 0000000000000005
RBP: ffffc90002d7e8b8 R08: 0000000000000005 R09: 0000000000000003
R10: 0000000000000004 R11: 0000000000000001 R12: 0000000000000003
R13: 0000000000000004 R14: ffffc90002d7e970 R15: 0000000000000003
FS: 00007f17e75cf840(0000) GS:ffff8880b9b00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055a120075288 CR3: 000000001d494000 CR4: 00000000003506e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
____bpf_trace_printk kernel/trace/bpf_trace.c:385 [inline]
bpf_trace_printk+0x10d/0x260 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:2050 [inline]
bpf_trace_run2+0x110/0x340 kernel/trace/bpf_trace.c:2087
__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:390 [inline]
bpf_trace_printk+0x134/0x260 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:2050 [inline]
bpf_trace_run2+0x110/0x340 kernel/trace/bpf_trace.c:2087
__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:390 [inline]
bpf_trace_printk+0x134/0x260 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:2050 [inline]
bpf_trace_run2+0x110/0x340 kernel/trace/bpf_trace.c:2087
__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]
lockdep_lock kernel/locking/lockdep.c:143 [inline]
graph_lock kernel/locking/lockdep.c:169 [inline]
lookup_chain_cache_add kernel/locking/lockdep.c:3764 [inline]
validate_chain kernel/locking/lockdep.c:3797 [inline]
__lock_acquire+0x333f/0x5660 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:390 [inline]
bpf_trace_printk+0x134/0x260 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:2050 [inline]
bpf_trace_run2+0x110/0x340 kernel/trace/bpf_trace.c:2087
__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
kernfs_get_open_node fs/kernfs/file.c:524 [inline]
kernfs_fop_open+0x7e8/0xe00 fs/kernfs/file.c:693
do_dentry_open+0x4a1/0x11f0 fs/open.c:848
do_open fs/namei.c:3527 [inline]
path_openat+0x1c71/0x2910 fs/namei.c:3660
do_filp_open+0x1aa/0x400 fs/namei.c:3687
do_sys_openat2+0x16d/0x4c0 fs/open.c:1278
do_sys_open fs/open.c:1294 [inline]
__do_sys_openat fs/open.c:1310 [inline]
__se_sys_openat fs/open.c:1305 [inline]
__x64_sys_openat+0x13f/0x1f0 fs/open.c:1305
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:0x7f17e7125697
Code: 25 00 00 41 00 3d 00 00 41 00 74 37 64 8b 04 25 18 00 00 00 85 c0 75 5b 44 89 e2 48 89 ee bf 9c ff ff ff b8 01 01 00 00 0f 05 <48> 3d 00 f0 ff ff 0f 87 85 00 00 00 48 83 c4 68 5d 41 5c c3 0f 1f
RSP: 002b:00007ffcc7516d30 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 000055a11ff7ccc0 RCX: 00007f17e7125697
RDX: 0000000000080000 RSI: 00007ffcc7516e68 RDI: 00000000ffffff9c
RBP: 00007ffcc7516e68 R08: 0000000000000008 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000080000
R13: 000055a11ff7ccc0 R14: 0000000000000001 R15: 0000000000000000
</TASK>
Tested on:
commit: d678cbd2 xsk: Fix handling of invalid descriptors in X..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git
console output: https://syzkaller.appspot.com/x/log.txt?x=17515e73f00000
kernel config: https://syzkaller.appspot.com/x/.config?x=fc5a30a131480a80
dashboard link: https://syzkaller.appspot.com/bug?extid=c49e17557ddb5725583d
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=145a11bff00000
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-and-tested-by: [email protected]
Tested on:
commit: d678cbd2 xsk: Fix handling of invalid descriptors in X..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git
console output: https://syzkaller.appspot.com/x/log.txt?x=13743f27f00000
kernel config: https://syzkaller.appspot.com/x/.config?x=fc5a30a131480a80
dashboard link: https://syzkaller.appspot.com/bug?extid=c49e17557ddb5725583d
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=16922173f00000
Note: testing is done by a robot and is best-effort only.
syzbot suspects this issue was fixed by commit:
commit 05b24ff9b2cfabfcfd951daaa915a036ab53c9e1
Author: Jiri Olsa <[email protected]>
Date: Fri Sep 16 07:19:14 2022 +0000
bpf: Prevent bpf program recursion for raw tracepoint probes
bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=10a653d6c80000
start commit: a335366bad13 Merge tag 'gpio-fixes-for-v6.0-rc6' of git://..
git tree: upstream
kernel config: https://syzkaller.appspot.com/x/.config?x=9e66520f224211a2
dashboard link: https://syzkaller.appspot.com/bug?extid=c49e17557ddb5725583d
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16e27480880000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12737fbf080000
If the result looks correct, please mark the issue as fixed by replying with:
#syz fix: bpf: Prevent bpf program recursion for raw tracepoint probes
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
On Wed, 22 Mar 2023 at 10:29, syzbot
<[email protected]> wrote:
>
> syzbot suspects this issue was fixed by commit:
>
> commit 05b24ff9b2cfabfcfd951daaa915a036ab53c9e1
> Author: Jiri Olsa <[email protected]>
> Date: Fri Sep 16 07:19:14 2022 +0000
>
> bpf: Prevent bpf program recursion for raw tracepoint probes
>
> bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=10a653d6c80000
> start commit: a335366bad13 Merge tag 'gpio-fixes-for-v6.0-rc6' of git://..
> git tree: upstream
> kernel config: https://syzkaller.appspot.com/x/.config?x=9e66520f224211a2
> dashboard link: https://syzkaller.appspot.com/bug?extid=c49e17557ddb5725583d
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16e27480880000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12737fbf080000
>
> If the result looks correct, please mark the issue as fixed by replying with:
>
> #syz fix: bpf: Prevent bpf program recursion for raw tracepoint probes
>
> For information about bisection process see: https://goo.gl/tpsmEJ#bisection
Looks reasonable:
#syz fix: bpf: Prevent bpf program recursion for raw tracepoint probes
On Thu, Mar 23, 2023 at 08:50:10AM +0100, Dmitry Vyukov wrote:
> On Wed, 22 Mar 2023 at 10:29, syzbot
> <[email protected]> wrote:
> >
> > syzbot suspects this issue was fixed by commit:
> >
> > commit 05b24ff9b2cfabfcfd951daaa915a036ab53c9e1
> > Author: Jiri Olsa <[email protected]>
> > Date: Fri Sep 16 07:19:14 2022 +0000
> >
> > bpf: Prevent bpf program recursion for raw tracepoint probes
> >
> > bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=10a653d6c80000
> > start commit: a335366bad13 Merge tag 'gpio-fixes-for-v6.0-rc6' of git://..
> > git tree: upstream
> > kernel config: https://syzkaller.appspot.com/x/.config?x=9e66520f224211a2
> > dashboard link: https://syzkaller.appspot.com/bug?extid=c49e17557ddb5725583d
> > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16e27480880000
> > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12737fbf080000
> >
> > If the result looks correct, please mark the issue as fixed by replying with:
> >
> > #syz fix: bpf: Prevent bpf program recursion for raw tracepoint probes
> >
> > For information about bisection process see: https://goo.gl/tpsmEJ#bisection
>
> Looks reasonable:
>
> #syz fix: bpf: Prevent bpf program recursion for raw tracepoint probes
agreed, thanks
jirka