diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2013-10-16 06:22:44 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2013-10-18 02:40:37 -0400 |
commit | b062672e305ce071f21eb9e18b102c2a430e0999 (patch) | |
tree | 6a07fbd3e3a7e63d8770772d8ba9f64eff66f206 /drivers/gpu/drm | |
parent | c4249855ac5b2a383704d31e040d3831d6a25c6f (diff) |
drm: Prevent overwriting from userspace underallocating core ioctl structs
Apply the protections from
commit 1b2f1489633888d4a06028315dc19d65768a1c05
Author: Dave Airlie <airlied@redhat.com>
Date: Sat Aug 14 20:20:34 2010 +1000
drm: block userspace under allocating buffer and having drivers overwrite it (v2)
to the core ioctl structs as well, for we found one instance where there
is a 32-/64-bit size mismatch and were guilty of writing beyond the end
of the user's buffer.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Dave Airlie <airlied@redhat.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: dri-devel@lists.freedesktop.org
Cc: stable@vger.kernel.org
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r-- | drivers/gpu/drm/drm_drv.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index e572dd20bdee..05ad9ba0a67e 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c | |||
@@ -402,9 +402,16 @@ long drm_ioctl(struct file *filp, | |||
402 | cmd = ioctl->cmd_drv; | 402 | cmd = ioctl->cmd_drv; |
403 | } | 403 | } |
404 | else if ((nr >= DRM_COMMAND_END) || (nr < DRM_COMMAND_BASE)) { | 404 | else if ((nr >= DRM_COMMAND_END) || (nr < DRM_COMMAND_BASE)) { |
405 | u32 drv_size; | ||
406 | |||
405 | ioctl = &drm_ioctls[nr]; | 407 | ioctl = &drm_ioctls[nr]; |
406 | cmd = ioctl->cmd; | 408 | |
409 | drv_size = _IOC_SIZE(ioctl->cmd); | ||
407 | usize = asize = _IOC_SIZE(cmd); | 410 | usize = asize = _IOC_SIZE(cmd); |
411 | if (drv_size > asize) | ||
412 | asize = drv_size; | ||
413 | |||
414 | cmd = ioctl->cmd; | ||
408 | } else | 415 | } else |
409 | goto err_i1; | 416 | goto err_i1; |
410 | 417 | ||