lkml.org 
[lkml]   [2020]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH net] vsock: fix potential deadlock in transport->release()
On Wed, Feb 26, 2020 at 11:58:18AM +0100, Stefano Garzarella wrote:
> 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: 408624af4c89 ("vsock: use local transport when it is loaded")
> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
> ---
> net/vmw_vsock/af_vsock.c | 20 ++++++++++++--------
> net/vmw_vsock/hyperv_transport.c | 3 ---
> net/vmw_vsock/virtio_transport_common.c | 2 --
> 3 files changed, 12 insertions(+), 13 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2020-02-27 17:12    [W:0.038 / U:0.232 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site