diff options
author | Jakob Bornecrantz <jakob@vmware.com> | 2011-10-04 14:13:27 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2011-10-05 05:17:18 -0400 |
commit | 0cff60c625131c64847debc2b4cee33ba33e8d8f (patch) | |
tree | 5eb3cc5532639aff057231ff75719b4882caa01d | |
parent | 2fcd5a73bfd5341876f9ea6b5adcc1dd814226d4 (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>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c index c98c3475a9f8..dea0474f6f3b 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | |||
@@ -197,6 +197,12 @@ static int vmw_cmd_blt_surf_screen_check(struct vmw_private *dev_priv, | |||
197 | } *cmd; | 197 | } *cmd; |
198 | 198 | ||
199 | cmd = container_of(header, struct vmw_sid_cmd, header); | 199 | cmd = container_of(header, struct vmw_sid_cmd, header); |
200 | |||
201 | if (unlikely(!sw_context->kernel)) { | ||
202 | DRM_ERROR("Kernel only SVGA3d command: %u.\n", cmd->header.id); | ||
203 | return -EPERM; | ||
204 | } | ||
205 | |||
200 | return vmw_cmd_sid_check(dev_priv, sw_context, &cmd->body.srcImage.sid); | 206 | return vmw_cmd_sid_check(dev_priv, sw_context, &cmd->body.srcImage.sid); |
201 | } | 207 | } |
202 | 208 | ||
@@ -210,6 +216,12 @@ static int vmw_cmd_present_check(struct vmw_private *dev_priv, | |||
210 | } *cmd; | 216 | } *cmd; |
211 | 217 | ||
212 | cmd = container_of(header, struct vmw_sid_cmd, header); | 218 | cmd = container_of(header, struct vmw_sid_cmd, header); |
219 | |||
220 | if (unlikely(!sw_context->kernel)) { | ||
221 | DRM_ERROR("Kernel only SVGA3d command: %u.\n", cmd->header.id); | ||
222 | return -EPERM; | ||
223 | } | ||
224 | |||
213 | return vmw_cmd_sid_check(dev_priv, sw_context, &cmd->body.sid); | 225 | return vmw_cmd_sid_check(dev_priv, sw_context, &cmd->body.sid); |
214 | } | 226 | } |
215 | 227 | ||
@@ -478,14 +490,12 @@ static int vmw_cmd_check_not_3d(struct vmw_private *dev_priv, | |||
478 | void *buf, uint32_t *size) | 490 | void *buf, uint32_t *size) |
479 | { | 491 | { |
480 | uint32_t size_remaining = *size; | 492 | uint32_t size_remaining = *size; |
481 | bool need_kernel = true; | ||
482 | uint32_t cmd_id; | 493 | uint32_t cmd_id; |
483 | 494 | ||
484 | cmd_id = le32_to_cpu(((uint32_t *)buf)[0]); | 495 | cmd_id = le32_to_cpu(((uint32_t *)buf)[0]); |
485 | switch (cmd_id) { | 496 | switch (cmd_id) { |
486 | case SVGA_CMD_UPDATE: | 497 | case SVGA_CMD_UPDATE: |
487 | *size = sizeof(uint32_t) + sizeof(SVGAFifoCmdUpdate); | 498 | *size = sizeof(uint32_t) + sizeof(SVGAFifoCmdUpdate); |
488 | need_kernel = false; | ||
489 | break; | 499 | break; |
490 | case SVGA_CMD_DEFINE_GMRFB: | 500 | case SVGA_CMD_DEFINE_GMRFB: |
491 | *size = sizeof(uint32_t) + sizeof(SVGAFifoCmdDefineGMRFB); | 501 | *size = sizeof(uint32_t) + sizeof(SVGAFifoCmdDefineGMRFB); |
@@ -507,7 +517,7 @@ static int vmw_cmd_check_not_3d(struct vmw_private *dev_priv, | |||
507 | return -EINVAL; | 517 | return -EINVAL; |
508 | } | 518 | } |
509 | 519 | ||
510 | if (unlikely(need_kernel && !sw_context->kernel)) { | 520 | if (unlikely(!sw_context->kernel)) { |
511 | DRM_ERROR("Kernel only SVGA command: %u.\n", cmd_id); | 521 | DRM_ERROR("Kernel only SVGA command: %u.\n", cmd_id); |
512 | return -EPERM; | 522 | return -EPERM; |
513 | } | 523 | } |