From 7fbc1f2c44482c56f1aacf00d74c20645db10a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 8 Oct 2023 11:12:08 +0200 Subject: [PATCH] bar/wayland: seal memfd --- bar/wayland.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bar/wayland.c b/bar/wayland.c index edbf0db..2b1148b 100644 --- a/bar/wayland.c +++ b/bar/wayland.c @@ -937,6 +937,17 @@ get_buffer(struct wayland_backend *backend) goto err; } +#if defined(MEMFD_CREATE) + /* Seal file - we no longer allow any kind of resizing */ + /* TODO: wayland mmaps(PROT_WRITE), for some unknown reason, hence we cannot use F_SEAL_FUTURE_WRITE */ + if (fcntl(pool_fd, F_ADD_SEALS, + F_SEAL_GROW | F_SEAL_SHRINK | /*F_SEAL_FUTURE_WRITE |*/ F_SEAL_SEAL) < 0) + { + LOG_ERRNO("failed to seal SHM backing memory file"); + /* This is not a fatal error */ + } +#endif + pool = wl_shm_create_pool(backend->shm, pool_fd, size); if (pool == NULL) { LOG_ERR("failed to create SHM pool");