vxcan0: j1939_tp_rxtimer: 0xffff88801cc9a000: rx timeout, send abort
vxcan0: j1939_tp_rxtimer: 0xffff88801cc9a000: abort rx timeout. Force session deactivation
======================================================
WARNING: possible circular locking dependency detected
5.19.0-next-20220809-syzkaller #0 Not tainted
------------------------------------------------------
kworker/u4:10/7032 is trying to acquire lock:
ffff88803554d088 (&priv->active_session_list_lock){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:354 [inline]
ffff88803554d088 (&priv->active_session_list_lock){+.-.}-{2:2}, at: j1939_session_list_lock net/can/j1939/transport.c:238 [inline]
ffff88803554d088 (&priv->active_session_list_lock){+.-.}-{2:2}, at: j1939_session_activate+0x43/0x4b0 net/can/j1939/transport.c:1553
but task is already holding lock:
ffff8880358525b8 (&jsk->sk_session_queue_lock){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:354 [inline]
ffff8880358525b8 (&jsk->sk_session_queue_lock){+.-.}-{2:2}, at: j1939_sk_queue_activate_next+0x56/0x460 net/can/j1939/socket.c:204
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (&jsk->sk_session_queue_lock){+.-.}-{2:2}:
__raw_spin_lock_bh include/linux/spinlock_api_smp.h:126 [inline]
_raw_spin_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:178
spin_lock_bh include/linux/spinlock.h:354 [inline]
j1939_sk_queue_drop_all+0x3b/0x2f0 net/can/j1939/socket.c:139
j1939_sk_netdev_event_netdown+0x7b/0x160 net/can/j1939/socket.c:1272
j1939_netdev_notify+0x199/0x1d0 net/can/j1939/main.c:372
notifier_call_chain+0xb5/0x200 kernel/notifier.c:87
call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1945
call_netdevice_notifiers_extack net/core/dev.c:1983 [inline]
call_netdevice_notifiers net/core/dev.c:1997 [inline]
__dev_notify_flags+0x1da/0x2b0 net/core/dev.c:8596
dev_change_flags+0x112/0x170 net/core/dev.c:8632
do_setlink+0x961/0x3bb0 net/core/rtnetlink.c:2780
__rtnl_newlink+0xd6a/0x17e0 net/core/rtnetlink.c:3546
rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3593
rtnetlink_rcv_msg+0x43a/0xc90 net/core/rtnetlink.c:6089
netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2501
netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
netlink_unicast+0x543/0x7f0 net/netlink/af_netlink.c:1345
netlink_sendmsg+0x917/0xe10 net/netlink/af_netlink.c:1921
sock_sendmsg_nosec net/socket.c:714 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:734
____sys_sendmsg+0x6eb/0x810 net/socket.c:2482
___sys_sendmsg+0x110/0x1b0 net/socket.c:2536
__sys_sendmsg+0xf3/0x1c0 net/socket.c:2565
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
-> #1 (&priv->j1939_socks_lock){+.-.}-{2:2}:
__raw_spin_lock_bh include/linux/spinlock_api_smp.h:126 [inline]
_raw_spin_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:178
spin_lock_bh include/linux/spinlock.h:354 [inline]
j1939_sk_errqueue+0x9f/0x1a0 net/can/j1939/socket.c:1078
j1939_session_destroy+0x2fc/0x3c0 net/can/j1939/transport.c:269
__j1939_session_release net/can/j1939/transport.c:288 [inline]
kref_put include/linux/kref.h:65 [inline]
j1939_session_put net/can/j1939/transport.c:293 [inline]
j1939_session_deactivate_locked net/can/j1939/transport.c:1075 [inline]
j1939_session_deactivate_locked+0x293/0x340 net/can/j1939/transport.c:1063
j1939_cancel_active_session+0x17f/0x360 net/can/j1939/transport.c:2183
j1939_netdev_notify+0x191/0x1d0 net/can/j1939/main.c:371
notifier_call_chain+0xb5/0x200 kernel/notifier.c:87
call_netdevice_notifiers_info+0xb5/0x130 net/core/dev.c:1945
call_netdevice_notifiers_extack net/core/dev.c:1983 [inline]
call_netdevice_notifiers net/core/dev.c:1997 [inline]
__dev_notify_flags+0x1da/0x2b0 net/core/dev.c:8596
dev_change_flags+0x112/0x170 net/core/dev.c:8632
do_setlink+0x961/0x3bb0 net/core/rtnetlink.c:2780
__rtnl_newlink+0xd6a/0x17e0 net/core/rtnetlink.c:3546
rtnl_newlink+0x64/0xa0 net/core/rtnetlink.c:3593
rtnetlink_rcv_msg+0x43a/0xc90 net/core/rtnetlink.c:6089
netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2501
netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
netlink_unicast+0x543/0x7f0 net/netlink/af_netlink.c:1345
netlink_sendmsg+0x917/0xe10 net/netlink/af_netlink.c:1921
sock_sendmsg_nosec net/socket.c:714 [inline]
sock_sendmsg+0xcf/0x120 net/socket.c:734
____sys_sendmsg+0x6eb/0x810 net/socket.c:2482
___sys_sendmsg+0x110/0x1b0 net/socket.c:2536
__sys_sendmsg+0xf3/0x1c0 net/socket.c:2565
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
-> #0 (&priv->active_session_list_lock){+.-.}-{2:2}:
check_prev_add kernel/locking/lockdep.c:3095 [inline]
check_prevs_add kernel/locking/lockdep.c:3214 [inline]
validate_chain kernel/locking/lockdep.c:3829 [inline]
__lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5053
lock_acquire kernel/locking/lockdep.c:5666 [inline]
lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5631
__raw_spin_lock_bh include/linux/spinlock_api_smp.h:126 [inline]
_raw_spin_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:178
spin_lock_bh include/linux/spinlock.h:354 [inline]
j1939_session_list_lock net/can/j1939/transport.c:238 [inline]
j1939_session_activate+0x43/0x4b0 net/can/j1939/transport.c:1553
j1939_sk_queue_activate_next_locked net/can/j1939/socket.c:181 [inline]
j1939_sk_queue_activate_next+0x29b/0x460 net/can/j1939/socket.c:205
j1939_session_deactivate_activate_next+0xc8/0xd3 net/can/j1939/transport.c:1101
j1939_tp_rxtimer.cold+0x154/0x24f net/can/j1939/transport.c:1228
__run_hrtimer kernel/time/hrtimer.c:1685 [inline]
__hrtimer_run_queues+0x5fa/0xe40 kernel/time/hrtimer.c:1749
hrtimer_run_softirq+0x17b/0x360 kernel/time/hrtimer.c:1766
__do_softirq+0x1d3/0x9c6 kernel/softirq.c:571
invoke_softirq kernel/softirq.c:445 [inline]
__irq_exit_rcu+0x123/0x180 kernel/softirq.c:650
irq_exit_rcu+0x5/0x20 kernel/softirq.c:662
sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1106
asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:649
__sanitizer_cov_trace_const_cmp1+0xc/0x20 kernel/kcov.c:283
rcu_read_unlock include/linux/rcupdate.h:735 [inline]
batadv_nc_purge_orig_hash net/batman-adv/network-coding.c:412 [inline]
batadv_nc_worker+0x841/0xfa0 net/batman-adv/network-coding.c:719
process_one_work+0x991/0x1610 kernel/workqueue.c:2289
worker_thread+0x665/0x1080 kernel/workqueue.c:2436
kthread+0x2e4/0x3a0 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
other info that might help us debug this:
Chain exists of:
&priv->active_session_list_lock --> &priv->j1939_socks_lock --> &jsk->sk_session_queue_lock
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&jsk->sk_session_queue_lock);
lock(&priv->j1939_socks_lock);
lock(&jsk->sk_session_queue_lock);
lock(&priv->active_session_list_lock);
*** DEADLOCK ***
4 locks held by kworker/u4:10/7032:
#0: ffff88814acd5138 ((wq_completion)bat_events){+.+.}-{0:0}, at: arch_atomic64_set arch/x86/include/asm/atomic64_64.h:34 [inline]
#0: ffff88814acd5138 ((wq_completion)bat_events){+.+.}-{0:0}, at: arch_atomic_long_set include/linux/atomic/atomic-long.h:41 [inline]
#0: ffff88814acd5138 ((wq_completion)bat_events){+.+.}-{0:0}, at: atomic_long_set include/linux/atomic/atomic-instrumented.h:1280 [inline]
#0: ffff88814acd5138 ((wq_completion)bat_events){+.+.}-{0:0}, at: set_work_data kernel/workqueue.c:636 [inline]
#0: ffff88814acd5138 ((wq_completion)bat_events){+.+.}-{0:0}, at: set_work_pool_and_clear_pending kernel/workqueue.c:663 [inline]
#0: ffff88814acd5138 ((wq_completion)bat_events){+.+.}-{0:0}, at: process_one_work+0x87a/0x1610 kernel/workqueue.c:2260
#1: ffffc90002cafda8 ((work_completion)(&(&bat_priv->nc.work)->work)){+.+.}-{0:0}, at: process_one_work+0x8ae/0x1610 kernel/workqueue.c:2264
#2: ffffffff8bf89500 (rcu_read_lock){....}-{1:2}, at: batadv_nc_purge_orig_hash net/batman-adv/network-coding.c:406 [inline]
#2: ffffffff8bf89500 (rcu_read_lock){....}-{1:2}, at: batadv_nc_worker+0xf3/0xfa0 net/batman-adv/network-coding.c:719
#3: ffff8880358525b8 (&jsk->sk_session_queue_lock){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:354 [inline]
#3: ffff8880358525b8 (&jsk->sk_session_queue_lock){+.-.}-{2:2}, at: j1939_sk_queue_activate_next+0x56/0x460 net/can/j1939/socket.c:204
stack backtrace:
CPU: 1 PID: 7032 Comm: kworker/u4:10 Not tainted 5.19.0-next-20220809-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/22/2022
Workqueue: bat_events batadv_nc_worker
Call Trace:
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2175
check_prev_add kernel/locking/lockdep.c:3095 [inline]
check_prevs_add kernel/locking/lockdep.c:3214 [inline]
validate_chain kernel/locking/lockdep.c:3829 [inline]
__lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5053
lock_acquire kernel/locking/lockdep.c:5666 [inline]
lock_acquire+0x1ab/0x570 kernel/locking/lockdep.c:5631
__raw_spin_lock_bh include/linux/spinlock_api_smp.h:126 [inline]
_raw_spin_lock_bh+0x2f/0x40 kernel/locking/spinlock.c:178
spin_lock_bh include/linux/spinlock.h:354 [inline]
j1939_session_list_lock net/can/j1939/transport.c:238 [inline]
j1939_session_activate+0x43/0x4b0 net/can/j1939/transport.c:1553
j1939_sk_queue_activate_next_locked net/can/j1939/socket.c:181 [inline]
j1939_sk_queue_activate_next+0x29b/0x460 net/can/j1939/socket.c:205
j1939_session_deactivate_activate_next+0xc8/0xd3 net/can/j1939/transport.c:1101
j1939_tp_rxtimer.cold+0x154/0x24f net/can/j1939/transport.c:1228
__run_hrtimer kernel/time/hrtimer.c:1685 [inline]
__hrtimer_run_queues+0x5fa/0xe40 kernel/time/hrtimer.c:1749
hrtimer_run_softirq+0x17b/0x360 kernel/time/hrtimer.c:1766
__do_softirq+0x1d3/0x9c6 kernel/softirq.c:571
invoke_softirq kernel/softirq.c:445 [inline]
__irq_exit_rcu+0x123/0x180 kernel/softirq.c:650
irq_exit_rcu+0x5/0x20 kernel/softirq.c:662
sysvec_apic_timer_interrupt+0x93/0xc0 arch/x86/kernel/apic/apic.c:1106
asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:649
RIP: 0010:__sanitizer_cov_trace_const_cmp1+0xc/0x20 kernel/kcov.c:283
Code: 0c 24 48 89 f2 48 89 fe bf 06 00 00 00 e9 fc fe ff ff 66 66 2e 0f 1f 84 00 00 00 00 00 90 48 8b 0c 24 40 0f b6 d6 40 0f b6 f7 01 00 00 00 e9 da fe ff ff 66 2e 0f 1f 84 00 00 00 00 00 48 8b
RSP: 0018:ffffc90002cafc80 EFLAGS: 00000246
RAX: 0000000000000001 RBX: 0000000000000001 RCX: ffffffff8918f021
RDX: 0000000000000001 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000000
R10: 0000000000000001 R11: 1ffffffff17f2761 R12: 0000000000000001
R13: 0000000000000000 R14: dffffc0000000000 R15: 000000000000026d
rcu_read_unlock include/linux/rcupdate.h:735 [inline]
batadv_nc_purge_orig_hash net/batman-adv/network-coding.c:412 [inline]
batadv_nc_worker+0x841/0xfa0 net/batman-adv/network-coding.c:719
process_one_work+0x991/0x1610 kernel/workqueue.c:2289
worker_thread+0x665/0x1080 kernel/workqueue.c:2436
kthread+0x2e4/0x3a0 kernel/kthread.c:376
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:306
vxcan0: j1939_tp_rxtimer: 0xffff8880701f9800: rx timeout, send abort
vxcan0: j1939_tp_rxtimer: 0xffff8880701f9800: abort rx timeout. Force session deactivation
vxcan0: j1939_tp_rxtimer: 0xffff8880701f8000: rx timeout, send abort
vxcan0: j1939_tp_rxtimer: 0xffff8880701f8000: abort rx timeout. Force session deactivation
vxcan0: j1939_tp_rxtimer: 0xffff8880701fb800: rx timeout, send abort
vxcan0: j1939_tp_rxtimer: 0xffff8880701fb800: abort rx timeout. Force session deactivation
vxcan0: j1939_tp_rxtimer: 0xffff8880701f8400: rx timeout, send abort
vxcan0: j1939_tp_rxtimer: 0xffff8880701f8400: abort rx timeout. Force session deactivation
vxcan0: j1939_tp_rxtimer: 0xffff8880701f8800: rx timeout, send abort
vxcan0: j1939_tp_rxtimer: 0xffff8880701f8800: abort rx timeout. Force session deactivation
----------------
Code disassembly (best guess):
0: 0c 24 or $0x24,%al
2: 48 89 f2 mov %rsi,%rdx
5: 48 89 fe mov %rdi,%rsi
8: bf 06 00 00 00 mov $0x6,%edi
d: e9 fc fe ff ff jmpq 0xffffff0e
12: 66 66 2e 0f 1f 84 00 data16 nopw %cs:0x0(%rax,%rax,1)
19: 00 00 00 00
1d: 90 nop
1e: 48 8b 0c 24 mov (%rsp),%rcx
22: 40 0f b6 d6 movzbl %sil,%edx
26: 40 0f b6 f7 movzbl %dil,%esi
* 2a: bf 01 00 00 00 mov $0x1,%edi <-- trapping instruction
2f: e9 da fe ff ff jmpq 0xffffff0e
34: 66 2e 0f 1f 84 00 00 nopw %cs:0x0(%rax,%rax,1)
3b: 00 00 00
3e: 48 rex.W
3f: 8b .byte 0x8b