[Mesa-dev] [PATCH 1/5] egl/android: replace call to dup(2) with fcntl(F_DUPFD_CLOEXEC)

Matt Whitlock freedesktop at mattwhitlock.name
Sun Oct 2 03:49:41 UTC 2016


Without this fix, duplicated file descriptors leak into child processes.
See commit aaac913e901229d11a1894f6aaf646de6b1a542c for one instance
where the same fix was employed.

Cc: <mesa-stable at lists.freedesktop.org>
Signed-off-by: Matt Whitlock <freedesktop at mattwhitlock.name>
---
 src/egl/drivers/dri2/platform_android.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index 2e0df07..f868984 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -29,6 +29,7 @@
 
 #include <errno.h>
 #include <dlfcn.h>
+#include <fcntl.h>
 #include <xf86drm.h>
 
 #if ANDROID_VERSION >= 0x402
@@ -830,7 +831,7 @@ droid_open_device(void)
       fd = -1;
    }
 
-   return (fd >= 0) ? dup(fd) : -1;
+   return (fd >= 0) ? fcntl(fd, F_DUPFD_CLOEXEC, 3) : -1;
 }
 
 /* support versions < JellyBean */
-- 
2.10.0



More information about the mesa-dev mailing list