[v5.15] possible deadlock in bpf_trace_run3

1 view
Skip to first unread message

syzbot

unread,
Dec 6, 2023, 5:14:27 AM12/6/23
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 9b91d36ba301 Linux 5.15.141
git tree: linux-5.15.y
console output: https://syzkaller.appspot.com/x/log.txt?x=14142ed4e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=31f4c22724493853
dashboard link: https://syzkaller.appspot.com/bug?extid=c91e55dbe9697e42023e
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/5fc81554d3d4/disk-9b91d36b.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/191387cf41a2/vmlinux-9b91d36b.xz
kernel image: https://storage.googleapis.com/syzbot-assets/8d074d8a66a4/bzImage-9b91d36b.xz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+c91e55...@syzkaller.appspotmail.com

------------[ cut here ]------------
======================================================
WARNING: possible circular locking dependency detected
5.15.141-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.4/25823 is trying to acquire lock:
ffffffff8c7fb938 ((console_sem).lock){-.-.}-{2:2}, at: down_trylock+0x1c/0xa0 kernel/locking/semaphore.c:138

but task is already holding lock:
ffffffff8c975ef8 (trace_printk_lock){....}-{2:2}, at: ____bpf_trace_printk kernel/trace/bpf_trace.c:382 [inline]
ffffffff8c975ef8 (trace_printk_lock){....}-{2:2}, at: bpf_trace_printk+0x161/0x3d0 kernel/trace/bpf_trace.c:368

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (trace_printk_lock){....}-{2:2}:
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
_raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
____bpf_trace_printk kernel/trace/bpf_trace.c:382 [inline]
bpf_trace_printk+0x161/0x3d0 kernel/trace/bpf_trace.c:368
0xffffffffa001836b
bpf_dispatcher_nop_func include/linux/bpf.h:776 [inline]
__bpf_prog_run include/linux/filter.h:625 [inline]
bpf_prog_run include/linux/filter.h:632 [inline]
__bpf_trace_run kernel/trace/bpf_trace.c:1883 [inline]
bpf_trace_run3+0x1d1/0x380 kernel/trace/bpf_trace.c:1921
__traceiter_sched_switch+0x7d/0xb0 include/trace/events/sched.h:220
trace_sched_switch include/trace/events/sched.h:220 [inline]
__schedule+0x1e8d/0x45b0 kernel/sched/core.c:6373
preempt_schedule_common+0x83/0xd0 kernel/sched/core.c:6552
preempt_schedule+0xd9/0xe0 kernel/sched/core.c:6577
preempt_schedule_thunk+0x16/0x18 arch/x86/entry/thunk_64.S:34
try_to_wake_up+0x8a8/0x1300 kernel/sched/core.c:4152
wake_up_process kernel/sched/core.c:4215 [inline]
wake_up_q+0x8b/0xd0 kernel/sched/core.c:950
futex_wake+0x607/0x750 kernel/futex/core.c:1702
do_futex+0x1394/0x1810 kernel/futex/core.c:3987
__do_sys_futex kernel/futex/core.c:4059 [inline]
__se_sys_futex+0x407/0x490 kernel/futex/core.c:4040
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

-> #2 (&rq->__lock){-.-.}-{2:2}:
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
_raw_spin_lock_nested+0x2d/0x40 kernel/locking/spinlock.c:368
raw_spin_rq_lock_nested+0x26/0x140 kernel/sched/core.c:475
raw_spin_rq_lock kernel/sched/sched.h:1326 [inline]
rq_lock kernel/sched/sched.h:1621 [inline]
task_fork_fair+0x5d/0x350 kernel/sched/fair.c:11480
sched_cgroup_fork+0x2d3/0x330 kernel/sched/core.c:4466
copy_process+0x224a/0x3ef0 kernel/fork.c:2320
kernel_clone+0x210/0x960 kernel/fork.c:2604
kernel_thread+0x168/0x1e0 kernel/fork.c:2656
rest_init+0x21/0x330 init/main.c:703
start_kernel+0x48c/0x535 init/main.c:1137
secondary_startup_64_no_verify+0xb1/0xbb

-> #1 (&p->pi_lock){-.-.}-{2:2}:
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
_raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
try_to_wake_up+0xae/0x1300 kernel/sched/core.c:4030
up+0x6e/0x90 kernel/locking/semaphore.c:190
__up_console_sem+0x11a/0x1e0 kernel/printk/printk.c:256
console_unlock+0x1145/0x12b0 kernel/printk/printk.c:2754
vprintk_emit+0xbf/0x150 kernel/printk/printk.c:2268
dev_vprintk_emit+0x2aa/0x323 drivers/base/core.c:4595
dev_printk_emit+0xd9/0x118 drivers/base/core.c:4606
_dev_info+0x11e/0x165 drivers/base/core.c:4664
ath9k_hif_usb_disconnect+0x1c7/0x240 drivers/net/wireless/ath/ath9k/hif_usb.c:1457
usb_unbind_interface+0x1cd/0x840 drivers/usb/core/driver.c:458
__device_release_driver drivers/base/dd.c:1229 [inline]
device_release_driver_internal+0x50e/0x7f0 drivers/base/dd.c:1262
bus_remove_device+0x2e5/0x400 drivers/base/bus.c:529
device_del+0x6e2/0xbd0 drivers/base/core.c:3582
usb_disable_device+0x3b8/0x840 drivers/usb/core/message.c:1414
usb_disconnect+0x33c/0x8c0 drivers/usb/core/hub.c:2239
hub_port_connect drivers/usb/core/hub.c:5281 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5577 [inline]
port_event drivers/usb/core/hub.c:5723 [inline]
hub_event+0x1d58/0x54c0 drivers/usb/core/hub.c:5805
process_one_work+0x8a1/0x10c0 kernel/workqueue.c:2310
worker_thread+0xaca/0x1280 kernel/workqueue.c:2457
kthread+0x3f6/0x4f0 kernel/kthread.c:319
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

-> #0 ((console_sem).lock){-.-.}-{2:2}:
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain+0x1649/0x5930 kernel/locking/lockdep.c:3788
__lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
_raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
down_trylock+0x1c/0xa0 kernel/locking/semaphore.c:138
__down_trylock_console_sem+0x105/0x250 kernel/printk/printk.c:239
console_trylock kernel/printk/printk.c:2569 [inline]
console_trylock_spinning+0x8a/0x3f0 kernel/printk/printk.c:1867
vprintk_emit+0xa6/0x150 kernel/printk/printk.c:2267
_printk+0xd1/0x111 kernel/printk/printk.c:2293
__warn_printk+0xad/0x120 kernel/panic.c:710
format_decode+0x12d2/0x1f10 lib/vsprintf.c:2662
bstr_printf+0x130/0x10c0 lib/vsprintf.c:3233
____bpf_trace_printk kernel/trace/bpf_trace.c:383 [inline]
bpf_trace_printk+0x191/0x3d0 kernel/trace/bpf_trace.c:368
bpf_prog_12183cdb1cd51dab+0x2e/0x80c
bpf_dispatcher_nop_func include/linux/bpf.h:776 [inline]
__bpf_prog_run include/linux/filter.h:625 [inline]
bpf_prog_run include/linux/filter.h:632 [inline]
bpf_test_run+0x3f4/0x8a0 net/bpf/test_run.c:119
bpf_prog_test_run_skb+0xb41/0x1420 net/bpf/test_run.c:663
bpf_prog_test_run+0x32f/0x3a0 kernel/bpf/syscall.c:3331
__sys_bpf+0x3ac/0x670 kernel/bpf/syscall.c:4632
__do_sys_bpf kernel/bpf/syscall.c:4718 [inline]
__se_sys_bpf kernel/bpf/syscall.c:4716 [inline]
__x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:4716
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb

other info that might help us debug this:

Chain exists of:
(console_sem).lock --> &rq->__lock --> trace_printk_lock

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(trace_printk_lock);
lock(&rq->__lock);
lock(trace_printk_lock);
lock((console_sem).lock);

*** DEADLOCK ***

2 locks held by syz-executor.4/25823:
#0: ffffffff8c91f0e0 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire+0x9/0x30 include/linux/rcupdate.h:269
#1: ffffffff8c975ef8 (trace_printk_lock){....}-{2:2}, at: ____bpf_trace_printk kernel/trace/bpf_trace.c:382 [inline]
#1: ffffffff8c975ef8 (trace_printk_lock){....}-{2:2}, at: bpf_trace_printk+0x161/0x3d0 kernel/trace/bpf_trace.c:368

stack backtrace:
CPU: 0 PID: 25823 Comm: syz-executor.4 Not tainted 5.15.141-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/10/2023
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
check_noncircular+0x2f8/0x3b0 kernel/locking/lockdep.c:2133
check_prev_add kernel/locking/lockdep.c:3053 [inline]
check_prevs_add kernel/locking/lockdep.c:3172 [inline]
validate_chain+0x1649/0x5930 kernel/locking/lockdep.c:3788
__lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5012
lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
__raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
_raw_spin_lock_irqsave+0xd1/0x120 kernel/locking/spinlock.c:162
down_trylock+0x1c/0xa0 kernel/locking/semaphore.c:138
__down_trylock_console_sem+0x105/0x250 kernel/printk/printk.c:239
console_trylock kernel/printk/printk.c:2569 [inline]
console_trylock_spinning+0x8a/0x3f0 kernel/printk/printk.c:1867
vprintk_emit+0xa6/0x150 kernel/printk/printk.c:2267
_printk+0xd1/0x111 kernel/printk/printk.c:2293
__warn_printk+0xad/0x120 kernel/panic.c:710
format_decode+0x12d2/0x1f10 lib/vsprintf.c:2662
bstr_printf+0x130/0x10c0 lib/vsprintf.c:3233
____bpf_trace_printk kernel/trace/bpf_trace.c:383 [inline]
bpf_trace_printk+0x191/0x3d0 kernel/trace/bpf_trace.c:368
bpf_prog_12183cdb1cd51dab+0x2e/0x80c
bpf_dispatcher_nop_func include/linux/bpf.h:776 [inline]
__bpf_prog_run include/linux/filter.h:625 [inline]
bpf_prog_run include/linux/filter.h:632 [inline]
bpf_test_run+0x3f4/0x8a0 net/bpf/test_run.c:119
bpf_prog_test_run_skb+0xb41/0x1420 net/bpf/test_run.c:663
bpf_prog_test_run+0x32f/0x3a0 kernel/bpf/syscall.c:3331
__sys_bpf+0x3ac/0x670 kernel/bpf/syscall.c:4632
__do_sys_bpf kernel/bpf/syscall.c:4718 [inline]
__se_sys_bpf kernel/bpf/syscall.c:4716 [inline]
__x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:4716
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7fac67d53ae9
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:00007fac662d50c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007fac67e72f80 RCX: 00007fac67d53ae9
RDX: 0000000000000028 RSI: 0000000020000080 RDI: 000000000000000a
RBP: 00007fac67d9f47a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007fac67e72f80 R15: 00007ffc37dce2d8
</TASK>
Please remove unsupported % in format string
WARNING: CPU: 0 PID: 25823 at lib/vsprintf.c:2662 format_decode+0x12d2/0x1f10 lib/vsprintf.c:2662
Modules linked in:
CPU: 0 PID: 25823 Comm: syz-executor.4 Not tainted 5.15.141-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/10/2023
RIP: 0010:format_decode+0x12d2/0x1f10 lib/vsprintf.c:2662
Code: a4 09 01 48 b8 00 00 00 00 00 fc ff df 41 0f b6 04 07 84 c0 0f 85 30 0c 00 00 41 0f be 36 48 c7 c7 20 a3 db 8a e8 3e 95 1f fd <0f> 0b e9 01 fa ff ff 48 8b 4c 24 18 80 e1 07 38 c1 0f 8c e3 ed ff
RSP: 0018:ffffc900030376e0 EFLAGS: 00010046
RAX: d7fa552b8f942b00 RBX: 00000000ffffffdb RCX: 0000000000040000
RDX: ffffc9000e113000 RSI: 000000000003ffff RDI: 0000000000040000
RBP: ffffc900030377d0 R08: ffffffff81665b7c R09: ffffed1017344f24
R10: 0000000000000000 R11: dffffc0000000001 R12: ffff0a00ffffff00
R13: ffff0000ffffff00 R14: ffffc900030379ec R15: 1ffff92000606f3d
FS: 00007fac662d56c0(0000) GS:ffff8880b9a00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b2e721000 CR3: 000000009812a000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
bstr_printf+0x130/0x10c0 lib/vsprintf.c:3233
____bpf_trace_printk kernel/trace/bpf_trace.c:383 [inline]
bpf_trace_printk+0x191/0x3d0 kernel/trace/bpf_trace.c:368
bpf_prog_12183cdb1cd51dab+0x2e/0x80c
bpf_dispatcher_nop_func include/linux/bpf.h:776 [inline]
__bpf_prog_run include/linux/filter.h:625 [inline]
bpf_prog_run include/linux/filter.h:632 [inline]
bpf_test_run+0x3f4/0x8a0 net/bpf/test_run.c:119
bpf_prog_test_run_skb+0xb41/0x1420 net/bpf/test_run.c:663
bpf_prog_test_run+0x32f/0x3a0 kernel/bpf/syscall.c:3331
__sys_bpf+0x3ac/0x670 kernel/bpf/syscall.c:4632
__do_sys_bpf kernel/bpf/syscall.c:4718 [inline]
__se_sys_bpf kernel/bpf/syscall.c:4716 [inline]
__x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:4716
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7fac67d53ae9
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:00007fac662d50c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007fac67e72f80 RCX: 00007fac67d53ae9
RDX: 0000000000000028 RSI: 0000000020000080 RDI: 000000000000000a
RBP: 00007fac67d9f47a R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007fac67e72f80 R15: 00007ffc37dce2d8
</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 syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup
Reply all
Reply to author
Forward
0 new messages