Stefano Garzarella
2023-Jun-01 07:58 UTC
[PATCH net] virtio/vsock: fix sock refcnt bug on owner set failure
On Wed, May 31, 2023 at 07:47:32PM +0000, Bobby Eshleman wrote:>Previous to setting the owner the socket is found via >vsock_find_connected_socket(), which returns sk after a call to >sock_hold(). > >If setting the owner fails, then sock_put() needs to be called. > >Fixes: f9d2b1e146e0 ("virtio/vsock: fix leaks due to missing skb owner") >Signed-off-by: Bobby Eshleman <bobby.eshleman at bytedance.com> >--- > net/vmw_vsock/virtio_transport_common.c | 1 + > 1 file changed, 1 insertion(+) > >diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c >index b769fc258931..f01cd6adc5cb 100644 >--- a/net/vmw_vsock/virtio_transport_common.c >+++ b/net/vmw_vsock/virtio_transport_common.c >@@ -1343,6 +1343,7 @@ void virtio_transport_recv_pkt(struct virtio_transport *t, > > if (!skb_set_owner_sk_safe(skb, sk)) { > WARN_ONCE(1, "receiving vsock socket has sk_refcnt == 0\n"); >+ sock_put(sk);Did you have any warning, issue here? IIUC skb_set_owner_sk_safe() can return false only if the ref counter is 0, so calling a sock_put() on it should have no effect except to produce a warning. Thanks, Stefano
Apparently Analagous Threads
- [PATCH net-next v3 0/3] vsock: add support for sockmap
- [PATCH RFC net-next v5 10/14] virtio/vsock: add VIRTIO_VSOCK_F_DGRAM feature bit
- [PATCH RFC net-next v5 03/14] af_vsock: support multi-transport datagrams
- [PATCH] virtio-vsock: add VIRTIO_VSOCK_F_DGRAM feature bit
- [PATCH] virtio-vsock: add VIRTIO_VSOCK_F_DGRAM feature bit