]> git.proxmox.com Git - qemu.git/commitdiff
virtio-blk: refuse SG_IO requests with scsi=off
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 23 Dec 2011 14:39:03 +0000 (15:39 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 13 Jan 2012 16:20:51 +0000 (10:20 -0600)
QEMU does have a "scsi" option (to be used like -device
virtio-blk-pci,drive=foo,scsi=off).  However, it only
masks the feature bit, and does not reject the command
if a malicious guest disregards the feature bits and
issues a request.

Without this patch, using scsi=off does not protect you
from CVE-2011-4127.

Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/virtio-blk.c

index 5e81f53e14e77827470b6d32bff192d06d747e89..5b416c36eea1d3bbba0bb20fb6bc9bb318daf1a5 100644 (file)
@@ -153,6 +153,12 @@ static void virtio_blk_handle_scsi(VirtIOBlockReq *req)
     int status;
     int i;
 
+    if ((req->dev->vdev.guest_features & (1 << VIRTIO_BLK_F_SCSI)) == 0) {
+        virtio_blk_req_complete(req, VIRTIO_BLK_S_UNSUPP);
+        g_free(req);
+        return;
+    }
+
     /*
      * We require at least one output segment each for the virtio_blk_outhdr
      * and the SCSI command block.