Thread (4 messages) flat view 4 messages, 3 authors, 2016-08-04

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

From: David Miller <davem@davemloft.net>
Date: 2016-08-03 18:43:48

From: ggarcia@abra.uab.cat
Date: Mon, 01 Aug 2016 19:18:21 +0200
quoted hunk ↗ jump to hunk
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>
---
 net/vmw_vsock/virtio_transport_common.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index a53b3a1..3c38d43 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -773,13 +773,23 @@ virtio_transport_recv_connected(struct sock *sk,
 		pkt->len = le32_to_cpu(pkt->hdr.len);
 		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) {
+			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);
+
+			sk->sk_data_ready(sk);
+			return err;
+		} else {
+			/* Sender is ignoring our buf_alloc */
+			spin_unlock_bh(&vvs->rx_lock);
You don't hold vvs->rx_lock here, so it's a bug to try and release it.

I'd also expect the maintainers of this driver to give some feedback
before I apply this.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help