======================================================
WARNING: possible circular locking dependency detected
6.2.0-rc4-next-20230117-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/15666 is trying to acquire lock:
ffffc90001860a60 (&tcp_hashinfo.bhash[i].lock){+.-.}-{2:2}, at: spin_lock include/linux/spinlock.h:350 [inline]
ffffc90001860a60 (&tcp_hashinfo.bhash[i].lock){+.-.}-{2:2}, at: __inet_inherit_port+0x2b5/0x18c0 net/ipv4/inet_hashtables.c:230
but task is already holding lock:
ffff88802688e6b0 (slock-AF_INET6){+.-.}-{2:2}, at: spin_lock include/linux/spinlock.h:350 [inline]
ffff88802688e6b0 (slock-AF_INET6){+.-.}-{2:2}, at: sk_clone_lock+0x333/0x12d0 net/core/sock.c:2265
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #2 (slock-AF_INET6){+.-.}-{2:2}:
__raw_spin_lock_bh include/linux/spinlock_api_smp.h:126 [inline]
_raw_spin_lock_bh+0x33/0x40 kernel/locking/spinlock.c:178
spin_lock_bh include/linux/spinlock.h:355 [inline]
release_sock+0x1f/0x1b0 net/core/sock.c:3483
l2tp_tunnel_register+0x2e0/0xd80 net/l2tp/l2tp_core.c:1487
pppol2tp_connect+0xcdc/0x1a80 net/l2tp/l2tp_ppp.c:723
__sys_connect_file+0x153/0x1a0 net/socket.c:2001
__sys_connect+0x165/0x1a0 net/socket.c:2018
__do_sys_connect net/socket.c:2028 [inline]
__se_sys_connect net/socket.c:2025 [inline]
__x64_sys_connect+0x73/0xb0 net/socket.c:2025
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
-> #1 (clock-AF_INET6){++..}-{2:2}:
__raw_read_lock_bh include/linux/rwlock_api_smp.h:176 [inline]
_raw_read_lock_bh+0x3f/0x70 kernel/locking/spinlock.c:252
sock_i_uid+0x1f/0xb0 net/core/sock.c:2564
sk_reuseport_match net/ipv4/inet_connection_sock.c:401 [inline]
inet_csk_get_port+0x85f/0x26d0 net/ipv4/inet_connection_sock.c:532
__inet6_bind+0x625/0x1bb0 net/ipv6/af_inet6.c:413
inet6_bind+0x177/0x220 net/ipv6/af_inet6.c:472
__sys_bind+0x1ed/0x260 net/socket.c:1801
__do_sys_bind net/socket.c:1812 [inline]
__se_sys_bind net/socket.c:1810 [inline]
__x64_sys_bind+0x73/0xb0 net/socket.c:1810
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
-> #0 (&tcp_hashinfo.bhash[i].lock){+.-.}-{2:2}:
check_prev_add kernel/locking/lockdep.c:3107 [inline]
check_prevs_add kernel/locking/lockdep.c:3226 [inline]
validate_chain kernel/locking/lockdep.c:3841 [inline]
__lock_acquire+0x2a9d/0x5780 kernel/locking/lockdep.c:5073
lock_acquire.part.0+0x11c/0x350 kernel/locking/lockdep.c:5690
__raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
_raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
spin_lock include/linux/spinlock.h:350 [inline]
__inet_inherit_port+0x2b5/0x18c0 net/ipv4/inet_hashtables.c:230
tcp_v4_syn_recv_sock+0xb5a/0x14b0 net/ipv4/tcp_ipv4.c:1628
tcp_v6_syn_recv_sock+0x14e1/0x2360 net/ipv6/tcp_ipv6.c:1220
tcp_get_cookie_sock+0xcd/0x860 net/ipv4/syncookies.c:207
cookie_v4_check+0x1553/0x25e0 net/ipv4/syncookies.c:448
tcp_v4_cookie_check net/ipv4/tcp_ipv4.c:1670 [inline]
tcp_v4_do_rcv+0x8d9/0x9d0 net/ipv4/tcp_ipv4.c:1730
tcp_v4_rcv+0x306c/0x3280 net/ipv4/tcp_ipv4.c:2132
ip_protocol_deliver_rcu+0x9f/0x480 net/ipv4/ip_input.c:205
ip_local_deliver_finish+0x2ec/0x4f0 net/ipv4/ip_input.c:233
NF_HOOK include/linux/netfilter.h:302 [inline]
NF_HOOK include/linux/netfilter.h:296 [inline]
ip_local_deliver+0x1ae/0x200 net/ipv4/ip_input.c:254
dst_input include/net/dst.h:454 [inline]
ip_rcv_finish+0x1cf/0x2f0 net/ipv4/ip_input.c:449
NF_HOOK include/linux/netfilter.h:302 [inline]
NF_HOOK include/linux/netfilter.h:296 [inline]
ip_rcv+0xae/0xd0 net/ipv4/ip_input.c:569
__netif_receive_skb_one_core+0x114/0x180 net/core/dev.c:5482
__netif_receive_skb+0x1f/0x1c0 net/core/dev.c:5596
process_backlog+0x13e/0x6d0 net/core/dev.c:5924
__napi_poll+0xaf/0x430 net/core/dev.c:6485
napi_poll net/core/dev.c:6552 [inline]
net_rx_action+0x8da/0xc70 net/core/dev.c:6663
__do_softirq+0x2e3/0xae3 kernel/softirq.c:571
do_softirq.part.0+0xde/0x130 kernel/softirq.c:472
do_softirq kernel/softirq.c:464 [inline]
__local_bh_enable_ip+0x106/0x130 kernel/softirq.c:396
local_bh_enable include/linux/bottom_half.h:33 [inline]
rcu_read_unlock_bh include/linux/rcupdate.h:843 [inline]
ip_finish_output2+0x7dc/0x22e0 net/ipv4/ip_output.c:229
__ip_finish_output net/ipv4/ip_output.c:306 [inline]
__ip_finish_output+0x396/0x650 net/ipv4/ip_output.c:288
ip_finish_output+0x31/0x280 net/ipv4/ip_output.c:316
NF_HOOK_COND include/linux/netfilter.h:291 [inline]
ip_output+0x1a3/0x320 net/ipv4/ip_output.c:430
dst_output include/net/dst.h:444 [inline]
ip_local_out net/ipv4/ip_output.c:126 [inline]
__ip_queue_xmit+0x8e2/0x1c60 net/ipv4/ip_output.c:532
__tcp_transmit_skb+0x1967/0x3820 net/ipv4/tcp_output.c:1399
tcp_transmit_skb net/ipv4/tcp_output.c:1417 [inline]
tcp_write_xmit+0x1025/0x6160 net/ipv4/tcp_output.c:2693
__tcp_push_pending_frames+0xae/0x390 net/ipv4/tcp_output.c:2877
tcp_send_fin+0x11b/0xb70 net/ipv4/tcp_output.c:3432
tcp_shutdown net/ipv4/tcp.c:2817 [inline]
tcp_shutdown+0x12b/0x170 net/ipv4/tcp.c:2802
inet_shutdown+0x1ac/0x430 net/ipv4/af_inet.c:901
__sys_shutdown_sock net/socket.c:2343 [inline]
__sys_shutdown_sock net/socket.c:2337 [inline]
__sys_shutdown+0xf5/0x1c0 net/socket.c:2355
__do_sys_shutdown net/socket.c:2363 [inline]
__se_sys_shutdown net/socket.c:2361 [inline]
__x64_sys_shutdown+0x54/0x80 net/socket.c:2361
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x39/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:
&tcp_hashinfo.bhash[i].lock --> clock-AF_INET6 --> slock-AF_INET6
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(slock-AF_INET6);
lock(clock-AF_INET6);
lock(slock-AF_INET6);
lock(&tcp_hashinfo.bhash[i].lock);
*** DEADLOCK ***
5 locks held by syz-executor.0/15666:
#0: ffff88802688c0f0 (sk_lock-AF_INET6){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1725 [inline]
#0: ffff88802688c0f0 (sk_lock-AF_INET6){+.+.}-{0:0}, at: inet_shutdown+0x81/0x430 net/ipv4/af_inet.c:883
#1: ffffffff8c794880 (rcu_read_lock){....}-{1:2}, at: read_pnet include/net/net_namespace.h:383 [inline]
#1: ffffffff8c794880 (rcu_read_lock){....}-{1:2}, at: sock_net include/net/sock.h:649 [inline]
#1: ffffffff8c794880 (rcu_read_lock){....}-{1:2}, at: __ip_queue_xmit+0x41/0x1c60 net/ipv4/ip_output.c:457
#2: ffffffff8c794880 (rcu_read_lock){....}-{1:2}, at: __skb_unlink include/linux/skbuff.h:2327 [inline]
#2: ffffffff8c794880 (rcu_read_lock){....}-{1:2}, at: __skb_dequeue include/linux/skbuff.h:2342 [inline]
#2: ffffffff8c794880 (rcu_read_lock){....}-{1:2}, at: process_backlog+0x27c/0x6d0 net/core/dev.c:5922
#3: ffffffff8c794880 (rcu_read_lock){....}-{1:2}, at: __skb_pull include/linux/skbuff.h:2612 [inline]
#3: ffffffff8c794880 (rcu_read_lock){....}-{1:2}, at: ip_local_deliver_finish+0x20a/0x4f0 net/ipv4/ip_input.c:230
#4: ffff88802688e6b0 (slock-AF_INET6){+.-.}-{2:2}, at: spin_lock include/linux/spinlock.h:350 [inline]
#4: ffff88802688e6b0 (slock-AF_INET6){+.-.}-{2:2}, at: sk_clone_lock+0x333/0x12d0 net/core/sock.c:2265
stack backtrace:
CPU: 0 PID: 15666 Comm: syz-executor.0 Not tainted 6.2.0-rc4-next-20230117-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023
Call Trace:
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0xd1/0x138 lib/dump_stack.c:106
check_noncircular+0x25f/0x2e0 kernel/locking/lockdep.c:2187
check_prev_add kernel/locking/lockdep.c:3107 [inline]
check_prevs_add kernel/locking/lockdep.c:3226 [inline]
validate_chain kernel/locking/lockdep.c:3841 [inline]
__lock_acquire+0x2a9d/0x5780 kernel/locking/lockdep.c:5073
lock_acquire.part.0+0x11c/0x350 kernel/locking/lockdep.c:5690
__raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
_raw_spin_lock+0x2e/0x40 kernel/locking/spinlock.c:154
spin_lock include/linux/spinlock.h:350 [inline]
__inet_inherit_port+0x2b5/0x18c0 net/ipv4/inet_hashtables.c:230
tcp_v4_syn_recv_sock+0xb5a/0x14b0 net/ipv4/tcp_ipv4.c:1628
tcp_v6_syn_recv_sock+0x14e1/0x2360 net/ipv6/tcp_ipv6.c:1220
tcp_get_cookie_sock+0xcd/0x860 net/ipv4/syncookies.c:207
cookie_v4_check+0x1553/0x25e0 net/ipv4/syncookies.c:448
tcp_v4_cookie_check net/ipv4/tcp_ipv4.c:1670 [inline]
tcp_v4_do_rcv+0x8d9/0x9d0 net/ipv4/tcp_ipv4.c:1730
tcp_v4_rcv+0x306c/0x3280 net/ipv4/tcp_ipv4.c:2132
ip_protocol_deliver_rcu+0x9f/0x480 net/ipv4/ip_input.c:205
ip_local_deliver_finish+0x2ec/0x4f0 net/ipv4/ip_input.c:233
NF_HOOK include/linux/netfilter.h:302 [inline]
NF_HOOK include/linux/netfilter.h:296 [inline]
ip_local_deliver+0x1ae/0x200 net/ipv4/ip_input.c:254
dst_input include/net/dst.h:454 [inline]
ip_rcv_finish+0x1cf/0x2f0 net/ipv4/ip_input.c:449
NF_HOOK include/linux/netfilter.h:302 [inline]
NF_HOOK include/linux/netfilter.h:296 [inline]
ip_rcv+0xae/0xd0 net/ipv4/ip_input.c:569
__netif_receive_skb_one_core+0x114/0x180 net/core/dev.c:5482
__netif_receive_skb+0x1f/0x1c0 net/core/dev.c:5596
process_backlog+0x13e/0x6d0 net/core/dev.c:5924
__napi_poll+0xaf/0x430 net/core/dev.c:6485
napi_poll net/core/dev.c:6552 [inline]
net_rx_action+0x8da/0xc70 net/core/dev.c:6663
__do_softirq+0x2e3/0xae3 kernel/softirq.c:571
do_softirq.part.0+0xde/0x130 kernel/softirq.c:472
do_softirq kernel/softirq.c:464 [inline]
__local_bh_enable_ip+0x106/0x130 kernel/softirq.c:396
local_bh_enable include/linux/bottom_half.h:33 [inline]
rcu_read_unlock_bh include/linux/rcupdate.h:843 [inline]
ip_finish_output2+0x7dc/0x22e0 net/ipv4/ip_output.c:229
__ip_finish_output net/ipv4/ip_output.c:306 [inline]
__ip_finish_output+0x396/0x650 net/ipv4/ip_output.c:288
ip_finish_output+0x31/0x280 net/ipv4/ip_output.c:316
NF_HOOK_COND include/linux/netfilter.h:291 [inline]
ip_output+0x1a3/0x320 net/ipv4/ip_output.c:430
dst_output include/net/dst.h:444 [inline]
ip_local_out net/ipv4/ip_output.c:126 [inline]
__ip_queue_xmit+0x8e2/0x1c60 net/ipv4/ip_output.c:532
__tcp_transmit_skb+0x1967/0x3820 net/ipv4/tcp_output.c:1399
tcp_transmit_skb net/ipv4/tcp_output.c:1417 [inline]
tcp_write_xmit+0x1025/0x6160 net/ipv4/tcp_output.c:2693
__tcp_push_pending_frames+0xae/0x390 net/ipv4/tcp_output.c:2877
tcp_send_fin+0x11b/0xb70 net/ipv4/tcp_output.c:3432
tcp_shutdown net/ipv4/tcp.c:2817 [inline]
tcp_shutdown+0x12b/0x170 net/ipv4/tcp.c:2802
inet_shutdown+0x1ac/0x430 net/ipv4/af_inet.c:901
__sys_shutdown_sock net/socket.c:2343 [inline]
__sys_shutdown_sock net/socket.c:2337 [inline]
__sys_shutdown+0xf5/0x1c0 net/socket.c:2355
__do_sys_shutdown net/socket.c:2363 [inline]
__se_sys_shutdown net/socket.c:2361 [inline]
__x64_sys_shutdown+0x54/0x80 net/socket.c:2361
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x39/0xb0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f549968c0c9
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:00007f549a31c168 EFLAGS: 00000246 ORIG_RAX: 0000000000000030
RAX: ffffffffffffffda RBX: 00007f54997abf80 RCX: 00007f549968c0c9
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000004
RBP: 00007f54996e7ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd1cb92a0f R14: 00007f549a31c300 R15: 0000000000022000
TCP: request_sock_TCP: Possible SYN flooding on port [::]:20002. Sending cookies.
TCP: request_sock_TCP: Possible SYN flooding on port [::]:20002. Sending cookies.
TCP: request_sock_TCP: Possible SYN flooding on port [::]:20002. Sending cookies.
TCP: request_sock_TCP: Possible SYN flooding on port [::]:20002. Sending cookies.
TCP: request_sock_TCP: Possible SYN flooding on port [::]:20002. Sending cookies.