Skip to contentSkip to conversation

virtio-gpu: add sanity check

PATCH In review Gerd Hoffmann 3 participants 3 messages May 27, 2019 – May 29, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-gpu: add sanity check

Require a minimum 16x16 size for the scanout, to make sure the guest can't set either width or height to zero. This (a) doesn't make sense at all and (b) causes problems in some UI code. When using spice this will triggers an assert().

---
 hw/display/virtio-gpu.c | 2 ++
 1 file changed, 2 insertions(+)
hw/display/virtio-gpu.c +2 -0
index 9e37e0ac96b7..372b31ef0af2 100644
@@ -677,6 +677,8 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g,
 
     if (ss.r.x > res->width ||
         ss.r.y > res->height ||
+        ss.r.width < 16 ||
+        ss.r.height < 16 ||
         ss.r.width > res->width ||
         ss.r.height > res->height ||
         ss.r.x + ss.r.width > res->width ||
Signature · 1 line
2.18.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Gerd Hoffmann

Require a minimum 16x16 size for the scanout, to make sure the guest can't set either width or height to zero. This (a) doesn't make sense at all and (b) causes problems in some UI code. When using spice this will triggers an assert().

Quoted 21 lines
---
 hw/display/virtio-gpu.c | 2 ++
 1 file changed, 2 insertions(+)
hw/display/virtio-gpu.c +2 -1
index 9e37e0ac96b7..372b31ef0af2 100644
@@ -677,6 +677,8 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g,
 
     if (ss.r.x > res->width ||
         ss.r.y > res->height ||
+        ss.r.width < 16 ||
+        ss.r.height < 16 ||
         ss.r.width > res->width ||
         ss.r.height > res->height ||
         ss.r.x + ss.r.width > res->width ||
--

2.18.1

Signature · 1 line
Marc-André Lureau
#2 lore raw
In reply to Gerd Hoffmann
Quoted 7 lines · Gerd Hoffmann

Require a minimum 16x16 size for the scanout, to make sure the guest can't set either width or height to zero. This (a) doesn't make sense at all and (b) causes problems in some UI code. When using spice this will triggers an assert().

OK. Worth adding to spec maybe.

Quoted 19 lines
---
 hw/display/virtio-gpu.c | 2 ++
 1 file changed, 2 insertions(+)
hw/display/virtio-gpu.c +2 -0
index 9e37e0ac96b7..372b31ef0af2 100644
@@ -677,6 +677,8 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g,
 
     if (ss.r.x > res->width ||
         ss.r.y > res->height ||
+        ss.r.width < 16 ||
+        ss.r.height < 16 ||
         ss.r.width > res->width ||
         ss.r.height > res->height ||
         ss.r.x + ss.r.width > res->width ||
Signature · 1 line
2.18.1