Mesa (main): iris: export GEM handle with RDWR access rights

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 18 09:04:36 UTC 2021


Module: Mesa
Branch: main
Commit: b74898ef699486d0513fcd3af2587a831df99dff
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b74898ef699486d0513fcd3af2587a831df99dff

Author: Maksim Sisov <msisov at igalia.com>
Date:   Tue May 18 08:23:56 2021 +0300

iris: export GEM handle with RDWR access rights

There is a regression that made it impossible to export gem
handles with write access.

That is, a client may export gem handles of each buffer plane, then
export dmabuf fds using these handles, and mmap these dmabuf in
a different process (this is what Chromium does).

After https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4861,
it became impossible as mmap resulted in EACCESS error as slightly
different approach was taken for exporting these gem handles.

This CL fixes exporting gem handles (which are exported from dmabuf
fds) by adding the DRM_RDWR flag.

Cc: mesa-stable

Fixes #3119

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10851>

---

 src/gallium/drivers/iris/iris_bufmgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/gallium/drivers/iris/iris_bufmgr.c b/src/gallium/drivers/iris/iris_bufmgr.c
index 99dd2e79135..1c731a44989 100644
--- a/src/gallium/drivers/iris/iris_bufmgr.c
+++ b/src/gallium/drivers/iris/iris_bufmgr.c
@@ -1572,7 +1572,7 @@ iris_bo_export_dmabuf(struct iris_bo *bo, int *prime_fd)
    iris_bo_make_external(bo);
 
    if (drmPrimeHandleToFD(bufmgr->fd, bo->gem_handle,
-                          DRM_CLOEXEC, prime_fd) != 0)
+                          DRM_CLOEXEC | DRM_RDWR, prime_fd) != 0)
       return -errno;
 
    return 0;



More information about the mesa-commit mailing list