====================================================== 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: __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