Skip to contentSkip to conversation

virtio-blk: refuse SG_IO requests with scsi=off

PATCH Applied Paolo Bonzini 3 participants 5 messages Dec 23, 2011 – Jan 13, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-blk: refuse SG_IO requests with scsi=off

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.

---
 hw/virtio-blk.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
hw/virtio-blk.c +6 -0
index b70d116..6cd3164 100644
@@ -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.
Signature · 1 line
1.7.7.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Paolo Bonzini

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.

Quoted 7 lines

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

---
 hw/virtio-blk.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

I checked that guest_features cannot have SCSI enabled when the host wishes to prohibit SCSI.

#2 lore raw
In reply to Paolo Bonzini
Quoted 21 lines · Paolo Bonzini

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.

---
  hw/virtio-blk.c |    6 ++++++
  1 files changed, 6 insertions(+), 0 deletions(-)
hw/virtio-blk.c +0 -0
index b70d116..6cd3164 100644
@@ -153,6 +153,12 @@ static void virtio_blk_handle_scsi(VirtIOBlockReq *req)
      int status;
      int i;

hw/virtio-blk.c static void virtio_blk_handle_scsi(VirtIOBlockReq *req) · line 164

Quoted 10 lines
hw/virtio-blk.c +6 -0
 
+    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.

Ping.

Paolo

#3 lore raw
Quoted 24 lines · Paolo Bonzini
Quoted 23 lines · Paolo Bonzini

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.

---
hw/virtio-blk.c | 6 ++++++

1 files changed, 6 insertions(+), 0 deletions(-)
hw/virtio-blk.c +0 -0
index b70d116..6cd3164 100644
@@ -153,6 +153,12 @@ static void virtio_blk_handle_scsi(VirtIOBlockReq
 *req)
 int status;
 int i;
 
Quoted 11 lines
Quoted 9 lines
hw/virtio-blk.c +6 -0
+ 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.

Ping.

Ping^2

Paolo

#4 lore raw
In reply to Paolo Bonzini
Quoted 10 lines · Paolo Bonzini

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.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 21 lines
---
  hw/virtio-blk.c |    6 ++++++
  1 files changed, 6 insertions(+), 0 deletions(-)
hw/virtio-blk.c +6 -0
index b70d116..6cd3164 100644
@@ -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.