drm/vmwgfx: NULL pointer dereference from vmw_cmd_dx_view_define()
Subsystems (3)
PATCH 1/1 drm/vmwgfx: NULL pointer dereference from vmw_cmd_dx_view_define()
If SVGA_3D_CMD_DX_DEFINE_RENDERTARGET_VIEW is called with a surface ID of SVGA3D_INVALID_ID, the srf struct will remain NULL after vmw_cmd_res_check(), leading to a null pointer dereference in vmw_view_add().
Signed-off-by Murray McAllister <[email protected]>
--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +4 -0
@@ -2414,6 +2414,10 @@ static int vmw_cmd_dx_view_define(struct vmw_private *dev_priv,return -EINVAL ; cmd =container_of (header,typeof (*cmd), header); +if (unlikely (cmd->sid ==SVGA3D_INVALID_ID )) { +DRM_ERROR ("Invalid surface id.\n" ); +return -EINVAL ; + } ret =vmw_cmd_res_check (dev_priv, sw_context, vmw_res_surface,VMW_RES_DIRTY_NONE , user_surface_converter, &cmd->sid, &srf);
Signature · 1 line
2.20.1
Quoted 6 lines · Murray McAllister
If
SVGA_3D_CMD_DX_DEFINE_RENDERTARGET_VIEWis called with a surface ID ofSVGA3D_INVALID_ID, the srf struct will remain NULL aftervmw_cmd_res_check(), leading to a null pointer dereference invmw_view_add().Signed-off-by Murray McAllister <[email protected]>
Thanks, I'll add this to the next -fixes pull.
Thomas
Quoted 22 lines
--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +4
-0@@ -2414,6 +2414,10 @@ static int vmw_cmd_dx_view_define(struct vmw_private *dev_priv, return -EINVAL ; cmd =container_of (header,typeof (*cmd), header); +if (unlikely (cmd->sid ==SVGA3D_INVALID_ID )) { +DRM_ERROR ("Invalid surface id.\n" ); +return -EINVAL ; + } ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, VMW_RES_DIRTY_NONE,
user_surface_converter,
&cmd->sid, &srf);