Mesa (master): st/dri: replace calls to dup(2) with fcntl(F_DUPFD_CLOEXEC)
Nicolai Hähnle
nh at kemper.freedesktop.org
Tue Oct 4 09:10:33 UTC 2016
Module: Mesa
Branch: master
Commit: 0c060f691c0827b0a66e97a4a7f54385de14cdb8
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0c060f691c0827b0a66e97a4a7f54385de14cdb8
Author: Matt Whitlock <freedesktop at mattwhitlock.name>
Date: Sat Oct 1 23:49:43 2016 -0400
st/dri: replace calls to dup(2) with fcntl(F_DUPFD_CLOEXEC)
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>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>
---
src/gallium/state_trackers/dri/dri2.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index 64d9c3e..9ec069b 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -30,6 +30,7 @@
#include <xf86drm.h>
#include <dlfcn.h>
+#include <fcntl.h>
#include "GL/mesa_glinterop.h"
#include "util/u_memory.h"
#include "util/u_inlines.h"
@@ -1877,7 +1878,7 @@ dri2_init_screen(__DRIscreen * sPriv)
sPriv->driverPrivate = (void *)screen;
- if (screen->fd < 0 || (fd = dup(screen->fd)) < 0)
+ if (screen->fd < 0 || (fd = fcntl(screen->fd, F_DUPFD_CLOEXEC, 3)) < 0)
goto free_screen;
if (pipe_loader_drm_probe_fd(&screen->dev, fd))
@@ -1960,7 +1961,7 @@ dri_kms_init_screen(__DRIscreen * sPriv)
sPriv->driverPrivate = (void *)screen;
- if (screen->fd < 0 || (fd = dup(screen->fd)) < 0)
+ if (screen->fd < 0 || (fd = fcntl(screen->fd, F_DUPFD_CLOEXEC, 3)) < 0)
goto free_screen;
if (pipe_loader_sw_probe_kms(&screen->dev, fd))
More information about the mesa-commit
mailing list