drm/rcar: gem: dumb: pitch is an output
authorThierry Reding <treding@nvidia.com>
Mon, 3 Nov 2014 11:08:24 +0000 (12:08 +0100)
committerThierry Reding <treding@nvidia.com>
Thu, 13 Nov 2014 12:27:26 +0000 (13:27 +0100)
When creating a dumb buffer object using the DRM_IOCTL_MODE_CREATE_DUMB
IOCTL, only the width, height, bpp and flags fields are inputs. The
caller is not guaranteed to zero out or set handle, pitch and size.
Drivers must not treat these values as possible inputs, otherwise they
may use uninitialized memory during the computation of the framebuffer
size.

The R-Car DU driver treats the pitch passed in from userspace as minimum
and will only overwrite it when the driver-computed pitch is larger,
allowing userspace to, intentionally or not, overallocate framebuffers.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/gpu/drm/rcar-du/rcar_du_kms.c

index 5329491e32c32259084b719edd74e18be22d9ead..6289e3797bc5a6bf92b350e6f68a3cc57cd3a420 100644 (file)
@@ -126,7 +126,7 @@ int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev,
        else
                align = 16 * args->bpp / 8;
 
-       args->pitch = roundup(max(args->pitch, min_pitch), align);
+       args->pitch = roundup(min_pitch, align);
 
        return drm_gem_cma_dumb_create_internal(file, dev, args);
 }