diff options
author | Aleksei Bavshin <alebastr89@gmail.com> | 2020-07-10 07:24:32 -0700 |
---|---|---|
committer | Harry Jeffery <harry@exec64.co.uk> | 2020-07-21 01:50:01 +0100 |
commit | 500a6b3acc2f8e3bb6be1883c02004619c9edd32 (patch) | |
tree | 46df6e263186a5afd1ace5a5efb6399c65452f89 /src | |
parent | 767ce08307df6e816fcca7dfd747d8cc6a593fc5 (diff) | |
download | imv-500a6b3acc2f8e3bb6be1883c02004619c9edd32.tar.gz |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/wl_window.c | 9 |
1 files changed, 6 insertions, 3 deletions
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); } |