virtio/vsock: fix leaks due to missing skb owner
authorBobby Eshleman <bobby.eshleman@bytedance.com>
Wed, 29 Mar 2023 16:51:58 +0000 (16:51 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:52:19 +0000 (11:52 +0100)
commita6650e78c428841da5d68904475c5d177f3d11ee
treec6b2608a6833da029b1e535827792aa498433b3b
parentbb1c9a5907d25742c0285e9d7fa518b9f237c944
virtio/vsock: fix leaks due to missing skb owner

commit f9d2b1e146e0f82f3d04629afd92698522058361 upstream.

This patch sets the skb owner in the recv and send path for virtio.

For the send path, this solves the leak caused when
virtio_transport_purge_skbs() finds skb->sk is always NULL and therefore
never matches it with the current socket. Setting the owner upon
allocation fixes this.

For the recv path, this ensures correctness of accounting and also
correct transfer of ownership in vsock_loopback (when skbs are sent from
one socket and received by another).

Fixes: 71dc9ec9ac7d ("virtio/vsock: replace virtio_vsock_pkt with sk_buff")
Signed-off-by: Bobby Eshleman <bobby.eshleman@bytedance.com>
Reported-by: Cong Wang <xiyou.wangcong@gmail.com>
Link: https://lore.kernel.org/all/ZCCbATwov4U+GBUv@pop-os.localdomain/
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/vmw_vsock/virtio_transport_common.c