syzbot


possible deadlock in sock_map_unref

Status: auto-obsoleted due to no activity on 2024/09/22 19:42
Reported-by: syzbot+10c6083a9bdc03c0012f@syzkaller.appspotmail.com
First crash: 159d, last: 159d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in sock_map_unref bpf net 9 188d 226d 0/28 auto-obsoleted due to no activity on 2024/08/25 04:20

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
5.15.160-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.1/8250 is trying to acquire lock:
ffff8880155af3d8 (clock-AF_UNIX){++..}-{2:2}, at: sock_map_del_link net/core/sock_map.c:165 [inline]
ffff8880155af3d8 (clock-AF_UNIX){++..}-{2:2}, at: sock_map_unref+0x442/0x5d0 net/core/sock_map.c:182

but task is already holding lock:
ffff88807a8701c0 (&stab->lock){+.-.}-{2:2}, at: sock_map_update_common+0x1b6/0x5b0 net/core/sock_map.c:495

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&stab->lock){+.-.}-{2:2}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5623
       __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [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
       0xffffffffa0032856
       bpf_dispatcher_nop_func include/linux/bpf.h:790 [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:1880 [inline]
       bpf_trace_run2+0x19e/0x340 kernel/trace/bpf_trace.c:1917
       __bpf_trace_kfree+0x6e/0x90 include/trace/events/kmem.h:118
       trace_kfree include/trace/events/kmem.h:118 [inline]
       kfree+0x22f/0x270 mm/slub.c:4549
       __bpf_prog_put_noref+0x9c/0x2b0 kernel/bpf/syscall.c:1796
       bpf_prog_put_deferred+0x2ee/0x3e0 kernel/bpf/syscall.c:1822
       __bpf_prog_put kernel/bpf/syscall.c:1834 [inline]
       bpf_prog_put+0x260/0x2a0 kernel/bpf/syscall.c:1841
       psock_set_prog include/linux/skmsg.h:477 [inline]
       sk_psock_stop_verdict net/core/skmsg.c:1234 [inline]
       sk_psock_drop+0x243/0x500 net/core/skmsg.c:830
       sk_psock_put include/linux/skmsg.h:459 [inline]
       sock_map_close+0x1d4/0x290 net/core/sock_map.c:1581
       unix_release+0x7e/0xc0 net/unix/af_unix.c:949
       __sock_release net/socket.c:649 [inline]
       sock_close+0xcd/0x230 net/socket.c:1336
       __fput+0x3bf/0x890 fs/file_table.c:280
       task_work_run+0x129/0x1a0 kernel/task_work.c:164
       tracehook_notify_resume include/linux/tracehook.h:189 [inline]
       exit_to_user_mode_loop+0x106/0x130 kernel/entry/common.c:181
       exit_to_user_mode_prepare+0xb1/0x140 kernel/entry/common.c:214
       __syscall_exit_to_user_mode_work kernel/entry/common.c:296 [inline]
       syscall_exit_to_user_mode+0x5d/0x240 kernel/entry/common.c:307
       do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:86
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

-> #0 (clock-AF_UNIX){++..}-{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_write_lock_bh include/linux/rwlock_api_smp.h:203 [inline]
       _raw_write_lock_bh+0x31/0x40 kernel/locking/spinlock.c:324
       sock_map_del_link net/core/sock_map.c:165 [inline]
       sock_map_unref+0x442/0x5d0 net/core/sock_map.c:182
       sock_map_update_common+0x4ec/0x5b0 net/core/sock_map.c:508
       sock_map_update_elem_sys+0x440/0x770 net/core/sock_map.c:588
       map_update_elem+0x6a0/0x7c0 kernel/bpf/syscall.c:1185
       __sys_bpf+0x2fd/0x670 kernel/bpf/syscall.c:4639
       __do_sys_bpf kernel/bpf/syscall.c:4755 [inline]
       __se_sys_bpf kernel/bpf/syscall.c:4753 [inline]
       __x64_sys_bpf+0x78/0x90 kernel/bpf/syscall.c:4753
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x66/0xd0

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 ***

3 locks held by syz-executor.1/8250:
 #0: ffff8880155af120 (sk_lock-AF_UNIX){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1668 [inline]
 #0: ffff8880155af120 (sk_lock-AF_UNIX){+.+.}-{0:0}, at: sock_map_sk_acquire net/core/sock_map.c:119 [inline]
 #0: ffff8880155af120 (sk_lock-AF_UNIX){+.+.}-{0:0}, at: sock_map_update_elem_sys+0x1c8/0x770 net/core/sock_map.c:584
 #1: ffffffff8c91fae0 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire+0x5/0x30 include/linux/rcupdate.h:311
 #2: ffff88807a8701c0 (&stab->lock){+.-.}-{2:2}, at: sock_map_update_common+0x1b6/0x5b0 net/core/sock_map.c:495

stack backtrace:
CPU: 0 PID: 8250 Comm: syz-executor.1 Not tainted 5.15.160-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2d0 lib/dump_stack.c:106

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/06/14 19:41 linux-5.15.y c61bd26ae81a f429ab00 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf possible deadlock in sock_map_unref
* Struck through repros no longer work on HEAD.