qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH RFC for-2.2] virtio-blk: force 1st s/g to match header
@ 2014-11-27 16:33 Michael S. Tsirkin
  2014-11-27 19:21 ` Stefan Hajnoczi
  0 siblings, 1 reply; 11+ messages in thread
From: Michael S. Tsirkin @ 2014-11-27 16:33 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Stefan Hajnoczi

We leak cpu mappings when 1st s/g is not exactly the
header. As we don't set ANY_LAYOUT, we can at this point
simply assert the correct length.

This will have to be fixed once ANY_LAYOUT is set.

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

Untested: posting for early feedback.

 hw/block/virtio-blk.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index b19b102..1404b3f 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -381,6 +381,12 @@ void virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb)
         exit(1);
     }
 
+    /* We don't advertize ANY_LAYOUT, so first s/g is exactly the header. */
+    if (iov[0].iov_len != sizeof(req->out)) {
+        error_report("virtio-blk request outhdr too long");
+        exit(1);
+    }
+
     iov_discard_front(&iov, &out_num, sizeof(req->out));
 
     if (in_num < 1 ||
-- 
MST

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

end of thread, other threads:[~2014-12-01 12:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-27 16:33 [Qemu-devel] [PATCH RFC for-2.2] virtio-blk: force 1st s/g to match header Michael S. Tsirkin
2014-11-27 19:21 ` Stefan Hajnoczi
2014-11-27 21:13   ` Michael S. Tsirkin
2014-11-28  1:16     ` Fam Zheng
2014-11-28  7:05       ` Jason Wang
2014-11-28 11:43         ` Stefan Hajnoczi
2014-11-28 14:05           ` Marc Marí
2014-11-28 16:14           ` Peter Maydell
2014-11-30 16:43             ` Michael S. Tsirkin
2014-12-01 12:07               ` Peter Maydell
2014-12-01 12:18                 ` 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;
as well as URLs for NNTP newsgroup(s).