Skip to contentSkip to conversation

assorted s390x fixes

PATCH In review Cornelia Huck 3 participants 8 messages Mar 26, 2015 – Mar 27, 2015

lore
Share & tools
lore
#0 lore raw

cover assorted s390x fixes

Hi,

here's what I have pending for 2.3. Paolo noticed two small problems, and I realized we have some bugs wrt accessing virtqueue indices when I reviewed Jason's support for more virtqueues patchset.

I'm planning on sending a pull request on monday.

Cornelia Huck (3):
virtio-ccw: fix range check for SET_VQ
virtio-ccw: range check in READ_VQ_CONF
s390x/ipl: avoid sign extension

Paolo Bonzini (1):
s390x: do not include ram_addr.h

 hw/s390x/ipl.c        | 3 +--
 hw/s390x/virtio-ccw.c | 6 +++++-
 2 files changed, 6 insertions(+), 3 deletions(-)
Signature · 1 line
2.3.4
#1 lore raw

PATCH 1/4 virtio-ccw: fix range check for SET_VQ

VIRTIO_PCI_QUEUE_MAX is already too big; a malicious guest would be able to trigger a write beyond the VirtQueue structure.

---
 hw/s390x/virtio-ccw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/s390x/virtio-ccw.c +1 -1
index 130535c..ceb6a45 100644
@@ -266,7 +266,7 @@ static int virtio_ccw_set_vqs(SubchDev *sch, uint64_t addr, uint32_t align,
 {
     VirtIODevice *vdev = virtio_ccw_get_vdev(sch);
 
-    if (index > VIRTIO_PCI_QUEUE_MAX) {
+    if (index >= VIRTIO_PCI_QUEUE_MAX) {
         return -EINVAL;
     }
 
Signature · 1 line
2.3.4
Acked-by on v1 1/4
#2 lore raw

Re: [Qemu-devel] [PATCH for-2.3 1/4] virtio-ccw: fix range check for SET_VQ

Am 26.03.2015 um 16:35 schrieb Cornelia Huck:

Quoted 6 lines

VIRTIO_PCI_QUEUE_MAX is already too big; a malicious guest would be able to trigger a write beyond the VirtQueue structure.

Quoted 17 lines
---
 hw/s390x/virtio-ccw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/s390x/virtio-ccw.c +1 -1
index 130535c..ceb6a45 100644
@@ -266,7 +266,7 @@ static int virtio_ccw_set_vqs(SubchDev *sch, uint64_t addr, uint32_t align,
 {
     VirtIODevice *vdev = virtio_ccw_get_vdev(sch);
 
-    if (index > VIRTIO_PCI_QUEUE_MAX) {
+    if (index >= VIRTIO_PCI_QUEUE_MAX) {
         return -EINVAL;
     }
 
#3 lore raw

PATCH 2/4 virtio-ccw: range check in READ_VQ_CONF

In reply to Cornelia Huck

Processing for READ_VQ_CONF needs to check whether the requested queue value is actually in the supported range and post a channel program check if not.

---
 hw/s390x/virtio-ccw.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/s390x/virtio-ccw.c +4 -0
index ceb6a45..d32ecaf 100644
@@ -549,6 +549,10 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
             ret = -EFAULT;
         } else {
             vq_config.index = lduw_be_phys(&address_space_memory, ccw.cda);
+            if (vq_config.index >= VIRTIO_PCI_QUEUE_MAX) {
+                ret = -EINVAL;
+                break;
+            }
             vq_config.num_max = virtio_queue_get_num(vdev,
                                                      vq_config.index);
             stw_be_phys(&address_space_memory,
Signature · 1 line
2.3.4
Acked-by on v1 2/4
#4 lore raw

Re: [Qemu-devel] [PATCH for-2.3 2/4] virtio-ccw: range check in READ_VQ_CONF

Am 26.03.2015 um 16:36 schrieb Cornelia Huck:

Quoted 7 lines

Processing for READ_VQ_CONF needs to check whether the requested queue value is actually in the supported range and post a channel program check if not.

Quoted 20 lines
---
 hw/s390x/virtio-ccw.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/s390x/virtio-ccw.c +4 -0
index ceb6a45..d32ecaf 100644
@@ -549,6 +549,10 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
             ret = -EFAULT;
         } else {
             vq_config.index = lduw_be_phys(&address_space_memory, ccw.cda);
+            if (vq_config.index >= VIRTIO_PCI_QUEUE_MAX) {
+                ret = -EINVAL;
+                break;
+            }
             vq_config.num_max = virtio_queue_get_num(vdev,
                                                      vq_config.index);
             stw_be_phys(&address_space_memory,
#5 lore raw

PATCH 3/4 s390x: do not include ram_addr.h

In reply to Cornelia Huck

From: Paolo Bonzini <[email protected]>

ram_addr.h is an internal interface and it is not needed anyway by hw/s390x/ipl.c.

Cc Christian Borntraeger <[email protected]>

Message-Id: <[email protected]>

---
 hw/s390x/ipl.c | 1 -
 1 file changed, 1 deletion(-)
hw/s390x/ipl.c +0 -1
index 54d0835..5c86613 100644
@@ -14,7 +14,6 @@
 #include "sysemu/sysemu.h"
 #include "cpu.h"
 #include "elf.h"
-#include "exec/ram_addr.h"
 #include "hw/loader.h"
 #include "hw/sysbus.h"
 #include "hw/s390x/virtio-ccw.h"
Signature · 1 line
2.3.4
Reviewed-by on v1 3/4
#6 lore raw

Re: [Qemu-devel] [PATCH for-2.3 3/4] s390x: do not include ram_addr.h

Am Thu, 26 Mar 2015 16:36:01 +0100
schrieb Cornelia Huck <[email protected]>:

Quoted 19 lines

From: Paolo Bonzini <[email protected]>

ram_addr.h is an internal interface and it is not needed anyway by hw/s390x/ipl.c.

Cc Christian Borntraeger <[email protected]>

Message-Id: <[email protected]>

---
 hw/s390x/ipl.c | 1 -
 1 file changed, 1 deletion(-)
hw/s390x/ipl.c +0 -0
index 54d0835..5c86613 100644

hw/s390x/ipl.c line 19

Quoted 7 lines
hw/s390x/ipl.c +0 -1
@@ -14,7 +14,6 @@
 #include "sysemu/sysemu.h"
 #include "cpu.h"
 #include "elf.h"
-#include "exec/ram_addr.h"
 #include "hw/loader.h"
 #include "hw/sysbus.h"
 #include "hw/s390x/virtio-ccw.h"

Uh, IIRC I temporarily played around with qemu_get_ram_ptr() when I recently improved the BIOS loading in this file - and later forgot to remove that include file again - sorry! So of course, it should not be here. Thanks for cleaning it up!

#7 lore raw

PATCH 4/4 s390x/ipl: avoid sign extension

In reply to Cornelia Huck

Make s390_update_iplstate() return uint32_t to avoid sign extensions for cssids > 127. While this doesn't matter in practice yet (as nobody supports MCSS-E and thus won't see the real cssid), play safe.

---
 hw/s390x/ipl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/s390x/ipl.c +1 -1
index 5c86613..2e26d2a 100644
@@ -218,7 +218,7 @@ static Property s390_ipl_properties[] = {
  * - -1 if no valid boot device was found
  * - ccw id of the boot device otherwise
  */
-static uint64_t s390_update_iplstate(CPUS390XState *env, S390IPLState *ipl)
+static uint32_t s390_update_iplstate(CPUS390XState *env, S390IPLState *ipl)
 {
     DeviceState *dev_st;
 
Signature · 1 line
2.3.4