drm/vmwgfx: Avoid NULL-ptr dereference in vmw_cmd_dx_define_query()
Subsystems (4)
Thomas Zimmermann
maintainerPATCH 1/1 drm/vmwgfx: Avoid NULL-ptr dereference in vmw_cmd_dx_define_query()
There have been reports [1][2] that vmw_cmd_dx_define_query() can be called with ctx_node->ctx set to NULL, which results in undefined behavior in vmw_context_cotable(). Avoid this be returning an errno code.
--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +1 -1
@@ -1256,7 +1256,7 @@ static int vmw_cmd_dx_define_query(struct vmw_private *dev_priv,struct vmw_resource *cotable_res;int ret; -if (!ctx_node) +if (!ctx_node || !ctx_node->ctx)return -EINVAL ; cmd =container_of (header,typeof (*cmd), header);
Signature · 1 line
2.39.2
Quoted 22 lines · Thomas Zimmermann
There have been reports [1][2] that
vmw_cmd_dx_define_query()can be called withctx_node->ctxset to NULL, which results in undefined behavior invmw_context_cotable(). Avoid this be returning an errno code.Signed-off-by Thomas Zimmermann <[email protected]>---
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +0
-0@@ -1256,7 +1256,7 @@ static int vmw_cmd_dx_define_query(struct vmw_private *dev_priv, struct vmw_resource *cotable_res; int ret;
Quoted 4 lines
- if (!ctx_node)
+ if (!ctx_node || !ctx_node->ctx)
return-EINVAL;
I've seen this report, but never a poc that could reproduce it. This should never happen, the ctx in ctx_node should have been initialized. To be honest I'd prefer to just figure out how it's uninitialised instead of just checking for something that should be impossible but without a reproducible test that's difficult.
z