1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 19:21:53 +03:00

memfd: always create our memfds with CLOEXEC set

We really shouldn't create fds ever that have the flag unset.
This commit is contained in:
Lennart Poettering 2014-10-30 16:23:34 +01:00
parent ef309a681f
commit 45071fcaa0
3 changed files with 7 additions and 3 deletions

View File

@ -1129,7 +1129,7 @@ int bus_kernel_pop_memfd(sd_bus *bus, void **address, size_t *mapped, size_t *al
if (!g) if (!g)
return -ENOMEM; return -ENOMEM;
r = memfd_create(g, MFD_ALLOW_SEALING); r = memfd_create(g, MFD_ALLOW_SEALING|MFD_CLOEXEC);
if (r < 0) if (r < 0)
return -errno; return -errno;

View File

@ -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) if (fd < 0)
return -errno; return -errno;

View File

@ -74,7 +74,11 @@
#endif #endif
#ifndef MFD_ALLOW_SEALING #ifndef MFD_ALLOW_SEALING
#define MFD_ALLOW_SEALING 0x0002ULL #define MFD_ALLOW_SEALING 0x0002U
#endif
#ifndef MFD_CLOEXEC
#define MFD_CLOEXEC 0x0001U
#endif #endif
#ifndef IP_FREEBIND #ifndef IP_FREEBIND