vsock/virtio: free queued packets when closing socket
authorStefano Garzarella <sgarzare@redhat.com>
Tue, 20 Apr 2021 11:07:27 +0000 (13:07 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 21 Apr 2021 00:07:21 +0000 (17:07 -0700)
commit8432b8114957235f42e070a16118a7f750de9d39
tree4bdc098a6897f572515e2d2aaa4481113058f9b6
parenteeddfd8e8d392bc94968d87e7a408ba9e9be4722
vsock/virtio: free queued packets when closing socket

As reported by syzbot [1], there is a memory leak while closing the
socket. We partially solved this issue with commit ac03046ece2b
("vsock/virtio: free packets during the socket release"), but we
forgot to drain the RX queue when the socket is definitely closed by
the scheduled work.

To avoid future issues, let's use the new virtio_transport_remove_sock()
to drain the RX queue before removing the socket from the af_vsock lists
calling vsock_remove_sock().

[1] https://syzkaller.appspot.com/bug?extid=24452624fc4c571eedd9

Fixes: ac03046ece2b ("vsock/virtio: free packets during the socket release")
Reported-and-tested-by: syzbot+24452624fc4c571eedd9@syzkaller.appspotmail.com
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/vmw_vsock/virtio_transport_common.c