drm/vmwgfx: NULL pointer dereference in vmw_surface_define_ioctl()
authorMurray McAllister <murray.mcallister@insomniasec.com>
Mon, 27 Mar 2017 09:12:53 +0000 (11:12 +0200)
committerThomas Hellstrom <thellstrom@vmware.com>
Thu, 30 Mar 2017 09:43:23 +0000 (11:43 +0200)
Before memory allocations vmw_surface_define_ioctl() checks the
upper-bounds of a user-supplied size, but does not check if the
supplied size is 0.

Add check to avoid NULL pointer dereferences.

Cc: <stable@vger.kernel.org>
Signed-off-by: Murray McAllister <murray.mcallister@insomniasec.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c

index b445ce9b9757861ecc1ece1071f1c8c3a02a166f..f410502cb07527ba3e165495028a54150a5a1ae9 100644 (file)
@@ -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 > DRM_VMW_MAX_SURFACE_FACES * DRM_VMW_MAX_MIP_LEVELS ||
+           num_sizes == 0)
                return -EINVAL;
 
        size = vmw_user_surface_size + 128 +