LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] drm/vmwgfx: NULL pointer dereference from vmw_cmd_dx_view_define()
@ 2019-05-11  6:01 Murray McAllister
  2019-05-13 12:53 ` Thomas Hellstrom
  0 siblings, 1 reply; 2+ messages in thread
From: Murray McAllister @ 2019-05-11  6:01 UTC (permalink / raw)
  Cc: murray.mcallister, VMware Graphics, Thomas Hellstrom,
	David Airlie, Daniel Vetter, dri-devel, linux-kernel

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 <murray.mcallister@gmail.com>
---
 drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
index 2ff7ba04d8c8..447afd086206 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
@@ -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);
-- 
2.20.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/vmwgfx: NULL pointer dereference from vmw_cmd_dx_view_define()
  2019-05-11  6:01 [PATCH] drm/vmwgfx: NULL pointer dereference from vmw_cmd_dx_view_define() Murray McAllister
@ 2019-05-13 12:53 ` Thomas Hellstrom
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Hellstrom @ 2019-05-13 12:53 UTC (permalink / raw)
  To: murray.mcallister
  Cc: daniel, Linux-graphics-maintainer, linux-kernel, dri-devel, airlied

On Sat, 2019-05-11 at 18:01 +1200, Murray McAllister wrote:
> 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 <murray.mcallister@gmail.com>

Thanks, I'll add this to the next -fixes pull.
Thomas


> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> index 2ff7ba04d8c8..447afd086206 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
> @@ -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);

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-13 12:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-11  6:01 [PATCH] drm/vmwgfx: NULL pointer dereference from vmw_cmd_dx_view_define() Murray McAllister
2019-05-13 12:53 ` Thomas Hellstrom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).