kernel_optimize_test/net
Stefano Garzarella 3f74957fcb vsock: fix potential deadlock in transport->release()
Some transports (hyperv, virtio) acquire the sock lock during the
.release() callback.

In the vsock_stream_connect() we call vsock_assign_transport(); if
the socket was previously assigned to another transport, the
vsk->transport->release() is called, but the sock lock is already
held in the vsock_stream_connect(), causing a deadlock reported by
syzbot:

    INFO: task syz-executor280:9768 blocked for more than 143 seconds.
      Not tainted 5.6.0-rc1-syzkaller #0
    "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
    syz-executor280 D27912  9768   9766 0x00000000
    Call Trace:
     context_switch kernel/sched/core.c:3386 [inline]
     __schedule+0x934/0x1f90 kernel/sched/core.c:4082
     schedule+0xdc/0x2b0 kernel/sched/core.c:4156
     __lock_sock+0x165/0x290 net/core/sock.c:2413
     lock_sock_nested+0xfe/0x120 net/core/sock.c:2938
     virtio_transport_release+0xc4/0xd60 net/vmw_vsock/virtio_transport_common.c:832
     vsock_assign_transport+0xf3/0x3b0 net/vmw_vsock/af_vsock.c:454
     vsock_stream_connect+0x2b3/0xc70 net/vmw_vsock/af_vsock.c:1288
     __sys_connect_file+0x161/0x1c0 net/socket.c:1857
     __sys_connect+0x174/0x1b0 net/socket.c:1874
     __do_sys_connect net/socket.c:1885 [inline]
     __se_sys_connect net/socket.c:1882 [inline]
     __x64_sys_connect+0x73/0xb0 net/socket.c:1882
     do_syscall_64+0xfa/0x790 arch/x86/entry/common.c:294
     entry_SYSCALL_64_after_hwframe+0x49/0xbe

To avoid this issue, this patch remove the lock acquiring in the
.release() callback of hyperv and virtio transports, and it holds
the lock when we call vsk->transport->release() in the vsock core.

Reported-by: syzbot+731710996d79d0d58fbc@syzkaller.appspotmail.com
Fixes: 408624af4c ("vsock: use local transport when it is loaded")
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-27 12:03:56 -08:00
..
6lowpan
9p
802
8021q
appletalk
atm
ax25
batman-adv
bluetooth
bpf
bpfilter
bridge net: bridge: fix stale eth hdr pointer in br_dev_xmit 2020-02-24 11:11:19 -08:00
caif
can
ceph
core net: core: devlink.c: Use built-in RCU list checking 2020-02-26 16:59:18 -08:00
dcb
dccp
decnet
dns_resolver
dsa
ethernet
ethtool ethtool: limit bitset size 2020-02-26 11:27:31 -08:00
hsr
ieee802154
ife
ipv4 tcp: fix TFO SYNACK undo to avoid double-timestamp-undo 2020-02-23 17:23:35 -08:00
ipv6 ipv6: restrict IPV6_ADDRFORM operation 2020-02-26 20:20:58 -08:00
iucv
kcm
key
l2tp
l3mdev
lapb
llc
mac80211 mac80211: rx: avoid RCU list traversal under mutex 2020-02-24 10:42:38 +01:00
mac802154
mpls
mptcp mptcp: add dummy icsk_sync_mss() 2020-02-26 20:49:50 -08:00
ncsi
netfilter netfilter: xt_hashlimit: unregister proc file before releasing mutex 2020-02-26 23:25:07 +01:00
netlabel
netlink
netrom
nfc
nsh
openvswitch
packet
phonet
psample
qrtr
rds
rfkill
rose
rxrpc
sched sched: act: count in the size of action flags bitfield 2020-02-26 17:10:44 -08:00
sctp
smc net/smc: check for valid ib_client_data 2020-02-26 20:56:25 -08:00
strparser
sunrpc
switchdev
tipc
tls
unix unix: It's CONFIG_PROC_FS not CONFIG_PROCFS 2020-02-27 11:52:35 -08:00
vmw_vsock vsock: fix potential deadlock in transport->release() 2020-02-27 12:03:56 -08:00
wimax
wireless nl80211: explicitly include if_vlan.h 2020-02-24 10:41:13 +01:00
x25
xdp
xfrm
compat.c
Kconfig
Makefile
socket.c
sysctl_net.c