All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] drm: Sanitize DRM_IOCTL_MODE_CREATE_DUMB input
@ 2014-11-05 13:25 Thierry Reding
  2014-11-05 13:25 ` [PATCH 1/7] drm/gem: Fix a few kerneldoc typos Thierry Reding
                   ` (8 more replies)
  0 siblings, 9 replies; 37+ messages in thread
From: Thierry Reding @ 2014-11-05 13:25 UTC (permalink / raw)
  To: Dave Airlie
  Cc: Benjamin Gaignard, Daniel Vetter, dri-devel, Tomi Valkeinen,
	Archit Taneja, Laurent Pinchart, Russell King

From: Thierry Reding <treding@nvidia.com>

Drivers currently treat the IOCTL data for DRM_IOCTL_MODE_CREATE_DUMB
inconsistently. While the documentation clearly states that the handle,
pitch and size fields are outputs, some drivers use their values as a
minimum hint from userspace, presumably to allow userspace to over-
allocate buffers on purpose (for example after negotiating pitch
alignment requirements with other devices).

Most of userspace is well-behaved in that in zeros out the output fields
which works well with drivers that use them as minima. However, some
userspace (like Mesa's GBM DRI backend) only initializes the inputs, so
that the driver will end up using uninitialized data from the stack in
the computations. This can cause the driver to attempt very large
allocations, resulting in failure, or silently use excessively  large
buffers.

This series tries to fix this by sanitizing the IOCTL data (setting the
output fields to 0 in the kernel) so that drivers can no longer use
uninitialized data. While at it, it also fixes existing drivers to not
treat output fields as input/output for consistency.

Note that this is technically breaking ABI since overallocating will no
longer be possible after this series is applied. However, the public DRM
headers have always documented the fields as being outputs, so any
application relying on them being inputs could be considered buggy. The
hope is that no such applications exist in the wild.

Discussion on IRC lead to the conclusion that new IOCTLs should have
input validation and require userspace to zero out output parameters to
avoid this kind of mess in the future. In order to help avoid this kind
of ambiguity it would be a good idea to start documenting IOCTLs more
officially (e.g. in the DRM DocBook).

I'm adding a bunch of people on Cc to get feedback about what userspace
people know might be relying on the current behaviour. Drivers that are
impacted are OMAP, R-Car and any that use GEM CMA helpers.

This series also contains a couple of preparatory patches that add the
GEM CMA helpers to our DocBook.

Thierry

Thierry Reding (7):
  drm/gem: Fix a few kerneldoc typos
  drm/doc: mm: Fix indentation
  drm/doc: Add GEM/CMA helpers to kerneldoc
  drm/cma: Introduce drm_gem_cma_dumb_create_internal()
  drm/omap: gem: dumb: pitch is an output
  drm/rcar: gem: dumb: pitch is an output
  drm: Sanitize DRM_IOCTL_MODE_CREATE_DUMB input

 Documentation/DocBook/drm.tmpl        | 274 +++++++++++++++++-----------------
 drivers/gpu/drm/drm_crtc.c            |   8 +
 drivers/gpu/drm/drm_gem.c             |  11 +-
 drivers/gpu/drm/drm_gem_cma_helper.c  | 182 +++++++++++++++++-----
 drivers/gpu/drm/omapdrm/omap_gem.c    |   2 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c |   4 +-
 include/drm/drm_gem_cma_helper.h      |  30 +++-
 7 files changed, 319 insertions(+), 192 deletions(-)

-- 
2.1.3

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2014-11-07  8:03 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-05 13:25 [PATCH 0/7] drm: Sanitize DRM_IOCTL_MODE_CREATE_DUMB input Thierry Reding
2014-11-05 13:25 ` [PATCH 1/7] drm/gem: Fix a few kerneldoc typos Thierry Reding
2014-11-05 14:18   ` Daniel Vetter
2014-11-05 13:25 ` [PATCH 2/7] drm/doc: mm: Fix indentation Thierry Reding
2014-11-05 14:19   ` Daniel Vetter
2014-11-05 13:25 ` [PATCH 3/7] drm/doc: Add GEM/CMA helpers to kerneldoc Thierry Reding
2014-11-05 14:34   ` Daniel Vetter
2014-11-05 15:01     ` Thierry Reding
2014-11-05 15:04       ` Daniel Vetter
2014-11-05 15:16         ` Thierry Reding
2014-11-05 13:25 ` [PATCH 4/7] drm/cma: Introduce drm_gem_cma_dumb_create_internal() Thierry Reding
2014-11-05 14:36   ` Daniel Vetter
2014-11-05 13:25 ` [PATCH 5/7] drm/omap: gem: dumb: pitch is an output Thierry Reding
2014-11-05 14:38   ` Daniel Vetter
2014-11-05 13:25 ` [PATCH 6/7] drm/rcar: " Thierry Reding
2014-11-05 14:39   ` Daniel Vetter
2014-11-05 18:47   ` Laurent Pinchart
2014-11-06  0:54     ` Russell King - ARM Linux
2014-11-06 18:17       ` Laurent Pinchart
2014-11-05 13:25 ` [PATCH 7/7] drm: Sanitize DRM_IOCTL_MODE_CREATE_DUMB input Thierry Reding
2014-11-05 14:42   ` Daniel Vetter
2014-11-05 14:24 ` [PATCH 0/7] " Russell King - ARM Linux
2014-11-05 14:45   ` Thierry Reding
2014-11-05 15:01   ` Daniel Vetter
2014-11-06 15:49 ` [PATCH v2 0/8] " Thierry Reding
2014-11-06 15:49   ` [PATCH v2 1/8] drm/gem: Fix a few kerneldoc typos Thierry Reding
2014-11-06 15:49   ` [PATCH v2 2/8] drm/doc: mm: Fix indentation Thierry Reding
2014-11-06 15:49   ` [PATCH v2 3/8] drm/doc: Add GEM/CMA helpers to kerneldoc Thierry Reding
2014-11-06 20:05     ` Daniel Vetter
2014-11-06 15:49   ` [PATCH v2 4/8] drm/cma: Introduce drm_gem_cma_dumb_create_internal() Thierry Reding
2014-11-06 15:49   ` [PATCH v2 5/8] drm/omap: gem: dumb: pitch is an output Thierry Reding
2014-11-06 22:23     ` Rob Clark
2014-11-07  8:02     ` Tomi Valkeinen
2014-11-06 15:49   ` [PATCH v2 6/8] drm/rcar: " Thierry Reding
2014-11-06 15:49   ` [PATCH v2 7/8] drm: Sanitize DRM_IOCTL_MODE_CREATE_DUMB input Thierry Reding
2014-11-06 15:49   ` [PATCH v2 8/8] drm/cma: Remove call to drm_gem_free_mmap_offset() Thierry Reding
2014-11-06 20:06     ` Daniel Vetter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.