[systemd-commits] src/libsystemd src/shared

Lennart Poettering lennart at kemper.freedesktop.org
Thu Oct 30 08:24:17 PDT 2014


 src/libsystemd/sd-bus/bus-kernel.c |    2 +-
 src/shared/memfd.c                 |    2 +-
 src/shared/missing.h               |    6 +++++-
 3 files changed, 7 insertions(+), 3 deletions(-)

New commits:
commit 45071fcaa03eafc27352987fa2277b2792725036
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Oct 30 16:23:34 2014 +0100

    memfd: always create our memfds with CLOEXEC set
    
    We really shouldn't create fds ever that have the flag unset.

diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 0327614..3f8b0ab 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -1129,7 +1129,7 @@ int bus_kernel_pop_memfd(sd_bus *bus, void **address, size_t *mapped, size_t *al
                 if (!g)
                         return -ENOMEM;
 
-                r = memfd_create(g, MFD_ALLOW_SEALING);
+                r = memfd_create(g, MFD_ALLOW_SEALING|MFD_CLOEXEC);
                 if (r < 0)
                         return -errno;
 
diff --git a/src/shared/memfd.c b/src/shared/memfd.c
index 162c12f..f3ce8f8 100644
--- a/src/shared/memfd.c
+++ b/src/shared/memfd.c
@@ -65,7 +65,7 @@ int memfd_new(const char *name) {
                 }
         }
 
-        fd = memfd_create(name, MFD_ALLOW_SEALING);
+        fd = memfd_create(name, MFD_ALLOW_SEALING | MFD_CLOEXEC);
         if (fd < 0)
                 return -errno;
 
diff --git a/src/shared/missing.h b/src/shared/missing.h
index 7725e47..0d7c559 100644
--- a/src/shared/missing.h
+++ b/src/shared/missing.h
@@ -74,7 +74,11 @@
 #endif
 
 #ifndef MFD_ALLOW_SEALING
-#define MFD_ALLOW_SEALING 0x0002ULL
+#define MFD_ALLOW_SEALING 0x0002U
+#endif
+
+#ifndef MFD_CLOEXEC
+#define MFD_CLOEXEC 0x0001U
 #endif
 
 #ifndef IP_FREEBIND



More information about the systemd-commits mailing list