syzbot


possible deadlock in start_sync_thread

Status: public: reported C repro on 2019/04/14 00:00
Reported-by: syzbot+da6fbb7d5548c83a9a19@syzkaller.appspotmail.com
First crash: 2164d, last: 2142d

Sample crash report:
IPv6: ADDRCONF(NETDEV_UP): veth1: link is not ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth1: link becomes ready
IPv6: ADDRCONF(NETDEV_CHANGE): veth0: link becomes ready

======================================================
[ INFO: possible circular locking dependency detected ]
4.9.105-gd7e64f8 #40 Not tainted
-------------------------------------------------------
syz-executor124/3795 is trying to acquire lock:
 (sk_lock-AF_INET){+.+.+.}, at: [<ffffffff832f6a9b>] lock_sock include/net/sock.h:1404 [inline]
 (sk_lock-AF_INET){+.+.+.}, at: [<ffffffff832f6a9b>] set_mcast_if net/netfilter/ipvs/ip_vs_sync.c:1370 [inline]
 (sk_lock-AF_INET){+.+.+.}, at: [<ffffffff832f6a9b>] make_send_sock net/netfilter/ipvs/ip_vs_sync.c:1490 [inline]
 (sk_lock-AF_INET){+.+.+.}, at: [<ffffffff832f6a9b>] start_sync_thread+0x88b/0x1e80 net/netfilter/ipvs/ip_vs_sync.c:1885
but task is already holding lock:
 (rtnl_mutex){+.+.+.}, at: [<ffffffff830b5937>] rtnl_lock+0x17/0x20 net/core/rtnetlink.c:70
which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

       lock_acquire+0x130/0x3e0 kernel/locking/lockdep.c:3756
       __mutex_lock_common kernel/locking/mutex.c:521 [inline]
       mutex_lock_nested+0xc0/0x870 kernel/locking/mutex.c:621
       rtnl_lock+0x17/0x20 net/core/rtnetlink.c:70
       mrtsock_destruct+0x3b/0x1e0 net/ipv4/ipmr.c:1231
       ip_ra_control+0x2c2/0x420 net/ipv4/ip_sockglue.c:360
       do_ip_setsockopt.isra.13+0x15ff/0x2b10 net/ipv4/ip_sockglue.c:1139
       ip_setsockopt+0x3a/0xb0 net/ipv4/ip_sockglue.c:1242
       raw_setsockopt+0xb7/0xd0 net/ipv4/raw.c:833
       sock_common_setsockopt+0x9a/0xe0 net/core/sock.c:2706
       SYSC_setsockopt net/socket.c:1772 [inline]
       SyS_setsockopt+0x166/0x260 net/socket.c:1751
       do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
       entry_SYSCALL_64_after_swapgs+0x5d/0xdb

       check_prev_add kernel/locking/lockdep.c:1828 [inline]
       check_prevs_add kernel/locking/lockdep.c:1938 [inline]
       validate_chain kernel/locking/lockdep.c:2265 [inline]
       __lock_acquire+0x3019/0x4070 kernel/locking/lockdep.c:3345
       lock_acquire+0x130/0x3e0 kernel/locking/lockdep.c:3756
       lock_sock_nested+0xc6/0x120 net/core/sock.c:2511
       lock_sock include/net/sock.h:1404 [inline]
       set_mcast_if net/netfilter/ipvs/ip_vs_sync.c:1370 [inline]
       make_send_sock net/netfilter/ipvs/ip_vs_sync.c:1490 [inline]
       start_sync_thread+0x88b/0x1e80 net/netfilter/ipvs/ip_vs_sync.c:1885
       do_ip_vs_set_ctl+0x90f/0xbb0 net/netfilter/ipvs/ip_vs_ctl.c:2396
       nf_sockopt net/netfilter/nf_sockopt.c:105 [inline]
       nf_setsockopt+0x6d/0xc0 net/netfilter/nf_sockopt.c:114
       ip_setsockopt+0x9a/0xb0 net/ipv4/ip_sockglue.c:1249
       udp_setsockopt+0x4a/0x90 net/ipv4/udp.c:2091
       ipv6_setsockopt+0x10a/0x130 net/ipv6/ipv6_sockglue.c:901
       tcp_setsockopt+0x88/0xe0 net/ipv4/tcp.c:2758
       sock_common_setsockopt+0x9a/0xe0 net/core/sock.c:2706
       SYSC_setsockopt net/socket.c:1772 [inline]
       SyS_setsockopt+0x166/0x260 net/socket.c:1751
       do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
       entry_SYSCALL_64_after_swapgs+0x5d/0xdb

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(rtnl_mutex);
                               lock(sk_lock-AF_INET);
                               lock(rtnl_mutex);
  lock(sk_lock-AF_INET);

 *** DEADLOCK ***

2 locks held by syz-executor124/3795:
 #0:  (rtnl_mutex){+.+.+.}, at: [<ffffffff830b5937>] rtnl_lock+0x17/0x20 net/core/rtnetlink.c:70
 #1:  (ipvs->sync_mutex){+.+.+.}, at: [<ffffffff832f6328>] start_sync_thread+0x118/0x1e80 net/netfilter/ipvs/ip_vs_sync.c:1779

stack backtrace:
CPU: 0 PID: 3795 Comm: syz-executor124 Not tainted 4.9.105-gd7e64f8 #40
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
 ffff8801d9747538 ffffffff81eb41a9 ffffffff855e7690 ffffffff8559cf30
 ffffffff855e7690 ffff8801b752a0e8 ffff8801b7529800 ffff8801d9747580
 ffffffff8142679d 0000000000000001 00000000b7529800 0000000000000001
Call Trace:
 [<ffffffff81eb41a9>] __dump_stack lib/dump_stack.c:15 [inline]
 [<ffffffff81eb41a9>] dump_stack+0xc1/0x128 lib/dump_stack.c:51
 [<ffffffff8142679d>] print_circular_bug.cold.51+0x1bd/0x27d kernel/locking/lockdep.c:1202
 [<ffffffff812396b9>] check_prev_add kernel/locking/lockdep.c:1828 [inline]
 [<ffffffff812396b9>] check_prevs_add kernel/locking/lockdep.c:1938 [inline]
 [<ffffffff812396b9>] validate_chain kernel/locking/lockdep.c:2265 [inline]
 [<ffffffff812396b9>] __lock_acquire+0x3019/0x4070 kernel/locking/lockdep.c:3345
 [<ffffffff8123b180>] lock_acquire+0x130/0x3e0 kernel/locking/lockdep.c:3756
 [<ffffffff830246a6>] lock_sock_nested+0xc6/0x120 net/core/sock.c:2511
 [<ffffffff832f6a9b>] lock_sock include/net/sock.h:1404 [inline]
 [<ffffffff832f6a9b>] set_mcast_if net/netfilter/ipvs/ip_vs_sync.c:1370 [inline]
 [<ffffffff832f6a9b>] make_send_sock net/netfilter/ipvs/ip_vs_sync.c:1490 [inline]
 [<ffffffff832f6a9b>] start_sync_thread+0x88b/0x1e80 net/netfilter/ipvs/ip_vs_sync.c:1885
 [<ffffffff832e399f>] do_ip_vs_set_ctl+0x90f/0xbb0 net/netfilter/ipvs/ip_vs_ctl.c:2396
 [<ffffffff831df12d>] nf_sockopt net/netfilter/nf_sockopt.c:105 [inline]
 [<ffffffff831df12d>] nf_setsockopt+0x6d/0xc0 net/netfilter/nf_sockopt.c:114
 [<ffffffff8334931a>] ip_setsockopt+0x9a/0xb0 net/ipv4/ip_sockglue.c:1249
 [<ffffffff833f7d7a>] udp_setsockopt+0x4a/0x90 net/ipv4/udp.c:2091
 [<ffffffff835b4cea>] ipv6_setsockopt+0x10a/0x130 net/ipv6/ipv6_sockglue.c:901
 [<ffffffff833691f8>] tcp_setsockopt+0x88/0xe0 net/ipv4/tcp.c:2758
 [<ffffffff8301d75a>] sock_common_setsockopt+0x9a/0xe0 net/core/sock.c:2706
 [<ffffffff8301a516>] SYSC_setsockopt net/socket.c:1772 [inline]
 [<ffffffff8301a516>] SyS_setsockopt+0x166/0x260 net/socket.c:1751
 [<ffffffff81006316>] do_syscall_64+0x1a6/0x490 arch/x86/entry/common.c:282
 [<ffffffff839f9b13>] entry_SYSCALL_64_after_swapgs+0x5d/0xdb
IPVS: sync thread started: state = MASTER, mcast_ifn = veth0_to_bridge, syncid = 3, id = 0

Crashes (9):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/06/04 09:39 https://android.googlesource.com/kernel/common android-4.9 d7e64f8022e4 6cbe7c26 .config console log report syz C ci-android-49-kasan-gce-root
2018/06/26 13:12 https://android.googlesource.com/kernel/common android-4.9 00a0bcbfcfb6 089f1181 .config console log report ci-android-49-kasan-gce-root
2018/06/24 05:34 https://android.googlesource.com/kernel/common android-4.9 7cecc756ceae 2064fc5c .config console log report ci-android-49-kasan-gce-root
2018/06/19 08:47 https://android.googlesource.com/kernel/common android-4.9 e1815b3eba5b 45c54f75 .config console log report ci-android-49-kasan-gce-root
2018/06/19 01:47 https://android.googlesource.com/kernel/common android-4.9 e1815b3eba5b 45c54f75 .config console log report ci-android-49-kasan-gce-root
2018/06/17 11:34 https://android.googlesource.com/kernel/common android-4.9 a4230beab30a 27c5f59f .config console log report ci-android-49-kasan-gce-root
2018/06/09 15:04 https://android.googlesource.com/kernel/common android-4.9 db2c520bb56b 866118af .config console log report ci-android-49-kasan-gce-root
2018/06/06 21:35 https://android.googlesource.com/kernel/common android-4.9 42a730adb6e2 e0e534c6 .config console log report ci-android-49-kasan-gce-root
2018/06/04 08:19 https://android.googlesource.com/kernel/common android-4.9 d7e64f8022e4 6cbe7c26 .config console log report ci-android-49-kasan-gce-root
* Struck through repros no longer work on HEAD.