drm/vmwgfx: Check check that number of mip levels is above zero in vmw_surface_define_ioctl()
Subsystems (3)
PATCH 1/1 drm/vmwgfx: Check check that number of mip levels is above zero in vmw_surface_define_ioctl()
In vmw_surface_define_ioctl(), a num_sizes parameter is assigned a user-controlled value which is not checked for zero. It is used in a call to kmalloc() which returns ZERO_SIZE_PTR. Later ZERO_SIZE_PTR is dereferenced which leads to a GPF and possibly to a kernel panic. Add the check for zero to avoid this.
Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1435719
--- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +2 -2
@@ -716,8 +716,8 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,for (i =0 ; i <DRM_VMW_MAX_SURFACE_FACES ; ++i) num_sizes += req->mip_levels[i]; -if (num_sizes >DRM_VMW_MAX_SURFACE_FACES * -DRM_VMW_MAX_MIP_LEVELS ) +if (num_sizes <=0 || + num_sizes >DRM_VMW_MAX_SURFACE_FACES *DRM_VMW_MAX_MIP_LEVELS )return -EINVAL ; size = vmw_user_surface_size + 128 +
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi,
thank you for this patch. Murray McAllister reported this one a couple of months ago, and this is already in our queue.
Sinclair
Quoted 30 lines · Vladis Dronov
In
vmw_surface_define_ioctl(), anum_sizesparameter is assigned a user-controlled value which is not checked for zero. It is used in a call tokmalloc()which returnsZERO_SIZE_PTR. LaterZERO_SIZE_PTRis dereferenced which leads to a GPF and possibly to a kernel panic. Add the check for zero to avoid this.Signed-off-by Vladis Dronov <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +2
-2@@ -716,8 +716,8 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,for (i =0 ; i <DRM_VMW_MAX_SURFACE_FACES ; ++i) num_sizes += req->mip_levels[i]; -if (num_sizes >DRM_VMW_MAX_SURFACE_FACES * -DRM_VMW_MAX_MIP_LEVELS ) +if (num_sizes <=0 || + num_sizes >DRM_VMW_MAX_SURFACE_FACES *DRM_VMW_MAX_MIP_LEVELS )return -EINVAL ; size = vmw_user_surface_size + 128 +Signature · 1 line
2.9.3