Skip to contentSkip to conversation

fix bug in virtio-rng

PATCH Applied Christian Borntraeger 2 participants 2 messages Jan 14, 2008 – Jan 15, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix bug in virtio-rng

Rusty,

I have seen an oops triggered by the following bug statement in virtio-rng:

if (vq->vq_ops->add_buf(vq, &sg, 0, 1, &random_data) != 0)

	BUG();

The problem is that we never called get_buf for complete buffers.

The fix is simple: We have to free the buffer on interrupt to avoid a virtqueue "overflow".

Christian

---
 drivers/char/hw_random/virtio-rng.c |    3 +++
 1 file changed, 3 insertions(+)
drivers/char/hw_random/virtio-rng.c +3 -0
Index: kvm/drivers/char/hw_random/virtio-rng.c
===================================================================
@@ -29,6 +29,9 @@ static bool have_data;
 
 static void random_recv_done(struct virtqueue *vq)
 {
+	int len = 0;
+	vq->vq_ops->get_buf(vq, &len);
+	BUG_ON(!len);
 	have_data = true;
 
 	/* No need to call disable_cb: there can't be any more since we
Signature · 5 lines
IBM Deutschland Entwicklung GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Herbert Kircher 
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
#1 lore raw
Quoted 5 lines · On Tuesday 15 January 2008 04:31:35 Christian Borntraeger wrote:

Rusty,

I have seen an oops triggered by the following bug statement in virtio-rng:

Quoted 7 lines

if (vq->vq_ops->add_buf(vq, &sg, 0, 1, &random_data) != 0)

	BUG();

The problem is that we never called get_buf for complete buffers.

The fix is simple: We have to free the buffer on interrupt to avoid a virtqueue "overflow".

Thanks, applied.

Rusty.