public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio-net: fix data corruption with OOM
@ 2009-10-25 17:03 Michael S. Tsirkin
  2009-10-26  1:41 ` Rusty Russell
  0 siblings, 1 reply; 8+ messages in thread
From: Michael S. Tsirkin @ 2009-10-25 17:03 UTC (permalink / raw)
  To: virtualization, kvm, Rusty Russell

virtio net used to unlink skbs from send queues on error,
but ever since 48925e372f04f5e35fec6269127c62b2c71ab794
we do not do this. This causes guest data corruption and crashes
with vhost since net core can requeue the skb or free it without
it being taken off the list.

This patch fixes this by queueing the skb after successfull
transmit.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---

Rusty, here's a fix for another data corrupter I saw.
This fixes a regression from 2.6.31, so definitely
2.6.32 I think. Comments?

 drivers/net/virtio_net.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 8d00976..be459e1 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -517,8 +517,7 @@ again:
 	/* Free up any pending old buffers before queueing new ones. */
 	free_old_xmit_skbs(vi);
 
-	/* Put new one in send queue and do transmit */
-	__skb_queue_head(&vi->send, skb);
+	/* Try to transmit */
 	capacity = xmit_skb(vi, skb);
 
 	/* This can happen with OOM and indirect buffers. */
@@ -532,8 +531,11 @@ again:
 		}
 		return NETDEV_TX_BUSY;
 	}
-
 	vi->svq->vq_ops->kick(vi->svq);
+
+	/* Put new one in send queue */
+	__skb_queue_head(&vi->send, skb);
+
 	/* Don't wait up for transmitted skbs to be freed. */
 	skb_orphan(skb);
 	nf_reset(skb);
-- 
1.6.5.rc2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-10-27  1:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-25 17:03 [PATCH] virtio-net: fix data corruption with OOM Michael S. Tsirkin
2009-10-26  1:41 ` Rusty Russell
2009-10-26  8:54   ` Michael S. Tsirkin
2009-10-26  9:00   ` Michael S. Tsirkin
2009-10-26  9:07   ` Michael S. Tsirkin
2009-10-27  1:27     ` David Miller
2009-10-26 18:42   ` Michael S. Tsirkin
2009-10-26 19:34     ` Michael S. Tsirkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox