syzbot


possible deadlock in j1939_sk_queue_drop_all (2)

Status: upstream: reported C repro on 2023/09/15 19:47
Bug presence: origin:upstream
Labels: missing-backport
[Documentation on labels]
Reported-by: syzbot+96ac056233e7c92a41e6@syzkaller.appspotmail.com
First crash: 450d, last: 290d
Fix bisection: the issue occurs on the latest tested release (bisect log)
Crash: INFO: rcu detected stall in corrupted (log)
Repro: C syz .config
  
Bug presence (3)
Date Name Commit Repro Result
2024/03/14 linux-6.1.y (ToT) 61adba85cc40 C [report] INFO: rcu detected stall in corrupted
2023/09/15 upstream (ToT) 9608c7b729e2 C [report] possible deadlock in j1939_session_activate
2024/03/14 upstream (ToT) 480e035fc4c7 C Didn't crash
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 possible deadlock in j1939_sk_queue_drop_all origin:upstream missing-backport C 7 29d 499d 0/3 upstream: reported C repro on 2023/07/29 10:09
linux-6.1 possible deadlock in j1939_sk_queue_drop_all 1 553d 553d 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 315d 1188d 25/28 fixed on 2024/03/26 17:39
Fix bisection attempts (5)
Created Duration User Patch Repo Result
2024/03/22 21:16 7h22m fix candidate upstream OK (1) job log
2024/01/24 01:32 2h04m bisect fix linux-6.1.y OK (0) job log log
2023/12/24 22:19 2h21m bisect fix linux-6.1.y OK (0) job log log
2023/11/24 01:01 1h57m bisect fix linux-6.1.y OK (0) job log log
2023/10/20 06:48 1h47m bisect fix linux-6.1.y OK (0) job log log

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.1.53-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor410/3611 is trying to acquire lock:
ffff888073f1d5c8 (&jsk->sk_session_queue_lock){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:355 [inline]
ffff888073f1d5c8 (&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:
ffff8880738050d0 (&priv->j1939_socks_lock){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:355 [inline]
ffff8880738050d0 (&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+0x1f8/0x5a0 kernel/locking/lockdep.c:5661
       __raw_spin_lock_bh include/linux/spinlock_api_smp.h:126 [inline]
       _raw_spin_lock_bh+0x31/0x40 kernel/locking/spinlock.c:178
       spin_lock_bh include/linux/spinlock.h:355 [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:380
       notifier_call_chain kernel/notifier.c:87 [inline]
       raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:455
       call_netdevice_notifiers_info net/core/dev.c:1945 [inline]
       call_netdevice_notifiers_extack net/core/dev.c:1983 [inline]
       call_netdevice_notifiers net/core/dev.c:1997 [inline]
       dev_close_many+0x37c/0x530 net/core/dev.c:1545
       unregister_netdevice_many+0x4d0/0x1870 net/core/dev.c:10820
       rtnl_delete_link net/core/rtnetlink.c:3143 [inline]
       rtnl_dellink+0x4e1/0x880 net/core/rtnetlink.c:3194
       rtnetlink_rcv_msg+0x776/0xf00 net/core/rtnetlink.c:6124
       netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2525
       netlink_unicast_kernel net/netlink/af_netlink.c:1328 [inline]
       netlink_unicast+0x7bf/0x990 net/netlink/af_netlink.c:1354
       netlink_sendmsg+0xa26/0xd60 net/netlink/af_netlink.c:1903
       sock_sendmsg_nosec net/socket.c:716 [inline]
       sock_sendmsg net/socket.c:736 [inline]
       ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2482
       ___sys_sendmsg net/socket.c:2536 [inline]
       __sys_sendmsg+0x2a9/0x390 net/socket.c:2565
       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+0x63/0xcd

-> #1 (&priv->active_session_list_lock){+.-.}-{2:2}:
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5661
       __raw_spin_lock_bh include/linux/spinlock_api_smp.h:126 [inline]
       _raw_spin_lock_bh+0x31/0x40 kernel/locking/spinlock.c:178
       spin_lock_bh include/linux/spinlock.h:355 [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+0x72e/0xb10 net/can/j1939/main.c:112
       deliver net/can/af_can.c:573 [inline]
       can_rcv_filter+0x349/0x7c0 net/can/af_can.c:607
       can_receive+0x2f2/0x430 net/can/af_can.c:664
       can_rcv+0x140/0x260 net/can/af_can.c:688
       __netif_receive_skb_one_core net/core/dev.c:5496 [inline]
       __netif_receive_skb+0x1c6/0x530 net/core/dev.c:5610
       process_backlog+0x347/0x700 net/core/dev.c:5938
       __napi_poll+0xc7/0x470 net/core/dev.c:6505
       napi_poll net/core/dev.c:6572 [inline]
       net_rx_action+0x70f/0xeb0 net/core/dev.c:6683
       __do_softirq+0x2e9/0xa4c kernel/softirq.c:571
       run_ksoftirqd+0xc1/0x120 kernel/softirq.c:934
       smpboot_thread_fn+0x51b/0xa10 kernel/smpboot.c:164
       kthread+0x26e/0x300 kernel/kthread.c:376
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306

-> #0 (&jsk->sk_session_queue_lock){+.-.}-{2:2}:
       check_prev_add kernel/locking/lockdep.c:3090 [inline]
       check_prevs_add kernel/locking/lockdep.c:3209 [inline]
       validate_chain+0x1667/0x58e0 kernel/locking/lockdep.c:3824
       __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5048
       lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5661
       __raw_spin_lock_bh include/linux/spinlock_api_smp.h:126 [inline]
       _raw_spin_lock_bh+0x31/0x40 kernel/locking/spinlock.c:178
       spin_lock_bh include/linux/spinlock.h:355 [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:381
       notifier_call_chain kernel/notifier.c:87 [inline]
       raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:455
       call_netdevice_notifiers_info net/core/dev.c:1945 [inline]
       call_netdevice_notifiers_extack net/core/dev.c:1983 [inline]
       call_netdevice_notifiers net/core/dev.c:1997 [inline]
       dev_close_many+0x37c/0x530 net/core/dev.c:1545
       unregister_netdevice_many+0x4d0/0x1870 net/core/dev.c:10820
       rtnl_delete_link net/core/rtnetlink.c:3143 [inline]
       rtnl_dellink+0x4e1/0x880 net/core/rtnetlink.c:3194
       rtnetlink_rcv_msg+0x776/0xf00 net/core/rtnetlink.c:6124
       netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2525
       netlink_unicast_kernel net/netlink/af_netlink.c:1328 [inline]
       netlink_unicast+0x7bf/0x990 net/netlink/af_netlink.c:1354
       netlink_sendmsg+0xa26/0xd60 net/netlink/af_netlink.c:1903
       sock_sendmsg_nosec net/socket.c:716 [inline]
       sock_sendmsg net/socket.c:736 [inline]
       ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2482
       ___sys_sendmsg net/socket.c:2536 [inline]
       __sys_sendmsg+0x2a9/0x390 net/socket.c:2565
       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+0x63/0xcd

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-executor410/3611:
 #0: ffffffff8e29b568 (rtnl_mutex){+.+.}-{3:3}, at: rtnl_lock net/core/rtnetlink.c:74 [inline]
 #0: ffffffff8e29b568 (rtnl_mutex){+.+.}-{3:3}, at: rtnetlink_rcv_msg+0x720/0xf00 net/core/rtnetlink.c:6121
 #1: ffff8880738050d0 (&priv->j1939_socks_lock){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:355 [inline]
 #1: ffff8880738050d0 (&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: 3611 Comm: syz-executor410 Not tainted 6.1.53-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/04/2023
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+0x1667/0x58e0 kernel/locking/lockdep.c:3824
 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5048
 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5661
 __raw_spin_lock_bh include/linux/spinlock_api_smp.h:126 [inline]
 _raw_spin_lock_bh+0x31/0x40 kernel/locking/spinlock.c:178
 spin_lock_bh include/linux/spinlock.h:355 [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:381
 notifier_call_chain kernel/notifier.c:87 [inline]
 raw_notifier_call_chain+0xd0/0x170 kernel/notifier.c:455
 call_netdevice_notifiers_info net/core/dev.c:1945 [inline]
 call_netdevice_notifiers_extack net/core/dev.c:1983 [inline]
 call_netdevice_notifiers net/core/dev.c:1997 [inline]
 dev_close_many+0x37c/0x530 net/core/dev.c:1545
 unregister_netdevice_many+0x4d0/0x1870 net/core/dev.c:10820
 rtnl_delete_link net/core/rtnetlink.c:3143 [inline]
 rtnl_dellink+0x4e1/0x880 net/core/rtnetlink.c:3194
 rtnetlink_rcv_msg+0x776/0xf00 net/core/rtnetlink.c:6124
 netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2525
 netlink_unicast_kernel net/netlink/af_netlink.c:1328 [inline]
 netlink_unicast+0x7bf/0x990 net/netlink/af_netlink.c:1354
 netlink_sendmsg+0xa26/0xd60 net/netlink/af_netlink.c:1903
 sock_sendmsg_nosec net/socket.c:716 [inline]
 sock_sendmsg net/socket.c:736 [inline]
 ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2482
 ___sys_sendmsg net/socket.c:2536 [inline]
 __sys_sendmsg+0x2a9/0x390 net/socket.c:2565
 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+0x63/0xcd
RIP: 0033:0x7fd7338fda59
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:00007fffa8f68c48 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fd7338fda59
RDX: 0000000000000000 RSI: 00000000200002c0 RDI: 0000000000000007
RBP: 00000000000f4240 R08: 0000000100000000 R09: 0000000100000000
R10: 0000000100000000 R11: 0000000000000246 R12: 00007fffa8f68ca0
R13: 0000000000000001 R14: 00007fffa8f68ca0 R15: 0000000000000003
 </TASK>

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/09/15 19:47 linux-6.1.y 09045dae0d90 0b6a67ac .config console log report syz C [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in j1939_sk_queue_drop_all
2024/02/23 01:06 linux-6.1.y 8b4118fabd6e 8d446f15 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan possible deadlock in j1939_sk_queue_drop_all
* Struck through repros no longer work on HEAD.