[<prev] [next>] [day] [month] [year] [list]
Message-id: <20160812140243.17170-1-ggarcia@deic.uab.cat>
Date: Fri, 12 Aug 2016 16:02:43 +0200
From: ggarcia@...a.uab.cat
To: netdev@...r.kernel.org
Cc: stefanha@...hat.com, mst@...hat.com,
Gerard Garcia <ggarcia@...a.uab.cat>
Subject: [PATCH v3] virtio-vsock: Fix unbound rx buffer
From: Gerard Garcia <ggarcia@...c.uab.cat>
Reset connection and close rx socket when the sender is ignoring our announced
available buffer.
Signed-off-by: Gerard Garcia <ggarcia@...c.uab.cat>
Acked-by: Stefan Hajnoczi <stefanha@...hat.com>
---
Applies over mst/vhost: http://git.kernel.org/cgit/linux/kernel/git/mst/vhost.git
v3:
* Add subsystem prefix.
v2:
* Get vvs->rx_lock lock before checking if next packet is going to
overflow the rx buffer.
net/vmw_vsock/virtio_transport_common.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index a53b3a1..8d4abb6 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -774,12 +774,22 @@ virtio_transport_recv_connected(struct sock *sk,
pkt->off = 0;
spin_lock_bh(&vvs->rx_lock);
- virtio_transport_inc_rx_pkt(vvs, pkt);
- list_add_tail(&pkt->list, &vvs->rx_queue);
- spin_unlock_bh(&vvs->rx_lock);
+ if (vvs->rx_bytes + pkt->len <= vvs->buf_size) {
+ virtio_transport_inc_rx_pkt(vvs, pkt);
+ list_add_tail(&pkt->list, &vvs->rx_queue);
+ spin_unlock_bh(&vvs->rx_lock);
+
+ sk->sk_data_ready(sk);
+ return err;
+ } else {
+ /* Sender is ignoring our buf_alloc */
+ spin_unlock_bh(&vvs->rx_lock);
+
+ virtio_transport_reset(vsk, pkt);
+ virtio_transport_do_close(vsk, true);
+ break;
+ }
- sk->sk_data_ready(sk);
- return err;
case VIRTIO_VSOCK_OP_CREDIT_UPDATE:
sk->sk_write_space(sk);
break;
--
2.9.1
Powered by blists - more mailing lists