From 500a6b3acc2f8e3bb6be1883c02004619c9edd32 Mon Sep 17 00:00:00 2001 From: Aleksei Bavshin Date: Fri, 10 Jul 2020 07:24:32 -0700 Subject: Use private mapping for memfd with keymap. mmap with MAP_SHARED would fail if the compositor provides a read-only descriptor with keymap. And at least weston applies F_SEAL_WRITE to the memfd if supported by the platform. Fixes #263 --- src/wl_window.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/wl_window.c b/src/wl_window.c index 37fda4b..17ea976 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -105,9 +105,12 @@ static void keyboard_keymap(void *data, struct wl_keyboard *keyboard, (void)keyboard; (void)format; struct imv_window *window = data; - char *src = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0); - imv_keyboard_set_keymap(window->keyboard, src); - munmap(src, size); + char *src = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0); + + if (src != MAP_FAILED) { + imv_keyboard_set_keymap(window->keyboard, src); + munmap(src, size); + } close(fd); } -- cgit v1.2.3