* [PATCH] drm/vmwgfx: Check check that number of mip levels is above zero in vmw_surface_define_ioctl()
@ 2017-03-24 15:37 Vladis Dronov
2017-03-25 3:30 ` Sinclair Yeh
0 siblings, 1 reply; 2+ messages in thread
From: Vladis Dronov @ 2017-03-24 15:37 UTC (permalink / raw)
To: VMware Graphics, Sinclair Yeh, Thomas Hellstrom, David Airlie,
dri-devel, linux-kernel
Cc: Vladis Dronov
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
Signed-off-by: Vladis Dronov <vdronov@redhat.com>
---
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
index b445ce9..42840cc 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -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 +
--
2.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/vmwgfx: Check check that number of mip levels is above zero in vmw_surface_define_ioctl()
2017-03-24 15:37 [PATCH] drm/vmwgfx: Check check that number of mip levels is above zero in vmw_surface_define_ioctl() Vladis Dronov
@ 2017-03-25 3:30 ` Sinclair Yeh
0 siblings, 0 replies; 2+ messages in thread
From: Sinclair Yeh @ 2017-03-25 3:30 UTC (permalink / raw)
To: Vladis Dronov
Cc: VMware Graphics, Thomas Hellstrom, David Airlie, dri-devel,
linux-kernel, murray.mcallister
Hi,
thank you for this patch. Murray McAllister reported this one a couple
of months ago, and this is already in our queue.
Sinclair
On Fri, Mar 24, 2017 at 04:37:10PM +0100, Vladis Dronov wrote:
> 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://urldefense.proofpoint.com/v2/url?u=https-3A__bugzilla.redhat.com_show-5Fbug.cgi-3Fid-3D1435719&d=DwIBAg&c=uilaK90D4TOVoH58JNXRgQ&r=HaJ2a6NYExoV0cntAYcoqA&m=OW9cIAAez9eRIxEYMaToDu2szuR_YrfQcOzAH6L8dXo&s=-3P2pG3n1YW6-8NG6mLC7kyxmx7mMxJmXgY79ZgQeo4&e=
> Signed-off-by: Vladis Dronov <vdronov@redhat.com>
> ---
> drivers/gpu/drm/vmwgfx/vmwgfx_surface.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> index b445ce9..42840cc 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> @@ -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 +
> --
> 2.9.3
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-25 3:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-24 15:37 [PATCH] drm/vmwgfx: Check check that number of mip levels is above zero in vmw_surface_define_ioctl() Vladis Dronov
2017-03-25 3:30 ` Sinclair Yeh
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).