* [Qemu-devel] [PATCH 1/2] hw/qxl: extract verify_surface_cmd from qxl_track_command
@ 2012-11-20 9:19 Alon Levy
2012-11-20 9:19 ` [Qemu-devel] [PATCH 2/2] qxl/verify_surface_cmd: check format != 0 (buggy drivers can do that) Alon Levy
2012-11-20 10:31 ` [Qemu-devel] [PATCH 1/2] hw/qxl: extract verify_surface_cmd from qxl_track_command Gerd Hoffmann
0 siblings, 2 replies; 4+ messages in thread
From: Alon Levy @ 2012-11-20 9:19 UTC (permalink / raw)
To: qemu-devel; +Cc: kraxel
Signed-off-by: Alon Levy <alevy@redhat.com>
---
hw/qxl.c | 48 +++++++++++++++++++++++++++++-------------------
1 file changed, 29 insertions(+), 19 deletions(-)
diff --git a/hw/qxl.c b/hw/qxl.c
index 1482389..af5f68e 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -430,6 +430,34 @@ static void qxl_ring_set_dirty(PCIQXLDevice *qxl)
qxl_set_dirty(&qxl->vga.vram, addr, end);
}
+static int verify_surface_cmd(PCIQXLDevice *qxl, QXLSurfaceCmd *cmd)
+{
+ uint32_t id = le32_to_cpu(cmd->surface_id);
+
+ if (id >= qxl->ssd.num_surfaces) {
+ qxl_set_guest_bug(qxl, "QXL_CMD_SURFACE id %d >= %d", id,
+ qxl->ssd.num_surfaces);
+ return 1;
+ }
+ if (cmd->type == QXL_SURFACE_CMD_CREATE &&
+ (cmd->u.surface_create.stride & 0x03) != 0) {
+ qxl_set_guest_bug(qxl, "QXL_CMD_SURFACE stride = %d %% 4 != 0\n",
+ cmd->u.surface_create.stride);
+ return 1;
+ }
+ if (cmd->type == QXL_SURFACE_CMD_CREATE) {
+ intptr_t surface_offset = (intptr_t)qxl_phys2virt(qxl,
+ cmd->u.surface_create.data,
+ MEMSLOT_GROUP_GUEST);
+ if (!surface_offset) {
+ qxl_set_guest_bug(qxl, "QXL_CMD_SURFACE invalid data: %ld\n",
+ cmd->u.surface_create.data);
+ return 1;
+ }
+ }
+ return 0;
+}
+
/*
* keep track of some command state, for savevm/loadvm.
* called from spice server thread context only
@@ -446,27 +474,9 @@ static int qxl_track_command(PCIQXLDevice *qxl, struct QXLCommandExt *ext)
}
uint32_t id = le32_to_cpu(cmd->surface_id);
- if (id >= qxl->ssd.num_surfaces) {
- qxl_set_guest_bug(qxl, "QXL_CMD_SURFACE id %d >= %d", id,
- qxl->ssd.num_surfaces);
+ if (!verify_surface_cmd(qxl, cmd)) {
return 1;
}
- if (cmd->type == QXL_SURFACE_CMD_CREATE &&
- (cmd->u.surface_create.stride & 0x03) != 0) {
- qxl_set_guest_bug(qxl, "QXL_CMD_SURFACE stride = %d %% 4 != 0\n",
- cmd->u.surface_create.stride);
- return 1;
- }
- if (cmd->type == QXL_SURFACE_CMD_CREATE) {
- intptr_t surface_offset = (intptr_t)qxl_phys2virt(qxl,
- cmd->u.surface_create.data,
- MEMSLOT_GROUP_GUEST);
- if (!surface_offset) {
- qxl_set_guest_bug(qxl, "QXL_CMD_SURFACE invalid data: %ld\n",
- cmd->u.surface_create.data);
- return 1;
- }
- }
qemu_mutex_lock(&qxl->track_lock);
if (cmd->type == QXL_SURFACE_CMD_CREATE) {
qxl->guest_surfaces.cmds[id] = ext->cmd.data;
--
1.8.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 2/2] qxl/verify_surface_cmd: check format != 0 (buggy drivers can do that)
2012-11-20 9:19 [Qemu-devel] [PATCH 1/2] hw/qxl: extract verify_surface_cmd from qxl_track_command Alon Levy
@ 2012-11-20 9:19 ` Alon Levy
2012-11-20 10:31 ` [Qemu-devel] [PATCH 1/2] hw/qxl: extract verify_surface_cmd from qxl_track_command Gerd Hoffmann
1 sibling, 0 replies; 4+ messages in thread
From: Alon Levy @ 2012-11-20 9:19 UTC (permalink / raw)
To: qemu-devel; +Cc: kraxel
Signed-off-by: Alon Levy <alevy@redhat.com>
---
hw/qxl.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/qxl.c b/hw/qxl.c
index af5f68e..91e4fec 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -455,6 +455,12 @@ static int verify_surface_cmd(PCIQXLDevice *qxl, QXLSurfaceCmd *cmd)
return 1;
}
}
+ if (cmd->type == QXL_SURFACE_CMD_CREATE &&
+ cmd->u.surface_create.format == 0) {
+ qxl_set_guest_bug(qxl, "QXL_CMD_SURFACE invalid format: %u\n",
+ cmd->u.surface_create.format);
+ return 1;
+ }
return 0;
}
--
1.8.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] hw/qxl: extract verify_surface_cmd from qxl_track_command
2012-11-20 9:19 [Qemu-devel] [PATCH 1/2] hw/qxl: extract verify_surface_cmd from qxl_track_command Alon Levy
2012-11-20 9:19 ` [Qemu-devel] [PATCH 2/2] qxl/verify_surface_cmd: check format != 0 (buggy drivers can do that) Alon Levy
@ 2012-11-20 10:31 ` Gerd Hoffmann
2012-11-20 11:19 ` Alon Levy
1 sibling, 1 reply; 4+ messages in thread
From: Gerd Hoffmann @ 2012-11-20 10:31 UTC (permalink / raw)
To: Alon Levy; +Cc: qemu-devel
On 11/20/12 10:19, Alon Levy wrote:
> Signed-off-by: Alon Levy <alevy@redhat.com>
Doesn't apply to master.
cheers,
Gerd
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] hw/qxl: extract verify_surface_cmd from qxl_track_command
2012-11-20 10:31 ` [Qemu-devel] [PATCH 1/2] hw/qxl: extract verify_surface_cmd from qxl_track_command Gerd Hoffmann
@ 2012-11-20 11:19 ` Alon Levy
0 siblings, 0 replies; 4+ messages in thread
From: Alon Levy @ 2012-11-20 11:19 UTC (permalink / raw)
To: Gerd Hoffmann; +Cc: qemu-devel
> On 11/20/12 10:19, Alon Levy wrote:
> > Signed-off-by: Alon Levy <alevy@redhat.com>
>
> Doesn't apply to master.
Good. It didn't apply because it was missing warn on sync io-usage and validate surface data. The later we agreed should be dropped in favor of spice reporting an error to qxl.
>
> cheers,
> Gerd
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-11-20 11:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-20 9:19 [Qemu-devel] [PATCH 1/2] hw/qxl: extract verify_surface_cmd from qxl_track_command Alon Levy
2012-11-20 9:19 ` [Qemu-devel] [PATCH 2/2] qxl/verify_surface_cmd: check format != 0 (buggy drivers can do that) Alon Levy
2012-11-20 10:31 ` [Qemu-devel] [PATCH 1/2] hw/qxl: extract verify_surface_cmd from qxl_track_command Gerd Hoffmann
2012-11-20 11:19 ` Alon Levy
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).