====================================================== WARNING: possible circular locking dependency detected 6.1.32-syzkaller #0 Not tainted ------------------------------------------------------ syz-executor.1/18460 is trying to acquire lock: ffff8880731225c8 (&jsk->sk_session_queue_lock){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:355 [inline] ffff8880731225c8 (&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: ffff888029a110d0 (&priv->j1939_socks_lock){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:355 [inline] ffff888029a110d0 (&priv->j1939_socks_lock){+.-.}-{2:2}, at: j1939_sk_netdev_event_netdown+0x2d/0x150 net/can/j1939/socket.c:1269 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:5669 __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+0x1ff/0x2e0 net/can/j1939/main.c:378 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:10818 rtnl_delete_link net/core/rtnetlink.c:3123 [inline] rtnl_dellink+0x4e1/0x880 net/core/rtnetlink.c:3174 rtnetlink_rcv_msg+0x776/0xf00 net/core/rtnetlink.c:6091 netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2524 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:1902 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:5669 __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:5494 [inline] __netif_receive_skb+0x1c6/0x530 net/core/dev.c:5608 process_backlog+0x347/0x700 net/core/dev.c:5936 __napi_poll+0xc7/0x470 net/core/dev.c:6503 napi_poll net/core/dev.c:6570 [inline] net_rx_action+0x70f/0xeb0 net/core/dev.c:6681 __do_softirq+0x2e9/0xa4c kernel/softirq.c:571 invoke_softirq kernel/softirq.c:445 [inline] __irq_exit_rcu+0x155/0x240 kernel/softirq.c:650 irq_exit_rcu+0x5/0x20 kernel/softirq.c:662 sysvec_apic_timer_interrupt+0x91/0xb0 arch/x86/kernel/apic/apic.c:1106 asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:649 finish_lock_switch+0x91/0x100 kernel/sched/core.c:5001 finish_task_switch+0x134/0x630 kernel/sched/core.c:5118 context_switch kernel/sched/core.c:5244 [inline] __schedule+0x1334/0x4330 kernel/sched/core.c:6554 schedule+0xbf/0x180 kernel/sched/core.c:6630 schedule_timeout+0xac/0x300 kernel/time/timer.c:1911 unix_wait_for_peer+0x24b/0x330 net/unix/af_unix.c:1449 unix_dgram_sendmsg+0x1348/0x2050 net/unix/af_unix.c:2047 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_sendmmsg+0x3ab/0x730 net/socket.c:2622 __do_sys_sendmmsg net/socket.c:2651 [inline] __se_sys_sendmmsg net/socket.c:2648 [inline] __x64_sys_sendmmsg+0x9c/0xb0 net/socket.c:2648 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 -> #0 (&jsk->sk_session_queue_lock){+.-.}-{2:2}: check_prev_add kernel/locking/lockdep.c:3098 [inline] check_prevs_add kernel/locking/lockdep.c:3217 [inline] validate_chain+0x1667/0x58e0 kernel/locking/lockdep.c:3832 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5056 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5669 __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:1275 j1939_netdev_notify+0x207/0x2e0 net/can/j1939/main.c:379 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:10818 rtnl_delete_link net/core/rtnetlink.c:3123 [inline] rtnl_dellink+0x4e1/0x880 net/core/rtnetlink.c:3174 rtnetlink_rcv_msg+0x776/0xf00 net/core/rtnetlink.c:6091 netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2524 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:1902 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-executor.1/18460: #0: ffffffff8e093c08 (rtnl_mutex){+.+.}-{3:3}, at: rtnl_lock net/core/rtnetlink.c:74 [inline] #0: ffffffff8e093c08 (rtnl_mutex){+.+.}-{3:3}, at: rtnetlink_rcv_msg+0x720/0xf00 net/core/rtnetlink.c:6088 #1: ffff888029a110d0 (&priv->j1939_socks_lock){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:355 [inline] #1: ffff888029a110d0 (&priv->j1939_socks_lock){+.-.}-{2:2}, at: j1939_sk_netdev_event_netdown+0x2d/0x150 net/can/j1939/socket.c:1269 stack backtrace: CPU: 1 PID: 18460 Comm: syz-executor.1 Not tainted 6.1.32-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/25/2023 Call Trace: __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:2178 check_prev_add kernel/locking/lockdep.c:3098 [inline] check_prevs_add kernel/locking/lockdep.c:3217 [inline] validate_chain+0x1667/0x58e0 kernel/locking/lockdep.c:3832 __lock_acquire+0x125b/0x1f80 kernel/locking/lockdep.c:5056 lock_acquire+0x1f8/0x5a0 kernel/locking/lockdep.c:5669 __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:1275 j1939_netdev_notify+0x207/0x2e0 net/can/j1939/main.c:379 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:10818 rtnl_delete_link net/core/rtnetlink.c:3123 [inline] rtnl_dellink+0x4e1/0x880 net/core/rtnetlink.c:3174 rtnetlink_rcv_msg+0x776/0xf00 net/core/rtnetlink.c:6091 netlink_rcv_skb+0x1cd/0x410 net/netlink/af_netlink.c:2524 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:1902 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:0x7f531068c169 Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 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:00007f531148c168 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007f53107ac050 RCX: 00007f531068c169 RDX: 0000000000000000 RSI: 00000000200002c0 RDI: 000000000000000c RBP: 00007f53106e7ca1 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fff5958f37f R14: 00007f531148c300 R15: 0000000000022000