Relax the restriction and permit read/write access on dma-buf
This patch relax the restriction and permit read/write access on dma-buf. In
particular this is necessary for the userspace mmap()ing a dma-buf fd, so
Chrome could now use it for unpriviledged Renderers write into a graphics
buffer without much difficulty. This has been discussed in upstream here:
http://lists.freedesktop.org/archives/dri-devel/2015-December/097562.html
Kernel changes are needed to use this userspace feature:
Author: Daniel Thompson <daniel.thompson@linaro.org>
Date: Fri Jun 19 14:52:28 2015 +0100
drm: prime: Honour O_RDWR during prime-handle-to-fd
BUG=chromium:581151
TEST=test_that -b strago $DEVICE graphics_SanAngeles
test_that -b strago $DEVICE graphics_GLBench
test_that -b strago $DEVICE graphics_Sanity
Change-Id: I37aff88623ba6aa45797b0ccb6cd2d15c5c51f41
Reviewed-on: https://chromium-review.googlesource.com/323990
Commit-Ready: Tiago Vignatti <tiago.vignatti@intel.com>
Tested-by: Tiago Vignatti <tiago.vignatti@intel.com>
Reviewed-by: Ilja Friedel <ihf@chromium.org>
Reviewed-by: Tiago Vignatti <tiago.vignatti@intel.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
diff --git a/gbm.c b/gbm.c
index 671fec0..b438173 100644
--- a/gbm.c
+++ b/gbm.c
@@ -351,6 +351,10 @@
return bo->handles[plane];
}
+#ifndef DRM_RDWR
+#define DRM_RDWR O_RDWR
+#endif
+
PUBLIC int
gbm_bo_get_plane_fd(struct gbm_bo *bo, size_t plane)
{
@@ -360,7 +364,7 @@
if (drmPrimeHandleToFD(
gbm_device_get_fd(bo->gbm),
gbm_bo_get_plane_handle(bo, plane).u32,
- DRM_CLOEXEC,
+ DRM_CLOEXEC | DRM_RDWR,
&fd))
return -1;
else