syzbot


possible deadlock in j1939_sk_errqueue

Status: auto-obsoleted due to no activity on 2024/09/21 21:59
Reported-by: syzbot+9b2484e79a5f43b4851c@syzkaller.appspotmail.com
First crash: 452d, last: 276d
Bug presence (1)
Date Name Commit Repro Result
2024/09/21 upstream (ToT) 88264981f208 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_errqueue origin:lts-only C inconclusive 6 242d 471d 0/3 upstream: reported C repro on 2023/07/09 02:39
upstream possible deadlock in j1939_sk_errqueue can C unreliable 227 573d 1110d 22/28 fixed on 2023/06/08 14:41
upstream possible deadlock in j1939_sk_errqueue (2) can C done 24 250d 476d 25/28 fixed on 2024/03/26 17:39
Fix bisection attempts (2)
Created Duration User Patch Repo Result
2023/12/17 18:06 1m fix candidate upstream error job log
2023/08/26 22:07 14m fix candidate upstream error job log

Sample crash report:
IPv6: ADDRCONF(NETDEV_CHANGE): vxcan1: link becomes ready
======================================================
WARNING: possible circular locking dependency detected
5.15.145-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor401/10153 is trying to acquire lock:
ffff88807cd3d0d0 (&priv->j1939_socks_lock){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:368 [inline]
ffff88807cd3d0d0 (&priv->j1939_socks_lock){+.-.}-{2:2}, at: j1939_sk_errqueue+0x92/0x140 net/can/j1939/socket.c:1081

but task is already holding lock:
ffff88807cd3d088 (&priv->active_session_list_lock){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:368 [inline]
ffff88807cd3d088 (&priv->active_session_list_lock){+.-.}-{2:2}, at: j1939_session_list_lock net/can/j1939/transport.c:238 [inline]
ffff88807cd3d088 (&priv->active_session_list_lock){+.-.}-{2:2}, at: j1939_cancel_active_session+0x43/0x480 net/can/j1939/transport.c:2183

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (&priv->active_session_list_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
       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:5482 [inline]
       __netif_receive_skb+0x1c6/0x530 net/core/dev.c:5596
       process_backlog+0x363/0x7f0 net/core/dev.c:6473
       __napi_poll+0xc7/0x440 net/core/dev.c:7032
       napi_poll net/core/dev.c:7099 [inline]
       net_rx_action+0x617/0xda0 net/core/dev.c:7186
       __do_softirq+0x3b3/0x93a kernel/softirq.c:558
       run_ksoftirqd+0xc1/0x120 kernel/softirq.c:921
       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

-> #1 (&jsk->sk_session_queue_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
       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
       __dev_notify_flags+0x304/0x610
       dev_change_flags+0xe7/0x190 net/core/dev.c:8883
       do_setlink+0xcd1/0x3ae0 net/core/rtnetlink.c:2741
       __rtnl_newlink net/core/rtnetlink.c:3429 [inline]
       rtnl_newlink+0x17a4/0x2070 net/core/rtnetlink.c:3549
       rtnetlink_rcv_msg+0x993/0xee0 net/core/rtnetlink.c:5630
       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:716 [inline]
       ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2429
       ___sys_sendmsg+0x252/0x2e0 net/socket.c:2483
       __sys_sendmsg net/socket.c:2512 [inline]
       __do_sys_sendmsg net/socket.c:2521 [inline]
       __se_sys_sendmsg+0x19a/0x260 net/socket.c:2519
       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

-> #0 (&priv->j1939_socks_lock){+.-.}-{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_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
       __dev_notify_flags+0x304/0x610
       dev_change_flags+0xe7/0x190 net/core/dev.c:8883
       do_setlink+0xcd1/0x3ae0 net/core/rtnetlink.c:2741
       __rtnl_newlink net/core/rtnetlink.c:3429 [inline]
       rtnl_newlink+0x17a4/0x2070 net/core/rtnetlink.c:3549
       rtnetlink_rcv_msg+0x993/0xee0 net/core/rtnetlink.c:5630
       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:716 [inline]
       ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2429
       ___sys_sendmsg+0x252/0x2e0 net/socket.c:2483
       __sys_sendmsg net/socket.c:2512 [inline]
       __do_sys_sendmsg net/socket.c:2521 [inline]
       __se_sys_sendmsg+0x19a/0x260 net/socket.c:2519
       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:
  &priv->j1939_socks_lock --> &jsk->sk_session_queue_lock --> &priv->active_session_list_lock

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

2 locks held by syz-executor401/10153:
 #0: ffffffff8d9da708 (rtnl_mutex){+.+.}-{3:3}, at: rtnl_lock net/core/rtnetlink.c:72 [inline]
 #0: ffffffff8d9da708 (rtnl_mutex){+.+.}-{3:3}, at: rtnetlink_rcv_msg+0x94c/0xee0 net/core/rtnetlink.c:5627
 #1: ffff88807cd3d088 (&priv->active_session_list_lock){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:368 [inline]
 #1: ffff88807cd3d088 (&priv->active_session_list_lock){+.-.}-{2:2}, at: j1939_session_list_lock net/can/j1939/transport.c:238 [inline]
 #1: ffff88807cd3d088 (&priv->active_session_list_lock){+.-.}-{2:2}, at: j1939_cancel_active_session+0x43/0x480 net/can/j1939/transport.c:2183

stack backtrace:
CPU: 0 PID: 10153 Comm: syz-executor401 Not tainted 5.15.145-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/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+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_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
 __dev_notify_flags+0x304/0x610
 dev_change_flags+0xe7/0x190 net/core/dev.c:8883
 do_setlink+0xcd1/0x3ae0 net/core/rtnetlink.c:2741
 __rtnl_newlink net/core/rtnetlink.c:3429 [inline]
 rtnl_newlink+0x17a4/0x2070 net/core/rtnetlink.c:3549
 rtnetlink_rcv_msg+0x993/0xee0 net/core/rtnetlink.c:5630
 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:716 [inline]
 ____sys_sendmsg+0x59e/0x8f0 net/socket.c:2429
 ___sys_sendmsg+0x252/0x2e0 net/socket.c:2483
 __sys_sendmsg net/socket.c:2512 [inline]
 __do_sys_sendmsg net/socket.c:2521 [inline]
 __se_sys_sendmsg+0x19a/0x260 net/socket.c:2519
 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:0x7fc8c5cc1ff9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 21 1f 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:00007fff754ce528 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fc8c5cc1ff9
RDX: 0000000000000000 RSI: 00000000200000c0 RDI: 0000000000000007
RBP: 0000000000000000 R08: 00007fc800000001 R09: 00007fc800000001
R10: 00007fc800000001 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>

Crashes (6):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/01/01 10:26 linux-5.15.y d93fa2c78854 fb427a07 .config console log report syz C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in j1939_sk_errqueue
2023/12/31 18:25 linux-5.15.y d93fa2c78854 fb427a07 .config console log report syz C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan possible deadlock in j1939_sk_errqueue
2024/01/20 06:11 linux-5.15.y ddcaf4999061 9bd8dcda .config console log report syz C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in j1939_sk_errqueue
2024/01/19 09:27 linux-5.15.y ddcaf4999061 21772ce4 .config console log report syz C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in j1939_sk_errqueue
2023/07/28 14:35 linux-5.15.y 09996673e313 92476829 .config console log report syz [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in j1939_sk_errqueue
2023/07/28 13:47 linux-5.15.y 09996673e313 92476829 .config console log report syz C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-arm64 possible deadlock in j1939_sk_errqueue
* Struck through repros no longer work on HEAD.