Mesa (master): gallium/auxiliary: replace call 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: 5d0069eca2c5e29ef9255f9b0e70d4daefd10ce8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5d0069eca2c5e29ef9255f9b0e70d4daefd10ce8

Author: Matt Whitlock <freedesktop at mattwhitlock.name>
Date:   Sat Oct  1 23:49:42 2016 -0400

gallium/auxiliary: replace call 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/auxiliary/vl/vl_winsys_drm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/vl/vl_winsys_drm.c b/src/gallium/auxiliary/vl/vl_winsys_drm.c
index 6a759ae..df8809c 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_drm.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_drm.c
@@ -26,6 +26,7 @@
  **************************************************************************/
 
 #include <assert.h>
+#include <fcntl.h>
 
 #include "pipe/p_screen.h"
 #include "pipe-loader/pipe_loader.h"
@@ -47,7 +48,7 @@ vl_drm_screen_create(int fd)
    if (!vscreen)
       return NULL;
 
-   if (fd < 0 || (new_fd = dup(fd)) < 0)
+   if (fd < 0 || (new_fd = fcntl(fd, F_DUPFD_CLOEXEC, 3)) < 0)
       goto free_screen;
 
    if (pipe_loader_drm_probe_fd(&vscreen->dev, new_fd))




More information about the mesa-commit mailing list