Skip to content

Commit 8528076

Browse files
icklegregkh
authored andcommitted
drm: Prevent overwriting from userspace underallocating core ioctl structs
commit b062672 upstream. Apply the protections from commit 1b2f148 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 Signed-off-by: Dave Airlie <airlied@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ef4ea09 commit 8528076

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎drivers/gpu/drm/drm_drv.c‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,16 @@ long drm_ioctl(struct file *filp,
407407
cmd = ioctl->cmd_drv;
408408
}
409409
else if ((nr >= DRM_COMMAND_END) || (nr < DRM_COMMAND_BASE)) {
410+
u32 drv_size;
411+
410412
ioctl = &drm_ioctls[nr];
411-
cmd = ioctl->cmd;
413+
414+
drv_size = _IOC_SIZE(ioctl->cmd);
412415
usize = asize = _IOC_SIZE(cmd);
416+
if (drv_size > asize)
417+
asize = drv_size;
418+
419+
cmd = ioctl->cmd;
413420
} else
414421
goto err_i1;
415422

0 commit comments

Comments
 (0)