summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_crtc.c
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2014-11-03 11:14:14 +0100
committerThierry Reding <treding@nvidia.com>2014-11-13 13:27:29 +0100
commitf60859522a830c4d31337592b673799c3b914d0a (patch)
treea74a276df9256273cdd277660c2d2fa954a9b66e /drivers/gpu/drm/drm_crtc.c
parent7e295a36b3af5d588e585e2300febbb191463939 (diff)
downloadop-kernel-dev-f60859522a830c4d31337592b673799c3b914d0a.zip
op-kernel-dev-f60859522a830c4d31337592b673799c3b914d0a.tar.gz
drm: Sanitize DRM_IOCTL_MODE_CREATE_DUMB input
Some drivers treat the pitch and size fields as inputs and will use them as minima provided by userspace so that they are only overwritten if the minimal requirements of the driver exceed them. This can cause strange behaviour when applications don't zero out these fields, causing whatever was on the stack to be passed to the IOCTL. In a typical case this would become visible as a failed allocation if the pitch or size were unusually high. But this could also cause more subtle bugs like overallocating dumb framebuffers. To prevent drivers from misusing these values, make the DRM core zero out the pitch and size fields before passing the structure to the driver implementation. While at it, also set the output handle field to zero for good measure, even though it's less likely to be abused. Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Thierry Reding <treding@nvidia.com>
Diffstat (limited to 'drivers/gpu/drm/drm_crtc.c')
-rw-r--r--drivers/gpu/drm/drm_crtc.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index e79c8d3..e2ea151 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -4769,6 +4769,16 @@ int drm_mode_create_dumb_ioctl(struct drm_device *dev,
if (PAGE_ALIGN(size) == 0)
return -EINVAL;
+ /*
+ * handle, pitch and size are output parameters. Zero them out to
+ * prevent drivers from accidentally using uninitialized data. Since
+ * not all existing userspace is clearing these fields properly we
+ * cannot reject IOCTL with garbage in them.
+ */
+ args->handle = 0;
+ args->pitch = 0;
+ args->size = 0;
+
return dev->driver->dumb_create(file_priv, dev, args);
}
OpenPOWER on IntegriCloud