======================================================
WARNING: possible circular locking dependency detected
6.2.0-rc4-next-20230118-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/7052 is trying to acquire lock:
ffff88802781d9f0 (slock-AF_INET6){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:355 [inline]
ffff88802781d9f0 (slock-AF_INET6){+.-.}-{2:2}, at: release_sock+0x1f/0x1b0 net/core/sock.c:3483

but task is already holding lock:
ffff88802781dcf8 (clock-AF_INET6){++..}-{2:2}, at: l2tp_tunnel_register+0x1c3/0xd80 net/l2tp/l2tp_core.c:1484

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (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

-> #1 (&tcp_hashinfo.bhash[i].lock){+.-.}-{2:2}:
       __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_put_port net/ipv4/inet_hashtables.c:186 [inline]
       inet_put_port+0x280/0x940 net/ipv4/inet_hashtables.c:209
       tcp_v4_destroy_sock+0x352/0x850 net/ipv4/tcp_ipv4.c:2321
       inet_csk_destroy_sock+0x19a/0x450 net/ipv4/inet_connection_sock.c:1175
       __tcp_close+0xb8a/0xf70 net/ipv4/tcp.c:3021
       tcp_close+0x2d/0xc0 net/ipv4/tcp.c:3033
       inet_release+0x132/0x270 net/ipv4/af_inet.c:428
       inet6_release+0x50/0x70 net/ipv6/af_inet6.c:489
       __sock_release+0xcd/0x280 net/socket.c:651
       sock_close+0x1c/0x20 net/socket.c:1390
       __fput+0x27c/0xa90 fs/file_table.c:321
       task_work_run+0x16f/0x270 kernel/task_work.c:179
       resume_user_mode_work include/linux/resume_user_mode.h:49 [inline]
       exit_to_user_mode_loop kernel/entry/common.c:171 [inline]
       exit_to_user_mode_prepare+0x210/0x240 kernel/entry/common.c:204
       __syscall_exit_to_user_mode_work kernel/entry/common.c:286 [inline]
       syscall_exit_to_user_mode+0x1d/0x50 kernel/entry/common.c:297
       do_syscall_64+0x46/0xb0 arch/x86/entry/common.c:86
       entry_SYSCALL_64_after_hwframe+0x63/0xcd

-> #0 (slock-AF_INET6){+.-.}-{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_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

other info that might help us debug this:

Chain exists of:
  slock-AF_INET6 --> &tcp_hashinfo.bhash[i].lock --> clock-AF_INET6

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(clock-AF_INET6);
                               lock(&tcp_hashinfo.bhash[i].lock);
                               lock(clock-AF_INET6);
  lock(slock-AF_INET6);

 *** DEADLOCK ***

3 locks held by syz-executor.0/7052:
 #0: ffff88801e141130 (sk_lock-AF_PPPOX){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1725 [inline]
 #0: ffff88801e141130 (sk_lock-AF_PPPOX){+.+.}-{0:0}, at: pppol2tp_connect+0xadc/0x1a80 net/l2tp/l2tp_ppp.c:675
 #1: ffff88802781da70 (sk_lock-AF_INET6){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1725 [inline]
 #1: ffff88802781da70 (sk_lock-AF_INET6){+.+.}-{0:0}, at: l2tp_tunnel_register+0x1af/0xd80 net/l2tp/l2tp_core.c:1483
 #2: ffff88802781dcf8 (clock-AF_INET6){++..}-{2:2}, at: l2tp_tunnel_register+0x1c3/0xd80 net/l2tp/l2tp_core.c:1484

stack backtrace:
CPU: 1 PID: 7052 Comm: syz-executor.0 Not tainted 6.2.0-rc4-next-20230118-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/12/2023
Call Trace:
 <TASK>
 __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_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
RIP: 0033:0x7f58eb28c0c9
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:00007f58ec01b168 EFLAGS: 00000246 ORIG_RAX: 000000000000002a
RAX: ffffffffffffffda RBX: 00007f58eb3abf80 RCX: 00007f58eb28c0c9
RDX: 000000000000002e RSI: 0000000020000080 RDI: 0000000000000003
RBP: 00007f58eb2e7ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffee3f24adf R14: 00007f58ec01b300 R15: 0000000000022000
 </TASK>