[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ef98aad4-f86d-fe60-9a35-792363a78a68@sberdevices.ru>
Date: Sun, 5 Mar 2023 23:08:38 +0300
From: Arseniy Krasnov <avkrasnov@...rdevices.ru>
To: Stefan Hajnoczi <stefanha@...hat.com>,
Stefano Garzarella <sgarzare@...hat.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Bobby Eshleman <bobby.eshleman@...edance.com>
CC: <kvm@...r.kernel.org>, <virtualization@...ts.linux-foundation.org>,
<netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<kernel@...rdevices.ru>, <oxffffaa@...il.com>,
<avkrasnov@...rdevices.ru>
Subject: [RFC PATCH v2 3/4] virtio/vsock: free skb on data copy failure
This fixes two things in case when 'memcpy_to_msg()' fails:
1) Update credit parameters of the socket, like this skbuff was
copied to user successfully. This is needed because when skbuff was
received it's length was used to update 'rx_bytes', thus when we drop
skbuff here, we must account rest of it's data in 'rx_bytes'.
2) Free skbuff which was removed from socket's queue.
Fixes: 71dc9ec9ac7d ("virtio/vsock: replace virtio_vsock_pkt with sk_buff")
Signed-off-by: Arseniy Krasnov <AVKrasnov@...rdevices.ru>
---
net/vmw_vsock/virtio_transport_common.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index 30b0539990ba..ffb1af4f2b52 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -379,8 +379,12 @@ virtio_transport_stream_do_dequeue(struct vsock_sock *vsk,
spin_unlock_bh(&vvs->rx_lock);
err = memcpy_to_msg(msg, skb->data, bytes);
- if (err)
+ if (err) {
+ skb_pull(skb, skb->len);
+ virtio_transport_dec_rx_pkt(vvs, skb);
+ consume_skb(skb);
goto out;
+ }
spin_lock_bh(&vvs->rx_lock);
--
2.25.1
Powered by blists - more mailing lists