syzbot


possible deadlock in sk_psock_drop

Status: auto-obsoleted due to no activity on 2024/09/19 18:21
Reported-by: syzbot+6c8e098e6c1c4ec2d039@syzkaller.appspotmail.com
First crash: 198d, last: 177d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 possible deadlock in sk_psock_drop 3 173d 223d 0/3 auto-obsoleted due to no activity on 2024/09/23 18:07
upstream possible deadlock in sk_psock_drop bpf net 56 178d 254d 0/28 auto-obsoleted due to no activity on 2024/08/19 14:36

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

but task is already holding lock:
ffff888027d49168 (&htab->buckets[i].lock){+.-.}-{2:2}, at: sock_hash_delete_elem+0x177/0x400 net/core/sock_map.c:938

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&htab->buckets[i].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_hash_delete_elem+0x177/0x400 net/core/sock_map.c:938
       0xffffffffa0000833
       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
       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_verdict net/core/skmsg.c:1239 [inline]
       sk_psock_drop+0x243/0x500 net/core/skmsg.c:842
       sk_psock_put include/linux/skmsg.h:454 [inline]
       sock_map_close+0x205/0x2d0 net/core/sock_map.c:1638
       unix_release+0x7e/0xc0 net/unix/af_unix.c:1038
       __sock_release net/socket.c:654 [inline]
       sock_close+0xcd/0x230 net/socket.c:1400
       __fput+0x3b7/0x890 fs/file_table.c:320
       task_work_run+0x246/0x300 kernel/task_work.c:179
       resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
       exit_to_user_mode_loop+0xde/0x100 kernel/entry/common.c:177
       exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:210
       __syscall_exit_to_user_mode_work kernel/entry/common.c:292 [inline]
       syscall_exit_to_user_mode+0x60/0x270 kernel/entry/common.c:303
       do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:87
       entry_SYSCALL_64_after_hwframe+0x68/0xd2

-> #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_hash_delete_elem+0x388/0x400 net/core/sock_map.c:942
       map_delete_elem+0x3ff/0x550 kernel/bpf/syscall.c:1501
       __sys_bpf+0x350/0x6c0 kernel/bpf/syscall.c:4996
       __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(&htab->buckets[i].lock);
                               lock(clock-AF_UNIX);
                               lock(&htab->buckets[i].lock);
  lock(clock-AF_UNIX);

 *** DEADLOCK ***

2 locks held by syz-executor.0/5157:
 #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: map_delete_elem+0x321/0x550 kernel/bpf/syscall.c:1500
 #1: ffff888027d49168 (&htab->buckets[i].lock){+.-.}-{2:2}, at: sock_hash_delete_elem+0x177/0x400 net/core/sock_map.c:938

stack backtrace:
CPU: 0 PID: 5157 Comm: syz-executor.0 Not tainted 6.1.92-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_hash_delete_elem+0x388/0x400 net/core/sock_map.c:942
 map_delete_elem+0x3ff/0x550 kernel/bpf/syscall.c:1501
 __sys_bpf+0x350/0x6c0 kernel/bpf/syscall.c:4996
 __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:0x7f022fe7cea9
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:00007f0230c0f0c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
RAX: ffffffffffffffda RBX: 00007f022ffb3f80 RCX: 00007f022fe7cea9
RDX: 0000000000000020 RSI: 00000000200000c0 RDI: 0000000000000003
RBP: 00007f022feebff4 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 000000000000000b R14: 00007f022ffb3f80 R15: 00007fff14c60098
 </TASK>

Crashes (3):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/06/11 18:21 linux-6.1.y 88690811da69 4d75f4f7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-perf possible deadlock in sk_psock_drop
2024/06/10 16:17 linux-6.1.y 88690811da69 048c640a .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-perf possible deadlock in sk_psock_drop
2024/05/22 11:00 linux-6.1.y 4078fa637fcd 4d098039 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-perf possible deadlock in sk_psock_drop
* Struck through repros no longer work on HEAD.