syzbot


possible deadlock in j1939_sk_queue_drop_all

Status: upstream: reported C repro on 2023/07/29 10:09
Bug presence: origin:upstream
Labels: missing-backport
[Documentation on labels]
Reported-by: syzbot+8775a462e4c43abd602f@syzkaller.appspotmail.com
First crash: 278d, last: 2d12h
Bug presence (3)
Date Name Commit Repro Result
2023/09/12 linux-5.15.y (ToT) aff03380bda4 C [report] possible deadlock in j1939_session_activate
2023/07/29 upstream (ToT) ffabf7c73176 C [report] possible deadlock in j1939_session_activate
2023/09/12 upstream (ToT) 3669558bdf35 C Didn't crash
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-6.1 possible deadlock in j1939_sk_queue_drop_all (2) origin:upstream missing-backport C unreliable 2 69d 230d 0/3 upstream: reported C repro on 2023/09/15 19:47
linux-6.1 possible deadlock in j1939_sk_queue_drop_all 1 332d 332d 0/3 auto-obsoleted due to no activity on 2023/09/13 10:57
upstream possible deadlock in j1939_sk_queue_drop_all can C error done 281 94d 967d 26/26 fixed on 2024/03/26 17:39
Fix bisection attempts (6)
Created Duration User Patch Repo Result
2024/04/30 08:53 2h20m bisect fix linux-5.15.y job log (0) log
2024/03/30 01:16 3h31m bisect fix linux-5.15.y job log (0) log
2024/02/28 11:50 1h48m bisect fix linux-5.15.y job log (0) log
2024/01/04 03:30 1h13m bisect fix linux-5.15.y job log (0) log
2023/12/04 04:33 1h04m bisect fix linux-5.15.y job log (0) log
2023/09/21 20:44 1h13m fix candidate upstream job log (0) log

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
5.15.123-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor317/3557 is trying to acquire lock:
ffff888077bb35d0 (&jsk->sk_session_queue_lock){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:368 [inline]
ffff888077bb35d0 (&jsk->sk_session_queue_lock){+.-.}-{2:2}, at: j1939_sk_queue_drop_all+0x3a/0x240 net/can/j1939/socket.c:139

but task is already holding lock:
ffff888022f750d0 (&priv->j1939_socks_lock){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:368 [inline]
ffff888022f750d0 (&priv->j1939_socks_lock){+.-.}-{2:2}, at: j1939_sk_netdev_event_netdown+0x2d/0x150 net/can/j1939/socket.c:1274

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&priv->j1939_socks_lock){+.-.}-{2:2}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622
       __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline]
       _raw_spin_lock_bh+0x31/0x40 kernel/locking/spinlock.c:178
       spin_lock_bh include/linux/spinlock.h:368 [inline]
       j1939_sk_errqueue+0x92/0x140 net/can/j1939/socket.c:1081
       __j1939_session_release net/can/j1939/transport.c:294 [inline]
       kref_put include/linux/kref.h:65 [inline]
       j1939_session_put+0x100/0x460 net/can/j1939/transport.c:299
       j1939_session_deactivate_locked net/can/j1939/transport.c:1086 [inline]
       j1939_cancel_active_session+0x350/0x480 net/can/j1939/transport.c:2194
       j1939_netdev_notify+0x201/0x2e0 net/can/j1939/main.c:376
       notifier_call_chain kernel/notifier.c:83 [inline]
       raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:391
       call_netdevice_notifiers_info net/core/dev.c:1998 [inline]
       call_netdevice_notifiers_extack net/core/dev.c:2010 [inline]
       call_netdevice_notifiers net/core/dev.c:2024 [inline]
       dev_close_many+0x37c/0x530 net/core/dev.c:1599
       unregister_netdevice_many+0x4b0/0x18f0 net/core/dev.c:11043
       rtnl_delete_link net/core/rtnetlink.c:3071 [inline]
       rtnl_dellink+0x4d5/0x7d0 net/core/rtnetlink.c:3123
       rtnetlink_rcv_msg+0x993/0xee0 net/core/rtnetlink.c:5599
       netlink_rcv_skb+0x1cf/0x410 net/netlink/af_netlink.c:2505
       netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
       netlink_unicast+0x7b6/0x980 net/netlink/af_netlink.c:1356
       netlink_sendmsg+0xa30/0xd60 net/netlink/af_netlink.c:1924
       sock_sendmsg_nosec net/socket.c:704 [inline]
       sock_sendmsg net/socket.c:724 [inline]
       ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2412
       ___sys_sendmsg+0x252/0x2e0 net/socket.c:2466
       __sys_sendmsg net/socket.c:2495 [inline]
       __do_sys_sendmsg net/socket.c:2504 [inline]
       __se_sys_sendmsg+0x19a/0x260 net/socket.c:2502
       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

-> #1 (&priv->active_session_list_lock){+.-.}-{2:2}:
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622
       __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline]
       _raw_spin_lock_bh+0x31/0x40 kernel/locking/spinlock.c:178
       spin_lock_bh include/linux/spinlock.h:368 [inline]
       j1939_session_list_lock net/can/j1939/transport.c:238 [inline]
       j1939_session_activate+0x4d/0x3d0 net/can/j1939/transport.c:1564
       j1939_sk_queue_activate_next_locked net/can/j1939/socket.c:181 [inline]
       j1939_sk_queue_activate_next+0x268/0x3e0 net/can/j1939/socket.c:208
       j1939_session_deactivate_activate_next net/can/j1939/transport.c:1108 [inline]
       j1939_session_completed net/can/j1939/transport.c:1222 [inline]
       j1939_xtp_rx_eoma_one net/can/j1939/transport.c:1395 [inline]
       j1939_xtp_rx_eoma+0x323/0x530 net/can/j1939/transport.c:1410
       j1939_tp_cmd_recv net/can/j1939/transport.c:2099 [inline]
       j1939_tp_recv+0x833/0x1000 net/can/j1939/transport.c:2144
       j1939_can_recv+0x6ab/0xa60 net/can/j1939/main.c:108
       deliver net/can/af_can.c:574 [inline]
       can_rcv_filter+0x349/0x7c0 net/can/af_can.c:608
       can_receive+0x2f2/0x430 net/can/af_can.c:665
       can_rcv+0x147/0x290 net/can/af_can.c:696
       __netif_receive_skb_one_core net/core/dev.c:5462 [inline]
       __netif_receive_skb+0x1c6/0x530 net/core/dev.c:5576
       process_backlog+0x363/0x7f0 net/core/dev.c:6453
       __napi_poll+0xc7/0x440 net/core/dev.c:7012
       napi_poll net/core/dev.c:7079 [inline]
       net_rx_action+0x617/0xda0 net/core/dev.c:7166
       __do_softirq+0x3b3/0x93a kernel/softirq.c:558
       run_ksoftirqd+0xc1/0x120 kernel/softirq.c:920
       smpboot_thread_fn+0x51b/0x9d0 kernel/smpboot.c:164
       kthread+0x3f6/0x4f0 kernel/kthread.c:319
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:298

-> #0 (&jsk->sk_session_queue_lock){+.-.}-{2:2}:
       check_prev_add kernel/locking/lockdep.c:3053 [inline]
       check_prevs_add kernel/locking/lockdep.c:3172 [inline]
       validate_chain+0x1646/0x58b0 kernel/locking/lockdep.c:3787
       __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5011
       lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622
       __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline]
       _raw_spin_lock_bh+0x31/0x40 kernel/locking/spinlock.c:178
       spin_lock_bh include/linux/spinlock.h:368 [inline]
       j1939_sk_queue_drop_all+0x3a/0x240 net/can/j1939/socket.c:139
       j1939_sk_netdev_event_netdown+0xe9/0x150 net/can/j1939/socket.c:1280
       j1939_netdev_notify+0x209/0x2e0 net/can/j1939/main.c:377
       notifier_call_chain kernel/notifier.c:83 [inline]
       raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:391
       call_netdevice_notifiers_info net/core/dev.c:1998 [inline]
       call_netdevice_notifiers_extack net/core/dev.c:2010 [inline]
       call_netdevice_notifiers net/core/dev.c:2024 [inline]
       dev_close_many+0x37c/0x530 net/core/dev.c:1599
       unregister_netdevice_many+0x4b0/0x18f0 net/core/dev.c:11043
       rtnl_delete_link net/core/rtnetlink.c:3071 [inline]
       rtnl_dellink+0x4d5/0x7d0 net/core/rtnetlink.c:3123
       rtnetlink_rcv_msg+0x993/0xee0 net/core/rtnetlink.c:5599
       netlink_rcv_skb+0x1cf/0x410 net/netlink/af_netlink.c:2505
       netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
       netlink_unicast+0x7b6/0x980 net/netlink/af_netlink.c:1356
       netlink_sendmsg+0xa30/0xd60 net/netlink/af_netlink.c:1924
       sock_sendmsg_nosec net/socket.c:704 [inline]
       sock_sendmsg net/socket.c:724 [inline]
       ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2412
       ___sys_sendmsg+0x252/0x2e0 net/socket.c:2466
       __sys_sendmsg net/socket.c:2495 [inline]
       __do_sys_sendmsg net/socket.c:2504 [inline]
       __se_sys_sendmsg+0x19a/0x260 net/socket.c:2502
       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:
  &jsk->sk_session_queue_lock --> &priv->active_session_list_lock --> &priv->j1939_socks_lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&priv->j1939_socks_lock);
                               lock(&priv->active_session_list_lock);
                               lock(&priv->j1939_socks_lock);
  lock(&jsk->sk_session_queue_lock);

 *** DEADLOCK ***

2 locks held by syz-executor317/3557:
 #0: ffffffff8d9e0688 (rtnl_mutex){+.+.}-{3:3}, at: rtnl_lock net/core/rtnetlink.c:72 [inline]
 #0: ffffffff8d9e0688 (rtnl_mutex){+.+.}-{3:3}, at: rtnetlink_rcv_msg+0x94c/0xee0 net/core/rtnetlink.c:5596
 #1: ffff888022f750d0 (&priv->j1939_socks_lock){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:368 [inline]
 #1: ffff888022f750d0 (&priv->j1939_socks_lock){+.-.}-{2:2}, at: j1939_sk_netdev_event_netdown+0x2d/0x150 net/can/j1939/socket.c:1274

stack backtrace:
CPU: 0 PID: 3557 Comm: syz-executor317 Not tainted 5.15.123-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/12/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+0x1646/0x58b0 kernel/locking/lockdep.c:3787
 __lock_acquire+0x1295/0x1ff0 kernel/locking/lockdep.c:5011
 lock_acquire+0x1db/0x4f0 kernel/locking/lockdep.c:5622
 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:135 [inline]
 _raw_spin_lock_bh+0x31/0x40 kernel/locking/spinlock.c:178
 spin_lock_bh include/linux/spinlock.h:368 [inline]
 j1939_sk_queue_drop_all+0x3a/0x240 net/can/j1939/socket.c:139
 j1939_sk_netdev_event_netdown+0xe9/0x150 net/can/j1939/socket.c:1280
 j1939_netdev_notify+0x209/0x2e0 net/can/j1939/main.c:377
 notifier_call_chain kernel/notifier.c:83 [inline]
 raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:391
 call_netdevice_notifiers_info net/core/dev.c:1998 [inline]
 call_netdevice_notifiers_extack net/core/dev.c:2010 [inline]
 call_netdevice_notifiers net/core/dev.c:2024 [inline]
 dev_close_many+0x37c/0x530 net/core/dev.c:1599
 unregister_netdevice_many+0x4b0/0x18f0 net/core/dev.c:11043
 rtnl_delete_link net/core/rtnetlink.c:3071 [inline]
 rtnl_dellink+0x4d5/0x7d0 net/core/rtnetlink.c:3123
 rtnetlink_rcv_msg+0x993/0xee0 net/core/rtnetlink.c:5599
 netlink_rcv_skb+0x1cf/0x410 net/netlink/af_netlink.c:2505
 netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
 netlink_unicast+0x7b6/0x980 net/netlink/af_netlink.c:1356
 netlink_sendmsg+0xa30/0xd60 net/netlink/af_netlink.c:1924
 sock_sendmsg_nosec net/socket.c:704 [inline]
 sock_sendmsg net/socket.c:724 [inline]
 ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2412
 ___sys_sendmsg+0x252/0x2e0 net/socket.c:2466
 __sys_sendmsg net/socket.c:2495 [inline]
 __do_sys_sendmsg net/socket.c:2504 [inline]
 __se_sys_sendmsg+0x19a/0x260 net/socket.c:2502
 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:0x7fafeca77a59
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 d1 19 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe003670a8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fafeca77a59
RDX: 0000000000000000 RSI: 00000000200002c0 RDI: 0000000000000007
RBP: 00000000000f4240 R08: 0000000100000000 R09: 0000000100000000
R10: 0000000100000000 R11: 0000000000000246 R12: 00007ffe00367100
R13: 0000000000000001 R14: 00007ffe00367100 R15: 0000000000000003
 </TASK>

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/07/29 10:08 linux-5.15.y 09996673e313 92476829 .config console log report syz C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in j1939_sk_queue_drop_all
2024/01/19 16:17 linux-5.15.y ddcaf4999061 9bd8dcda .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in j1939_sk_queue_drop_all
2024/01/19 02:40 linux-5.15.y ddcaf4999061 21772ce4 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in j1939_sk_queue_drop_all
2024/01/18 13:26 linux-5.15.y ddcaf4999061 239abf84 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in j1939_sk_queue_drop_all
2024/01/18 10:09 linux-5.15.y ddcaf4999061 915053c7 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in j1939_sk_queue_drop_all
2023/11/02 23:36 linux-5.15.y 12952a23a5da c4ac074c .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in j1939_sk_queue_drop_all
2023/10/13 01:21 linux-5.15.y 02e21884dcf2 6388bc36 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in j1939_sk_queue_drop_all
* Struck through repros no longer work on HEAD.