summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Bornecrantz <jakob@vmware.com>2011-09-17 00:03:49 +0200
committerThomas Hellstrom <thellstrom@vmware.com>2011-09-27 14:47:42 +0200
commitffb6e7847dbf50ea18962eb2786524042ab56b58 (patch)
treef7f4ae4034a30a4b7ee0059f887431e58bc17db3
parenta8babf1a00f79d437f8116b7d179ad7d97abd7f0 (diff)
vmwgfx: Disallow user space to send present and readback commands
Signed-off-by: Jakob Bornecrantz <jakob@vmware.com> Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
-rw-r--r--vmwgfx_execbuf.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/vmwgfx_execbuf.c b/vmwgfx_execbuf.c
index 49800cf..d212a50 100644
--- a/vmwgfx_execbuf.c
+++ b/vmwgfx_execbuf.c
@@ -197,6 +197,12 @@ static int vmw_cmd_blt_surf_screen_check(struct vmw_private *dev_priv,
} *cmd;
cmd = container_of(header, struct vmw_sid_cmd, header);
+
+ if (unlikely(!sw_context->kernel)) {
+ DRM_ERROR("Kernel only SVGA3d command: %u.\n", cmd->header.id);
+ return -EPERM;
+ }
+
return vmw_cmd_sid_check(dev_priv, sw_context, &cmd->body.srcImage.sid);
}
@@ -210,6 +216,12 @@ static int vmw_cmd_present_check(struct vmw_private *dev_priv,
} *cmd;
cmd = container_of(header, struct vmw_sid_cmd, header);
+
+ if (unlikely(!sw_context->kernel)) {
+ DRM_ERROR("Kernel only SVGA3d command: %u.\n", cmd->header.id);
+ return -EPERM;
+ }
+
return vmw_cmd_sid_check(dev_priv, sw_context, &cmd->body.sid);
}
@@ -477,14 +489,12 @@ static int vmw_cmd_check_not_3d(struct vmw_private *dev_priv,
void *buf, uint32_t *size)
{
uint32_t size_remaining = *size;
- bool need_kernel = true;
uint32_t cmd_id;
cmd_id = le32_to_cpu(((uint32_t *)buf)[0]);
switch (cmd_id) {
case SVGA_CMD_UPDATE:
*size = sizeof(uint32_t) + sizeof(SVGAFifoCmdUpdate);
- need_kernel = false;
break;
case SVGA_CMD_DEFINE_GMRFB:
*size = sizeof(uint32_t) + sizeof(SVGAFifoCmdDefineGMRFB);
@@ -506,7 +516,7 @@ static int vmw_cmd_check_not_3d(struct vmw_private *dev_priv,
return -EINVAL;
}
- if (unlikely(need_kernel && !sw_context->kernel)) {
+ if (unlikely(!sw_context->kernel)) {
DRM_ERROR("Kernel only SVGA command: %u.\n", cmd_id);
return -EPERM;
}