From f64cc04fe6822d4efe27d85bebb9d46477be4815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 22 May 2024 14:06:15 +0200 Subject: [PATCH] shm: minor optimization Don't retry memfd_create() without MFD_NOEXEC_SEAL is 0. The overall logic is this: * Try memfd_create() with MFD_NOEXEC_SEAL * If that fails (which it does, on older kernels), try without the flag If compiling against an older kernel, or on a system that doesn't support the noexec seal, MFD_NOEXEC_SEAL is 0. In this case, there's little point in retrying memfd_create a second time, with the exact same set of flags. --- shm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shm.c b/shm.c index fb868382..5b57ace6 100644 --- a/shm.c +++ b/shm.c @@ -350,7 +350,7 @@ get_new_buffers(struct buffer_chain *chain, size_t count, "foot-wayland-shm-buffer-pool", MFD_CLOEXEC | MFD_ALLOW_SEALING | MFD_NOEXEC_SEAL); - if (pool_fd < 0 && errno == EINVAL) { + if (pool_fd < 0 && errno == EINVAL && MFD_NOEXEC_SEAL != 0) { pool_fd = memfd_create( "foot-wayland-shm-buffer-pool", MFD_CLOEXEC | MFD_ALLOW_SEALING); }