syzbot


possible deadlock in xt_find_table_lock

Status: closed as dup on 2018/01/30 09:07
Subsystems: netfilter
[Documentation on labels]
Reported-by: syzbot+ed1af231da07c4aee030@syzkaller.appspotmail.com
First crash: 2280d, last: 2278d
Duplicate of
Title Repro Cause bisect Fix bisect Count Last Reported
possible deadlock in do_ip_getsockopt netfilter 22 2276d 2281d
Discussions (1)
Title Replies (including bot) Last reply
possible deadlock in xt_find_table_lock 1 (2) 2018/01/30 09:04
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 possible deadlock in xt_find_table_lock C 4113 425d 1522d 0/1 upstream: reported C repro on 2020/02/26 14:41
upstream possible deadlock in xt_find_table_lock (2) netfilter 4 2269d 2268d 4/26 fixed on 2018/02/26 20:04

Sample crash report:
======================================================
WARNING: possible circular locking dependency detected
4.15.0-rc9+ #218 Not tainted
------------------------------------------------------
syz-executor1/5914 is trying to acquire lock:
 (&xt[i].mutex){+.+.}, at: [<00000000c86f7ab5>] xt_find_table_lock+0x3e/0x3e0 net/netfilter/x_tables.c:1036

but task is already holding lock:
 (sk_lock-AF_INET6){+.+.}, at: [<00000000d62f351f>] lock_sock include/net/sock.h:1463 [inline]
 (sk_lock-AF_INET6){+.+.}, at: [<00000000d62f351f>] ipv6_getsockopt+0x1c5/0x2e0 net/ipv6/ipv6_sockglue.c:1377

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #2 (sk_lock-AF_INET6){+.+.}:
       lock_sock_nested+0xc2/0x110 net/core/sock.c:2780
       lock_sock include/net/sock.h:1463 [inline]
       do_ipv6_setsockopt.isra.8+0x3c5/0x39d0 net/ipv6/ipv6_sockglue.c:167
       ipv6_setsockopt+0xd7/0x150 net/ipv6/ipv6_sockglue.c:922
       udpv6_setsockopt+0x45/0x80 net/ipv6/udp.c:1422
       sock_common_setsockopt+0x95/0xd0 net/core/sock.c:2978
       SYSC_setsockopt net/socket.c:1849 [inline]
       SyS_setsockopt+0x189/0x360 net/socket.c:1828
       entry_SYSCALL_64_fastpath+0x29/0xa0

-> #1 (rtnl_mutex){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0x16f/0x1a80 kernel/locking/mutex.c:893
       mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:908
       rtnl_lock+0x17/0x20 net/core/rtnetlink.c:74
       unregister_netdevice_notifier+0x91/0x4e0 net/core/dev.c:1673
       tee_tg_destroy+0x61/0xc0 net/netfilter/xt_TEE.c:123
       cleanup_entry+0x218/0x350 net/ipv4/netfilter/ip_tables.c:659
       __do_replace+0x79d/0xa50 net/ipv4/netfilter/ip_tables.c:1094
       do_replace net/ipv4/netfilter/ip_tables.c:1150 [inline]
       do_ipt_set_ctl+0x40f/0x5f0 net/ipv4/netfilter/ip_tables.c:1680
       nf_sockopt net/netfilter/nf_sockopt.c:106 [inline]
       nf_setsockopt+0x67/0xc0 net/netfilter/nf_sockopt.c:115
       ip_setsockopt+0xa1/0xb0 net/ipv4/ip_sockglue.c:1260
       sctp_setsockopt+0x2b6/0x61d0 net/sctp/socket.c:4141
       sock_common_setsockopt+0x95/0xd0 net/core/sock.c:2978
       SYSC_setsockopt net/socket.c:1849 [inline]
       SyS_setsockopt+0x189/0x360 net/socket.c:1828
       entry_SYSCALL_64_fastpath+0x29/0xa0

-> #0 (&xt[i].mutex){+.+.}:
       lock_acquire+0x1d5/0x580 kernel/locking/lockdep.c:3914
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0x16f/0x1a80 kernel/locking/mutex.c:893
       mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:908
       xt_find_table_lock+0x3e/0x3e0 net/netfilter/x_tables.c:1036
       get_entries net/ipv6/netfilter/ip6_tables.c:1050 [inline]
       do_ip6t_get_ctl+0x432/0xaf0 net/ipv6/netfilter/ip6_tables.c:1719
       nf_sockopt net/netfilter/nf_sockopt.c:104 [inline]
       nf_getsockopt+0x6a/0xc0 net/netfilter/nf_sockopt.c:122
       ipv6_getsockopt+0x1df/0x2e0 net/ipv6/ipv6_sockglue.c:1378
       udpv6_getsockopt+0x45/0x80 net/ipv6/udp.c:1441
       sock_common_getsockopt+0x95/0xd0 net/core/sock.c:2937
       SYSC_getsockopt net/socket.c:1880 [inline]
       SyS_getsockopt+0x178/0x340 net/socket.c:1862
       entry_SYSCALL_64_fastpath+0x29/0xa0

other info that might help us debug this:

Chain exists of:
  &xt[i].mutex --> rtnl_mutex --> sk_lock-AF_INET6

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(sk_lock-AF_INET6);
                               lock(rtnl_mutex);
                               lock(sk_lock-AF_INET6);
  lock(&xt[i].mutex);

 *** DEADLOCK ***

1 lock held by syz-executor1/5914:
 #0:  (sk_lock-AF_INET6){+.+.}, at: [<00000000d62f351f>] lock_sock include/net/sock.h:1463 [inline]
 #0:  (sk_lock-AF_INET6){+.+.}, at: [<00000000d62f351f>] ipv6_getsockopt+0x1c5/0x2e0 net/ipv6/ipv6_sockglue.c:1377

stack backtrace:
CPU: 1 PID: 5914 Comm: syz-executor1 Not tainted 4.15.0-rc9+ #218
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x194/0x257 lib/dump_stack.c:53
 print_circular_bug.isra.37+0x2cd/0x2dc kernel/locking/lockdep.c:1218
 check_prev_add kernel/locking/lockdep.c:1858 [inline]
 check_prevs_add kernel/locking/lockdep.c:1971 [inline]
 validate_chain kernel/locking/lockdep.c:2412 [inline]
 __lock_acquire+0x30a8/0x3e00 kernel/locking/lockdep.c:3426
 lock_acquire+0x1d5/0x580 kernel/locking/lockdep.c:3914
 __mutex_lock_common kernel/locking/mutex.c:756 [inline]
 __mutex_lock+0x16f/0x1a80 kernel/locking/mutex.c:893
 mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:908
 xt_find_table_lock+0x3e/0x3e0 net/netfilter/x_tables.c:1036
 get_entries net/ipv6/netfilter/ip6_tables.c:1050 [inline]
 do_ip6t_get_ctl+0x432/0xaf0 net/ipv6/netfilter/ip6_tables.c:1719
 nf_sockopt net/netfilter/nf_sockopt.c:104 [inline]
 nf_getsockopt+0x6a/0xc0 net/netfilter/nf_sockopt.c:122
 ipv6_getsockopt+0x1df/0x2e0 net/ipv6/ipv6_sockglue.c:1378
 udpv6_getsockopt+0x45/0x80 net/ipv6/udp.c:1441
 sock_common_getsockopt+0x95/0xd0 net/core/sock.c:2937
 SYSC_getsockopt net/socket.c:1880 [inline]
 SyS_getsockopt+0x178/0x340 net/socket.c:1862
 entry_SYSCALL_64_fastpath+0x29/0xa0
RIP: 0033:0x453299
RSP: 002b:00007fc9f6183c58 EFLAGS: 00000212 ORIG_RAX: 0000000000000037
RAX: ffffffffffffffda RBX: 000000000071bea0 RCX: 0000000000453299
RDX: 0000000000000041 RSI: 0000000000000029 RDI: 0000000000000014
RBP: 0000000000000389 R08: 0000000020c7a000 R09: 0000000000000000
R10: 0000000020000000 R11: 0000000000000212 R12: 00000000006f4578
R13: 00000000ffffffff R14: 00007fc9f61846d4 R15: 0000000000000000
A link change request failed with some changes committed already. Interface lo may have been left with an inconsistent configuration, please check.
A link change request failed with some changes committed already. Interface lo may have been left with an inconsistent configuration, please check.
TCP: request_sock_TCPv6: Possible SYN flooding on port 20022. Sending cookies.  Check SNMP counters.
netlink: 'syz-executor6': attribute type 1 has an invalid length.
sctp: [Deprecated]: syz-executor7 (pid 6175) Use of int in maxseg socket option.
Use struct sctp_assoc_value instead
sctp: [Deprecated]: syz-executor7 (pid 6175) Use of int in max_burst socket option deprecated.
Use struct sctp_assoc_value instead
sctp: [Deprecated]: syz-executor7 (pid 6180) Use of int in maxseg socket option.
Use struct sctp_assoc_value instead
sctp: [Deprecated]: syz-executor7 (pid 6180) Use of int in max_burst socket option deprecated.
Use struct sctp_assoc_value instead
syz-executor4 (6405) used greatest stack depth: 15456 bytes left
xt_TCPMSS: Only works on TCP SYN packets
IPv6: RTM_NEWROUTE with no NLM_F_CREATE or NLM_F_REPLACE
IPv6: NLM_F_CREATE should be set when creating new route
IPv6: RTM_NEWROUTE with no NLM_F_CREATE or NLM_F_REPLACE
SELinux: unrecognized netlink message: protocol=4 nlmsg_type=2912 sclass=netlink_tcpdiag_socket pig=6495 comm=syz-executor4
SELinux: unrecognized netlink message: protocol=4 nlmsg_type=2912 sclass=netlink_tcpdiag_socket pig=6507 comm=syz-executor4
netlink: 'syz-executor3': attribute type 11 has an invalid length.
xt_hashlimit: overflow, rate too high: 0
netlink: 8 bytes leftover after parsing attributes in process `syz-executor2'.
netlink: 'syz-executor3': attribute type 11 has an invalid length.
xt_hashlimit: overflow, rate too high: 0
netlink: 8 bytes leftover after parsing attributes in process `syz-executor2'.
kauditd_printk_skb: 22 callbacks suppressed
audit: type=1400 audit(1517430977.470:44): avc:  denied  { map } for  pid=6724 comm="syz-executor3" path="socket:[16823]" dev="sockfs" ino=16823 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=tcp_socket permissive=1
netlink: 'syz-executor0': attribute type 33 has an invalid length.
A link change request failed with some changes committed already. Interface syz0 may have been left with an inconsistent configuration, please check.
sctp: [Deprecated]: syz-executor7 (pid 6811) Use of int in maxseg socket option.
Use struct sctp_assoc_value instead
netlink: 'syz-executor0': attribute type 33 has an invalid length.
A link change request failed with some changes committed already. Interface syz0 may have been left with an inconsistent configuration, please check.
sctp: [Deprecated]: syz-executor7 (pid 6829) Use of int in maxseg socket option.
Use struct sctp_assoc_value instead
netlink: 16 bytes leftover after parsing attributes in process `syz-executor4'.
syz-executor2 (6919) used greatest stack depth: 13360 bytes left
TCP: request_sock_TCP: Possible SYN flooding on port 20009. Sending cookies.  Check SNMP counters.
Cannot find del_set index 0 as target
Cannot find del_set index 0 as target
dccp_invalid_packet: P.Data Offset(172) too large
dccp_invalid_packet: P.Data Offset(172) too large
syz-executor0 uses obsolete (PF_INET,SOCK_PACKET)
netlink: 8 bytes leftover after parsing attributes in process `syz-executor0'.
netlink: 8 bytes leftover after parsing attributes in process `syz-executor0'.
mac80211_hwsim: wmediumd released netlink socket, switching to perfect channel medium
dccp_xmit_packet: Payload too large (65423) for featneg.
dccp_xmit_packet: Payload too large (65423) for featneg.
netlink: 'syz-executor6': attribute type 4 has an invalid length.
netlink: 8 bytes leftover after parsing attributes in process `syz-executor1'.
netlink: 8 bytes leftover after parsing attributes in process `syz-executor1'.
netlink: 'syz-executor6': attribute type 4 has an invalid length.
netlink: 'syz-executor6': attribute type 1 has an invalid length.
netlink: 'syz-executor6': attribute type 1 has an invalid length.
netlink: 'syz-executor6': attribute type 1 has an invalid length.
netlink: 'syz-executor6': attribute type 1 has an invalid length.
dccp_close: ABORT with 4294967275 bytes unread
audit: type=1400 audit(1517430979.072:45): avc:  denied  { create } for  pid=7301 comm="syz-executor4" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_connector_socket permissive=1
audit: type=1400 audit(1517430979.098:46): avc:  denied  { write } for  pid=7301 comm="syz-executor4" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_connector_socket permissive=1
audit: type=1400 audit(1517430979.099:47): avc:  denied  { accept } for  pid=7301 comm="syz-executor4" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_connector_socket permissive=1
audit: type=1400 audit(1517430979.100:48): avc:  denied  { ioctl } for  pid=7301 comm="syz-executor4" path="socket:[17263]" dev="sockfs" ino=17263 ioctlcmd=0x8933 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_connector_socket permissive=1
openvswitch: netlink: Flow set message rejected, Key attribute missing.
openvswitch: netlink: Flow set message rejected, Key attribute missing.
RDS: rds_bind could not find a transport for 224.0.0.2, load rds_tcp or rds_rdma?
RDS: rds_bind could not find a transport for 224.0.0.2, load rds_tcp or rds_rdma?
TCP: request_sock_TCPv6: Possible SYN flooding on port 20006. Sending cookies.  Check SNMP counters.
ipt_CLUSTERIP: Please specify destination IP
ipt_CLUSTERIP: Please specify destination IP
xt_TCPMSS: Only works on TCP SYN packets
audit: type=1400 audit(1517430979.748:49): avc:  denied  { map } for  pid=7566 comm="syz-executor4" path=2F616E6F6E5F6875676570616765202864656C6574656429 dev="hugetlbfs" ino=18495 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:hugetlbfs_t:s0 tclass=file permissive=1
openvswitch: netlink: ufid size 20 bytes exceeds the range (1, 16)
openvswitch: netlink: Flow get message rejected, Key attribute missing.
openvswitch: netlink: ufid size 20 bytes exceeds the range (1, 16)
netlink: 8 bytes leftover after parsing attributes in process `syz-executor3'.
openvswitch: netlink: Flow get message rejected, Key attribute missing.
xt_ipcomp: unknown flags FF
xt_ipcomp: unknown flags FF
audit: type=1400 audit(1517430980.325:50): avc:  denied  { setopt } for  pid=7761 comm="syz-executor1" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_netfilter_socket permissive=1
netlink: 'syz-executor1': attribute type 21 has an invalid length.
netlink: 'syz-executor1': attribute type 21 has an invalid length.
audit: type=1400 audit(1517430981.009:51): avc:  denied  { relabelto } for  pid=8054 comm="syz-executor2" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=system_u:object_r:policy_src_t:s0 tclass=packet permissive=1
l2tp_core: tunl 59: sockfd_lookup(fd=0) returned -88
l2tp_core: tunl 59: sockfd_lookup(fd=0) returned -88
Cannot find add_set index 0 as target
ipt_CLUSTERIP: Please specify destination IP
can: request_module (can-proto-0) failed.
xt_TPROXY: Can be used only in combination with either -p tcp or -p udp
ipt_CLUSTERIP: Please specify destination IP
xt_TPROXY: Can be used only in combination with either -p tcp or -p udp
xt_socket: unknown flags 0xfe
can: request_module (can-proto-0) failed.
Cannot find add_set index 0 as target
xt_socket: unknown flags 0xfe
skbuff: bad partial csum: csum=65535/65535 len=14
device bridge0 entered promiscuous mode
netlink: 4 bytes leftover after parsing attributes in process `syz-executor7'.
device bridge0 left promiscuous mode
audit: type=1400 audit(1517430981.642:52): avc:  denied  { create } for  pid=8306 comm="syz-executor2" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_iscsi_socket permissive=1
netlink: 'syz-executor5': attribute type 2 has an invalid length.
netlink: 'syz-executor5': attribute type 2 has an invalid length.
SELinux: unrecognized netlink message: protocol=4 nlmsg_type=24 sclass=netlink_tcpdiag_socket pig=8453 comm=syz-executor0
SELinux: unrecognized netlink message: protocol=4 nlmsg_type=24 sclass=netlink_tcpdiag_socket pig=8456 comm=syz-executor0
audit: type=1400 audit(1517430982.188:53): avc:  denied  { bind } for  pid=8512 comm="syz-executor6" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_netfilter_socket permissive=1
ipt_ECN: cannot use TCP operations on a non-tcp rule
ipt_ECN: cannot use TCP operations on a non-tcp rule
netlink: 'syz-executor6': attribute type 1 has an invalid length.
netlink: 'syz-executor6': attribute type 1 has an invalid length.
sctp: [Deprecated]: syz-executor2 (pid 8899) Use of int in maxseg socket option.
Use struct sctp_assoc_value instead
audit: type=1400 audit(1517430983.042:54): avc:  denied  { setopt } for  pid=8885 comm="syz-executor5" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=system_u:object_r:unlabeled_t:s0 tclass=socket permissive=1
sctp: [Deprecated]: syz-executor2 (pid 8910) Use of int in maxseg socket option.
Use struct sctp_assoc_value instead
sctp: [Deprecated]: syz-executor4 (pid 8964) Use of struct sctp_assoc_value in delayed_ack socket option.
Use struct sctp_sack_info instead
sctp: [Deprecated]: syz-executor1 (pid 8973) Use of struct sctp_assoc_value in delayed_ack socket option.
Use struct sctp_sack_info instead
sctp: [Deprecated]: syz-executor1 (pid 8980) Use of struct sctp_assoc_value in delayed_ack socket option.
Use struct sctp_sack_info instead
Cannot find del_set index 0 as target
netlink: 5 bytes leftover after parsing attributes in process `syz-executor0'.
netlink: 5 bytes leftover after parsing attributes in process `syz-executor0'.
sctp: [Deprecated]: syz-executor7 (pid 9112) Use of struct sctp_assoc_value in delayed_ack socket option.
Use struct sctp_sack_info instead
sctp: [Deprecated]: syz-executor7 (pid 9137) Use of struct sctp_assoc_value in delayed_ack socket option.
Use struct sctp_sack_info instead
syz-executor7 (9102) used greatest stack depth: 11792 bytes left
net_ratelimit: 5 callbacks suppressed
dccp_close: ABORT with 2 bytes unread
audit: type=1400 audit(1517430984.272:55): avc:  denied  { shutdown } for  pid=9336 comm="syz-executor3" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_netfilter_socket permissive=1
device syz1 entered promiscuous mode
device syz1 left promiscuous mode
audit: type=1400 audit(1517430984.502:56): avc:  denied  { ioctl } for  pid=9433 comm="syz-executor1" path="socket:[19999]" dev="sockfs" ino=19999 ioctlcmd=0x8943 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=netlink_crypto_socket permissive=1
xt_connbytes: Forcing CT accounting to be enabled
validate_nla: 2 callbacks suppressed
netlink: 'syz-executor1': attribute type 3 has an invalid length.
netlink: 'syz-executor1': attribute type 3 has an invalid length.

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/01/31 20:36 net-next-old a54667f6728c 02553e22 .config console log report ci-upstream-net-kasan-gce
2018/01/29 18:00 net-next-old 3e3ab9ccca5b 08d47756 .config console log report ci-upstream-net-kasan-gce
* Struck through repros no longer work on HEAD.