]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/vmwgfx: fix potential UAF in vmwgfx_surface.c
authorDesmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
Sat, 24 Jul 2021 11:18:24 +0000 (19:18 +0800)
committerZack Rusin <zackr@vmware.com>
Mon, 9 Aug 2021 21:30:34 +0000 (17:30 -0400)
drm_file.master should be protected by either drm_device.master_mutex
or drm_file.master_lookup_lock when being dereferenced. However,
drm_master_get is called on unprotected file_priv->master pointers in
vmw_surface_define_ioctl and vmw_gb_surface_define_internal.

This is fixed by replacing drm_master_get with drm_file_get_master.

Signed-off-by: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Zack Rusin <zackr@vmware.com>
Signed-off-by: Zack Rusin <zackr@vmware.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210724111824.59266-4-desmondcheongzx@gmail.com
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c

index 0eba47762bedf2e3137fc4afdfda7e52a23b053e..5d53a5f9d1237049567299ca8f34ca717d12d412 100644 (file)
@@ -865,7 +865,7 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
        user_srf->prime.base.shareable = false;
        user_srf->prime.base.tfile = NULL;
        if (drm_is_primary_client(file_priv))
-               user_srf->master = drm_master_get(file_priv->master);
+               user_srf->master = drm_file_get_master(file_priv);
 
        /**
         * From this point, the generic resource management functions
@@ -1534,7 +1534,7 @@ vmw_gb_surface_define_internal(struct drm_device *dev,
 
        user_srf = container_of(srf, struct vmw_user_surface, srf);
        if (drm_is_primary_client(file_priv))
-               user_srf->master = drm_master_get(file_priv->master);
+               user_srf->master = drm_file_get_master(file_priv);
 
        res = &user_srf->srf.res;