syzbot


possible deadlock in release_sock

Status: fixed on 2023/06/08 14:41
Subsystems: net
[Documentation on labels]
Reported-by: syzbot+bbd35b345c7cab0d9a08@syzkaller.appspotmail.com
Fix commit: b9fb10d131b8 l2tp: prevent lockdep issue in l2tp_tunnel_register()
First crash: 458d, last: 456d
Cause bisection: introduced by (bisect log) :
commit 0b2c59720e65885a394a017d0cf9cab118914682
Author: Cong Wang <cong.wang@bytedance.com>
Date: Sat Jan 14 03:01:37 2023 +0000

  l2tp: close all race conditions in l2tp_tunnel_register()

Crash: possible deadlock in release_sock (log)
Repro: C syz .config
  
Discussions (2)
Title Replies (including bot) Last reply
[PATCH net] l2tp: prevent lockdep issue in l2tp_tunnel_register() 4 (4) 2023/01/18 17:10
[syzbot] possible deadlock in release_sock 1 (3) 2023/01/18 13:11

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
6.2.0-rc3-syzkaller-00197-g87b93b678e95 #0 Not tainted
------------------------------------------------------
syz-executor131/5064 is trying to acquire lock:
ffff888017b6b370 (slock-AF_INET){+.-.}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:355 [inline]
ffff888017b6b370 (slock-AF_INET){+.-.}-{2:2}, at: release_sock+0x1f/0x1b0 net/core/sock.c:3483

but task is already holding lock:
ffff888017b6b678 (clock-AF_INET){++..}-{2:2}, at: l2tp_tunnel_register+0x2be/0x11e0 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_INET){++..}-{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/0x2660 net/ipv4/inet_connection_sock.c:532
       inet_csk_listen_start+0x1ad/0x440 net/ipv4/inet_connection_sock.c:1237
       inet_listen+0x235/0x640 net/ipv4/af_inet.c:228
       __sys_listen+0x181/0x250 net/socket.c:1810
       __do_sys_listen net/socket.c:1819 [inline]
       __se_sys_listen net/socket.c:1817 [inline]
       __x64_sys_listen+0x54/0x80 net/socket.c:1817
       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_inherit_port+0x2b5/0x1840 net/ipv4/inet_hashtables.c:230
       tcp_v4_syn_recv_sock+0xb5b/0x1450 net/ipv4/tcp_ipv4.c:1628
       tcp_check_req+0x632/0x1aa0 net/ipv4/tcp_minisocks.c:803
       tcp_v4_rcv+0x2120/0x3280 net/ipv4/tcp_ipv4.c:2070
       ip_protocol_deliver_rcu+0x9f/0x460 net/ipv4/ip_input.c:205
       ip_local_deliver_finish+0x2ec/0x4c0 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_sublist_rcv_finish+0x9a/0x2c0 net/ipv4/ip_input.c:580
       ip_list_rcv_finish net/ipv4/ip_input.c:630 [inline]
       ip_sublist_rcv+0x533/0x980 net/ipv4/ip_input.c:638
       ip_list_rcv+0x31e/0x470 net/ipv4/ip_input.c:673
       __netif_receive_skb_list_ptype net/core/dev.c:5525 [inline]
       __netif_receive_skb_list_core+0x548/0x8f0 net/core/dev.c:5573
       __netif_receive_skb_list net/core/dev.c:5625 [inline]
       netif_receive_skb_list_internal+0x75f/0xd90 net/core/dev.c:5716
       gro_normal_list include/net/gro.h:433 [inline]
       gro_normal_list include/net/gro.h:429 [inline]
       napi_complete_done+0x243/0x960 net/core/dev.c:6056
       virtqueue_napi_complete drivers/net/virtio_net.c:405 [inline]
       virtnet_poll+0xd08/0x1300 drivers/net/virtio_net.c:1682
       __napi_poll+0xb8/0x770 net/core/dev.c:6485
       napi_poll net/core/dev.c:6552 [inline]
       net_rx_action+0xa00/0xde0 net/core/dev.c:6663
       __do_softirq+0x1fb/0xadc kernel/softirq.c:571
       invoke_softirq kernel/softirq.c:445 [inline]
       __irq_exit_rcu+0x123/0x180 kernel/softirq.c:650
       irq_exit_rcu+0x9/0x20 kernel/softirq.c:662
       sysvec_apic_timer_interrupt+0x97/0xc0 arch/x86/kernel/apic/apic.c:1107
       asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:649
       native_safe_halt arch/x86/include/asm/irqflags.h:51 [inline]
       arch_safe_halt arch/x86/include/asm/irqflags.h:89 [inline]
       acpi_safe_halt drivers/acpi/processor_idle.c:112 [inline]
       acpi_idle_do_entry+0x1fd/0x2a0 drivers/acpi/processor_idle.c:570
       acpi_idle_enter+0x368/0x510 drivers/acpi/processor_idle.c:707
       cpuidle_enter_state+0x1af/0xd40 drivers/cpuidle/cpuidle.c:239
       cpuidle_enter+0x4e/0xa0 drivers/cpuidle/cpuidle.c:356
       call_cpuidle kernel/sched/idle.c:155 [inline]
       cpuidle_idle_call kernel/sched/idle.c:236 [inline]
       do_idle+0x3f7/0x590 kernel/sched/idle.c:303
       cpu_startup_entry+0x18/0x20 kernel/sched/idle.c:400
       start_secondary+0x256/0x300 arch/x86/kernel/smpboot.c:264
       secondary_startup_64_no_verify+0xce/0xdb

-> #0 (slock-AF_INET){+.-.}-{2:2}:
       check_prev_add kernel/locking/lockdep.c:3097 [inline]
       check_prevs_add kernel/locking/lockdep.c:3216 [inline]
       validate_chain kernel/locking/lockdep.c:3831 [inline]
       __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5055
       lock_acquire kernel/locking/lockdep.c:5668 [inline]
       lock_acquire+0x1e3/0x630 kernel/locking/lockdep.c:5633
       __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+0x3db/0x11e0 net/l2tp/l2tp_core.c:1487
       l2tp_nl_cmd_tunnel_create+0x3d6/0x8b0 net/l2tp/l2tp_netlink.c:245
       genl_family_rcv_msg_doit.isra.0+0x1e6/0x2d0 net/netlink/genetlink.c:968
       genl_family_rcv_msg net/netlink/genetlink.c:1048 [inline]
       genl_rcv_msg+0x4ff/0x7e0 net/netlink/genetlink.c:1065
       netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2564
       genl_rcv+0x28/0x40 net/netlink/genetlink.c:1076
       netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
       netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1356
       netlink_sendmsg+0x91b/0xe10 net/netlink/af_netlink.c:1932
       sock_sendmsg_nosec net/socket.c:714 [inline]
       sock_sendmsg+0xd3/0x120 net/socket.c:734
       ____sys_sendmsg+0x712/0x8c0 net/socket.c:2476
       ___sys_sendmsg+0x110/0x1b0 net/socket.c:2530
       __sys_sendmsg+0xf7/0x1c0 net/socket.c:2559
       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_INET --> &tcp_hashinfo.bhash[i].lock --> clock-AF_INET

 Possible unsafe locking scenario:

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

 *** DEADLOCK ***

4 locks held by syz-executor131/5064:
 #0: ffffffff8e159a10 (cb_lock){++++}-{3:3}, at: genl_rcv+0x19/0x40 net/netlink/genetlink.c:1075
 #1: ffffffff8e159ac8 (genl_mutex){+.+.}-{3:3}, at: genl_lock net/netlink/genetlink.c:33 [inline]
 #1: ffffffff8e159ac8 (genl_mutex){+.+.}-{3:3}, at: genl_rcv_msg+0x51a/0x7e0 net/netlink/genetlink.c:1063
 #2: ffff888017b6b3f0 (sk_lock-AF_INET){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1725 [inline]
 #2: ffff888017b6b3f0 (sk_lock-AF_INET){+.+.}-{0:0}, at: l2tp_tunnel_register+0x2aa/0x11e0 net/l2tp/l2tp_core.c:1483
 #3: ffff888017b6b678 (clock-AF_INET){++..}-{2:2}, at: l2tp_tunnel_register+0x2be/0x11e0 net/l2tp/l2tp_core.c:1484

stack backtrace:
CPU: 0 PID: 5064 Comm: syz-executor131 Not tainted 6.2.0-rc3-syzkaller-00197-g87b93b678e95 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
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:2177
 check_prev_add kernel/locking/lockdep.c:3097 [inline]
 check_prevs_add kernel/locking/lockdep.c:3216 [inline]
 validate_chain kernel/locking/lockdep.c:3831 [inline]
 __lock_acquire+0x2a43/0x56d0 kernel/locking/lockdep.c:5055
 lock_acquire kernel/locking/lockdep.c:5668 [inline]
 lock_acquire+0x1e3/0x630 kernel/locking/lockdep.c:5633
 __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+0x3db/0x11e0 net/l2tp/l2tp_core.c:1487
 l2tp_nl_cmd_tunnel_create+0x3d6/0x8b0 net/l2tp/l2tp_netlink.c:245
 genl_family_rcv_msg_doit.isra.0+0x1e6/0x2d0 net/netlink/genetlink.c:968
 genl_family_rcv_msg net/netlink/genetlink.c:1048 [inline]
 genl_rcv_msg+0x4ff/0x7e0 net/netlink/genetlink.c:1065
 netlink_rcv_skb+0x165/0x440 net/netlink/af_netlink.c:2564
 genl_rcv+0x28/0x40 net/netlink/genetlink.c:1076
 netlink_unicast_kernel net/netlink/af_netlink.c:1330 [inline]
 netlink_unicast+0x547/0x7f0 net/netlink/af_netlink.c:1356
 netlink_sendmsg+0x91b/0xe10 net/netlink/af_netlink.c:1932
 sock_sendmsg_nosec net/socket.c:714 [inline]
 sock_sendmsg+0xd3/0x120 net/socket.c:734
 ____sys_sendmsg+0x712/0x8c0 net/socket.c:2476
 ___sys_sendmsg+0x110/0x1b0 net/socket.c:2530
 __sys_sendmsg+0xf7/0x1c0 net/socket.c:2559
 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:0x7f82e5a4fbe9
Code: 28 c3 e8 5a 14 00 00 66 2e 0f 1f 84 00 00 00 00 00 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007

Crashes (42):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/01/17 08:29 net-old 87b93b678e95 a63719e7 .config console log report syz C ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/17 15:13 linux-next 9ce08dd7ea24 a63719e7 .config strace log report syz C ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/18 11:31 net-old 010a74f52203 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/18 10:17 net-old 010a74f52203 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/18 09:29 net-old 010a74f52203 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/18 09:07 net-old 010a74f52203 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/18 07:26 net-old 010a74f52203 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/18 01:11 net-old 1f3bd64ad921 aedf5331 .config console log report info ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/18 01:02 net-old 1f3bd64ad921 aedf5331 .config console log report info ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/17 19:50 net-old 1f3bd64ad921 aedf5331 .config console log report info ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/17 19:08 net-old 1f3bd64ad921 aedf5331 .config console log report info ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/17 18:18 net-old 1f3bd64ad921 aedf5331 .config console log report info ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/17 18:10 net-old 1f3bd64ad921 aedf5331 .config console log report info ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/17 11:15 net-old 87b93b678e95 a63719e7 .config console log report info ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/17 10:47 net-old 87b93b678e95 a63719e7 .config console log report info ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/17 09:26 net-old 87b93b678e95 a63719e7 .config console log report info ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/17 07:12 net-old 87b93b678e95 a63719e7 .config console log report info ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/17 07:03 net-old 87b93b678e95 a63719e7 .config console log report info ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/17 06:45 net-old 87b93b678e95 a63719e7 .config console log report info ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/17 05:59 net-old 87b93b678e95 a63719e7 .config console log report info ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/17 05:51 net-old 87b93b678e95 a63719e7 .config console log report info ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/17 05:49 net-old 87b93b678e95 a63719e7 .config console log report info ci-upstream-net-this-kasan-gce possible deadlock in release_sock
2023/01/19 08:49 linux-next f3381a7baf5c 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/19 06:10 linux-next f3381a7baf5c 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/19 06:03 linux-next f3381a7baf5c 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/19 05:07 linux-next f3381a7baf5c 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/18 17:23 linux-next f3381a7baf5c 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/18 07:20 linux-next f3381a7baf5c 42660d9e .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/17 22:23 linux-next 9ce08dd7ea24 aedf5331 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/17 21:33 linux-next 9ce08dd7ea24 aedf5331 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/17 20:43 linux-next 9ce08dd7ea24 aedf5331 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/17 19:19 linux-next 9ce08dd7ea24 aedf5331 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/17 19:00 linux-next 9ce08dd7ea24 aedf5331 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/17 18:15 linux-next 9ce08dd7ea24 aedf5331 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/17 13:54 linux-next 9ce08dd7ea24 a63719e7 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/17 12:16 linux-next 9ce08dd7ea24 a63719e7 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/17 11:00 linux-next 9ce08dd7ea24 a63719e7 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/17 10:08 linux-next 9ce08dd7ea24 a63719e7 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/17 09:04 linux-next 9ce08dd7ea24 a63719e7 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/17 08:32 linux-next 9ce08dd7ea24 a63719e7 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/17 07:37 linux-next 9ce08dd7ea24 a63719e7 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
2023/01/17 06:32 linux-next 9ce08dd7ea24 a63719e7 .config console log report info ci-upstream-linux-next-kasan-gce-root possible deadlock in release_sock
* Struck through repros no longer work on HEAD.