drm/vmwgfx: integer underflow in vmw_cmd_dx_set_shader() leading to an invalid read
Subsystems (3)
PATCH 1/1 drm/vmwgfx: integer underflow in vmw_cmd_dx_set_shader() leading to an invalid read
If SVGA_3D_CMD_DX_SET_SHADER is called with a shader ID
of SVGA3D_INVALID_ID, and a shader type of SVGA3D_SHADERTYPE_INVALID, the calculated binding.shader_slot will be 4294967295, leading to an out-of-bounds read in vmw_binding_loc() when the offset is calculated.
Signed-off-by Murray McAllister <[email protected]>
--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +2 -1
@@ -2193,7 +2193,8 @@ static int vmw_cmd_dx_set_shader(struct vmw_private *dev_priv, cmd =container_of (header,typeof (*cmd), header); -if (cmd->body.type >=SVGA3D_SHADERTYPE_DX10_MAX ) { +if (cmd->body.type >=SVGA3D_SHADERTYPE_DX10_MAX || + cmd->body.type <SVGA3D_SHADERTYPE_MIN ) {VMW_DEBUG_USER ("Illegal shader type %u.\n" , (unsigned int ) cmd->body.type);return -EINVAL ;
Signature · 1 line
2.20.1
Thanks, Murray,
I'll include in the next vmwgfx-fixes pull request.
Quoted 28 lines · Murray McAllister
If
SVGA_3D_CMD_DX_SET_SHADERis called with a shader ID ofSVGA3D_INVALID_ID, and a shader type ofSVGA3D_SHADERTYPE_INVALID, the calculated binding.shader_slot will be 4294967295, leading to an out-of-bounds read invmw_binding_loc()
when the offset is calculated.Signed-off-by Murray McAllister <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +2
-1@@ -2193,7 +2193,8 @@ static int vmw_cmd_dx_set_shader(structvmw_private *dev_priv, cmd =container_of (header,typeof (*cmd), header); -if (cmd->body.type >=SVGA3D_SHADERTYPE_DX10_MAX ) { +if (cmd->body.type >=SVGA3D_SHADERTYPE_DX10_MAX || + cmd->body.type <SVGA3D_SHADERTYPE_MIN ) {VMW_DEBUG_USER ("Illegal shader type %u.\n" , (unsigned int ) cmd->body.type);return
-EINVAL;