aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2013-12-18 08:13:29 -0500
committerThomas Hellstrom <thellstrom@vmware.com>2014-01-08 04:11:57 -0500
commit05efb1abecce6e36457ae1a7be29ded7ac52292a (patch)
tree59be0d416b8811b273bc1b64f34fa4f0f4cb7b04 /drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
parent859ae233cd0ee76b6143f948ba1cb6b0b4c342f8 (diff)
drm/ttm: ttm object security fixes for render nodes
When a client looks up a ttm object, don't look it up through the device hash table, but rather from the file hash table. That makes sure that the client has indeed put a reference on the object, or in gem terms, has opened the object; either using prime or using the global "name". To avoid a performance loss, make sure the file hash table entries can be looked up from under an RCU lock, and as a consequence, replace the rwlock with a spinlock, since we never need to take it in read mode only anymore. Finally add a ttm object lookup function for the device hash table, that is intended to be used when we put a ref object on a base object or, in gem terms, when we open the object. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_surface.c')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_surface.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
index 7de2ea8bd553..0fc93398bba2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -843,6 +843,7 @@ out_unlock:
843int vmw_surface_reference_ioctl(struct drm_device *dev, void *data, 843int vmw_surface_reference_ioctl(struct drm_device *dev, void *data,
844 struct drm_file *file_priv) 844 struct drm_file *file_priv)
845{ 845{
846 struct vmw_private *dev_priv = vmw_priv(dev);
846 union drm_vmw_surface_reference_arg *arg = 847 union drm_vmw_surface_reference_arg *arg =
847 (union drm_vmw_surface_reference_arg *)data; 848 (union drm_vmw_surface_reference_arg *)data;
848 struct drm_vmw_surface_arg *req = &arg->req; 849 struct drm_vmw_surface_arg *req = &arg->req;
@@ -854,7 +855,7 @@ int vmw_surface_reference_ioctl(struct drm_device *dev, void *data,
854 struct ttm_base_object *base; 855 struct ttm_base_object *base;
855 int ret = -EINVAL; 856 int ret = -EINVAL;
856 857
857 base = ttm_base_object_lookup(tfile, req->sid); 858 base = ttm_base_object_lookup_for_ref(dev_priv->tdev, req->sid);
858 if (unlikely(base == NULL)) { 859 if (unlikely(base == NULL)) {
859 DRM_ERROR("Could not find surface to reference.\n"); 860 DRM_ERROR("Could not find surface to reference.\n");
860 return -EINVAL; 861 return -EINVAL;