[v6.1] possible deadlock in sk_psock_drop

0 views
Skip to first unread message

syzbot

unread,
May 22, 2024, 7:01:35 AMMay 22
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 4078fa637fcd Linux 6.1.91
git tree: linux-6.1.y
console output: https://syzkaller.appspot.com/x/log.txt?x=17975072980000
kernel config: https://syzkaller.appspot.com/x/.config?x=715ba80acfd3def4
dashboard link: https://syzkaller.appspot.com/bug?extid=6c8e098e6c1c4ec2d039
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/20c616b95c1f/disk-4078fa63.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/78c98fa5c5a9/vmlinux-4078fa63.xz
kernel image: https://storage.googleapis.com/syzbot-assets/5dcdafdbe940/bzImage-4078fa63.xz

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

======================================================
WARNING: possible circular locking dependency detected
6.1.91-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.3/8741 is trying to acquire lock:
ffff888043807bb8 (clock-AF_UNIX){+...}-{2:2}, at: sk_psock_drop+0x30/0x500 net/core/skmsg.c:836

but task is already holding lock:
ffff888078858a40 (&stab->lock){+.-.}-{2:2}, at: __sock_map_delete net/core/sock_map.c:419 [inline]
ffff888078858a40 (&stab->lock){+.-.}-{2:2}, at: sock_map_delete_elem+0x161/0x230 net/core/sock_map.c:451

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&stab->lock){+.-.}-{2:2}:
lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5662
__raw_spin_lock_bh include/linux/spinlock_api_smp.h:126 [inline]
_raw_spin_lock_bh+0x31/0x40 kernel/locking/spinlock.c:178
__sock_map_delete net/core/sock_map.c:419 [inline]
sock_map_delete_elem+0x161/0x230 net/core/sock_map.c:451
0xffffffffa0000a70
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
__bpf_trace_kfree+0x6e/0x90 include/trace/events/kmem.h:94
__traceiter_kfree+0x26/0x40 include/trace/events/kmem.h:94
trace_kfree include/trace/events/kmem.h:94 [inline]
kfree+0xf6/0x190 mm/slab_common.c:994
__bpf_prog_put_noref+0x9c/0x2b0 kernel/bpf/syscall.c:2059
bpf_prog_put_deferred+0x2ee/0x3e0 kernel/bpf/syscall.c:2085
__bpf_prog_put kernel/bpf/syscall.c:2097 [inline]
bpf_prog_put+0x260/0x2a0 kernel/bpf/syscall.c:2104
psock_set_prog include/linux/skmsg.h:472 [inline]
sk_psock_stop_strp net/core/skmsg.c:1153 [inline]
sk_psock_drop+0xd6/0x500 net/core/skmsg.c:840
sock_map_free+0x1e3/0x3d0 net/core/sock_map.c:353
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:308

-> #0 (clock-AF_UNIX){+...}-{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_write_lock_bh include/linux/rwlock_api_smp.h:202 [inline]
_raw_write_lock_bh+0x31/0x40 kernel/locking/spinlock.c:334
sk_psock_drop+0x30/0x500 net/core/skmsg.c:836
__sock_map_delete net/core/sock_map.c:425 [inline]
sock_map_delete_elem+0x191/0x230 net/core/sock_map.c:451
bpf_prog_107af3efe6330ca3+0x3a/0x3e
bpf_dispatcher_nop_func include/linux/bpf.h:989 [inline]
__bpf_prog_run include/linux/filter.h:596 [inline]
bpf_prog_run include/linux/filter.h:610 [inline]
__bpf_trace_run kernel/trace/bpf_trace.c:2273 [inline]
bpf_trace_run10+0x475/0x520 kernel/trace/bpf_trace.c:2320
__bpf_trace_percpu_alloc_percpu+0x4a/0x60 include/trace/events/percpu.h:11
trace_percpu_alloc_percpu include/trace/events/percpu.h:11 [inline]
pcpu_alloc+0x16d9/0x18f0 mm/percpu.c:1887
bpf_prog_alloc_no_stats+0xd5/0x3f0 kernel/bpf/core.c:101
bpf_prog_alloc+0x1c/0x1b0 kernel/bpf/core.c:130
bpf_prog_load+0x803/0x1bb0 kernel/bpf/syscall.c:2577
__sys_bpf+0x382/0x6c0 kernel/bpf/syscall.c:5005
__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(&stab->lock);
lock(clock-AF_UNIX);
lock(&stab->lock);
lock(clock-AF_UNIX);

*** DEADLOCK ***

2 locks held by syz-executor.3/8741:
#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_trace_run kernel/trace/bpf_trace.c:2272 [inline]
#0: ffffffff8d12ac80 (rcu_read_lock){....}-{1:2}, at: bpf_trace_run10+0x248/0x520 kernel/trace/bpf_trace.c:2320
#1: ffff888078858a40 (&stab->lock){+.-.}-{2:2}, at: __sock_map_delete net/core/sock_map.c:419 [inline]
#1: ffff888078858a40 (&stab->lock){+.-.}-{2:2}, at: sock_map_delete_elem+0x161/0x230 net/core/sock_map.c:451

stack backtrace:
CPU: 1 PID: 8741 Comm: syz-executor.3 Not tainted 6.1.91-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_write_lock_bh include/linux/rwlock_api_smp.h:202 [inline]
_raw_write_lock_bh+0x31/0x40 kernel/locking/spinlock.c:334
sk_psock_drop+0x30/0x500 net/core/skmsg.c:836
__sock_map_delete net/core/sock_map.c:425 [inline]
sock_map_delete_elem+0x191/0x230 net/core/sock_map.c:451
bpf_prog_107af3efe6330ca3+0x3a/0x3e
bpf_dispatcher_nop_func include/linux/bpf.h:989 [inline]
__bpf_prog_run include/linux/filter.h:596 [inline]
bpf_prog_run include/linux/filter.h:610 [inline]
__bpf_trace_run kernel/trace/bpf_trace.c:2273 [inline]
bpf_trace_run10+0x475/0x520 kernel/trace/bpf_trace.c:2320
__bpf_trace_percpu_alloc_percpu+0x4a/0x60 include/trace/events/percpu.h:11
trace_percpu_alloc_percpu include/trace/events/percpu.h:11 [inline]
pcpu_alloc+0x16d9/0x18f0 mm/percpu.c:1887
bpf_prog_alloc_no_stats+0xd5/0x3f0 kernel/bpf/core.c:101
bpf_prog_alloc+0x1c/0x1b0 kernel/bpf/core.c:130
bpf_prog_load+0x803/0x1bb0 kernel/bpf/syscall.c:2577
__sys_bpf+0x382/0x6c0 kernel/bpf/syscall.c:5005
__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:0x7efefc47cee9
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:00007efefd1490c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007efefc5abf80 RCX: 00007efefc47cee9
RDX: 0000000000000090 RSI: 00000000200000c0 RDI: 0000000000000005
RBP: 00007efefc4c949e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007efefc5abf80 R15: 00007fff76343f88
</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