From 83b086a16eb2bf36bf541bc100bc1083fcc2d579 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 18 Feb 2019 15:28:22 +0300 Subject: [PATCH] shm: Always try to set F_SEAL_SHRINK for created SHM files Sealing is working not only for files created by memfd_create(), but also on tmpfs files. --- Xext/shm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Xext/shm.c b/Xext/shm.c index 506fd4df1..5c10ad4ef 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -1207,7 +1207,6 @@ shm_tmpfile(void) #ifdef HAVE_MEMFD_CREATE fd = memfd_create("xorg", MFD_CLOEXEC|MFD_ALLOW_SEALING); if (fd != -1) { - fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK); DebugF ("Using memfd_create\n"); return fd; } @@ -1274,6 +1273,9 @@ ProcShmCreateSegment(ClientPtr client) close(fd); return BadAlloc; } +#if defined(F_ADD_SEALS) && defined(F_SEAL_SHRINK) + fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK); +#endif shmdesc = malloc(sizeof(ShmDescRec)); if (!shmdesc) { close(fd);