summaryrefslogtreecommitdiffstats
path: root/src/gbm
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2014-11-13 19:05:51 +0100
committerEmil Velikov <emil.l.velikov@gmail.com>2014-11-16 01:03:40 +0000
commit631090e1557437faa89f4dfd452a194241707363 (patch)
treeded89985d1e5b12a708b7452c1b14e6b3c42c2a2 /src/gbm
parent2efabd9f5a711a7f6cd1846630244b7814bf25b3 (diff)
downloadexternal_mesa3d-631090e1557437faa89f4dfd452a194241707363.zip
external_mesa3d-631090e1557437faa89f4dfd452a194241707363.tar.gz
external_mesa3d-631090e1557437faa89f4dfd452a194241707363.tar.bz2
dri/kms: Always zero out struct drm_mode_create_dumb
The DRM_IOCTL_MODE_CREATE_DUMB (and others) IOCTL isn't very rigorously specified, which has the effect that some kernel drivers do not consider the .pitch and .size fields of struct drm_mode_create_dumb outputs only. Instead they will use these as lower bounds and overwrite them only if the values that they compute are larger than what userspace provided. This works if and only if userspace initializes the fields explicitly to either 0 or some meaningful value. However, if userspace just leaves the values uninitialized and the struct drm_mode_create_dumb is allocated on the stack for example, the driver may try to overallocate buffers. Fortunately most userspace does zero out the structure before passing it to the IOCTL, but there are rare exceptions. Mesa is one of them. In an attempt to rectify this situation, kernel drivers are being updated to not use the .pitch and .size fields as inputs. However in order to fix the issue with older kernels, make sure that Mesa always zeros out the structure as well. Future IOCTLs should be more rigorously defined so that structures can be validated and IOCTLs rejected if output fields aren't set to zero. Signed-off-by: Thierry Reding <treding@nvidia.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Diffstat (limited to 'src/gbm')
-rw-r--r--src/gbm/backends/dri/gbm_dri.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 0664266..39e6b30 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -774,6 +774,7 @@ create_dumb(struct gbm_device *gbm,
if (bo == NULL)
return NULL;
+ memset(&create_arg, 0, sizeof(create_arg));
create_arg.bpp = 32;
create_arg.width = width;
create_arg.height = height;