diff options
| author | 6t8k <6t8k@noreply.codeberg.org> | 2023-10-05 10:22:44 +0000 |
|---|---|---|
| committer | 6t8k <6t8k@noreply.codeberg.org> | 2023-10-05 10:33:05 +0000 |
| commit | 61eb56dfda605427156b52d019be4bf5ce84c3aa (patch) | |
| tree | 6eed5a0fadc6cc8de3582110072c2e298cf5e9bf | |
| parent | term_reset: log hard vs. soft reset (diff) | |
shm: if defined, set MFD_NOEXEC_SEAL flag for memfd_create
Effective from Linux 6.3.0 onward, this creates the memfd without
execute permissions and prevents that setting from ever being changed.
This is a defense-in-depth security measure and prevents a respective
kernel warning from being emitted.
See https://lwn.net/Articles/918106/ for more information.
| -rw-r--r-- | shm.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -330,8 +330,13 @@ get_new_buffers(struct buffer_chain *chain, size_t count, struct buffer_pool *pool = NULL; /* Backing memory for SHM */ +#if defined(MFD_NOEXEC_SEAL) + #define FOOT_MFD_FLAGS (MFD_CLOEXEC | MFD_ALLOW_SEALING | MFD_NOEXEC_SEAL) +#else + #define FOOT_MFD_FLAGS (MFD_CLOEXEC | MFD_ALLOW_SEALING) +#endif #if defined(MEMFD_CREATE) - pool_fd = memfd_create("foot-wayland-shm-buffer-pool", MFD_CLOEXEC | MFD_ALLOW_SEALING); + pool_fd = memfd_create("foot-wayland-shm-buffer-pool", FOOT_MFD_FLAGS); #elif defined(__FreeBSD__) // memfd_create on FreeBSD 13 is SHM_ANON without sealing support pool_fd = shm_open(SHM_ANON, O_RDWR | O_CLOEXEC, 0600); |
