diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2012-11-21 10:04:18 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-11-28 05:09:08 -0500 |
commit | d08a9b9cd82f668a5437c23e59063387ca3ecec5 (patch) | |
tree | ba4f33c31d5cf530c244b2ec0fa8bf5865677563 | |
parent | 219e81536c8776b30ccf3262c1ceaeaddf7a231a (diff) |
drm/vmwgfx: Tighten the security around buffer maps
Make sure that other DRM clients can't map the contents of
non-shareable buffer objects.
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 9 | ||||
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 20 |
3 files changed, 26 insertions, 5 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c index ef1109c8fec8..96dc84dc34d0 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | |||
@@ -248,13 +248,12 @@ void vmw_evict_flags(struct ttm_buffer_object *bo, | |||
248 | *placement = vmw_sys_placement; | 248 | *placement = vmw_sys_placement; |
249 | } | 249 | } |
250 | 250 | ||
251 | /** | ||
252 | * FIXME: Proper access checks on buffers. | ||
253 | */ | ||
254 | |||
255 | static int vmw_verify_access(struct ttm_buffer_object *bo, struct file *filp) | 251 | static int vmw_verify_access(struct ttm_buffer_object *bo, struct file *filp) |
256 | { | 252 | { |
257 | return 0; | 253 | struct ttm_object_file *tfile = |
254 | vmw_fpriv((struct drm_file *)filp->private_data)->tfile; | ||
255 | |||
256 | return vmw_user_dmabuf_verify_access(bo, tfile); | ||
258 | } | 257 | } |
259 | 258 | ||
260 | static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) | 259 | static int vmw_ttm_io_mem_reserve(struct ttm_bo_device *bdev, struct ttm_mem_reg *mem) |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index 34dce9e2b6d2..13aeda71280e 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | |||
@@ -461,6 +461,8 @@ extern int vmw_dmabuf_init(struct vmw_private *dev_priv, | |||
461 | size_t size, struct ttm_placement *placement, | 461 | size_t size, struct ttm_placement *placement, |
462 | bool interuptable, | 462 | bool interuptable, |
463 | void (*bo_free) (struct ttm_buffer_object *bo)); | 463 | void (*bo_free) (struct ttm_buffer_object *bo)); |
464 | extern int vmw_user_dmabuf_verify_access(struct ttm_buffer_object *bo, | ||
465 | struct ttm_object_file *tfile); | ||
464 | extern int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data, | 466 | extern int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data, |
465 | struct drm_file *file_priv); | 467 | struct drm_file *file_priv); |
466 | extern int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data, | 468 | extern int vmw_dmabuf_unref_ioctl(struct drm_device *dev, void *data, |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c index 88b6f921ee94..0def4ff5b621 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | |||
@@ -458,6 +458,26 @@ out_no_base_object: | |||
458 | return ret; | 458 | return ret; |
459 | } | 459 | } |
460 | 460 | ||
461 | /** | ||
462 | * vmw_user_dmabuf_verify_access - verify access permissions on this | ||
463 | * buffer object. | ||
464 | * | ||
465 | * @bo: Pointer to the buffer object being accessed | ||
466 | * @tfile: Identifying the caller. | ||
467 | */ | ||
468 | int vmw_user_dmabuf_verify_access(struct ttm_buffer_object *bo, | ||
469 | struct ttm_object_file *tfile) | ||
470 | { | ||
471 | struct vmw_user_dma_buffer *vmw_user_bo; | ||
472 | |||
473 | if (unlikely(bo->destroy != vmw_user_dmabuf_destroy)) | ||
474 | return -EPERM; | ||
475 | |||
476 | vmw_user_bo = vmw_user_dma_buffer(bo); | ||
477 | return (vmw_user_bo->base.tfile == tfile || | ||
478 | vmw_user_bo->base.shareable) ? 0 : -EPERM; | ||
479 | } | ||
480 | |||
461 | int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data, | 481 | int vmw_dmabuf_alloc_ioctl(struct drm_device *dev, void *data, |
462 | struct drm_file *file_priv) | 482 | struct drm_file *file_priv) |
463 | { | 483 | { |