[PATCH v2 0/1] virtio-vsock: Fix unbound rx buffer

STALE3662d

Revision v2 of 2 in this series.

4 messages, 3 authors, 2016-08-10 · open the first message on its own page

[PATCH v2 0/1] virtio-vsock: Fix unbound rx buffer

From: <hidden>
Date: 2016-08-04 14:10:38

From: Gerard Garcia <redacted>

This patch applies over VSOCK RFC v6.

Reset connection and close rx socket when the sender is ignoring our
announced available buffer. This avoids a DoS.

v2:
 * Get vvs->rx_lock lock before checking if next packet is going to
    overflow the rx buffer.

Gerard Garcia (1):
  Fix unbound rx buffer

 net/vmw_vsock/virtio_transport_common.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

-- 
2.9.1

[PATCH v2 1/1] Fix unbound rx buffer

From: <hidden>
Date: 2016-08-04 14:10:39

From: Gerard Garcia <redacted>

Reset connection and close rx socket when the sender is ignoring our announced available buffer.

Signed-off-by: Gerard Garcia <redacted>

---
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

Re: [PATCH v2 1/1] Fix unbound rx buffer

From: Stefan Hajnoczi <stefanha@redhat.com>
Date: 2016-08-10 18:22:13

On Thu, Aug 04, 2016 at 04:09:57PM +0200, ggarcia@abra.uab.cat wrote:
From: Gerard Garcia <redacted>

Reset connection and close rx socket when the sender is ignoring our announced available buffer.

Signed-off-by: Gerard Garcia <redacted>

---
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(-)
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>

Re: [PATCH v2 1/1] Fix unbound rx buffer

From: David Miller <davem@davemloft.net>
Date: 2016-08-10 22:12:07

All of these patches need to be resubmitted with a proper subsystem
prefix in the Subject line.

Thank you.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help