hack: use MAP_NOSIGBUS

Use MAP_NOSIGBUS from [1].

[1]: https://lore.kernel.org/linux-mm/1622589753-9206-1-git-send-email-mlin@kernel.org/

Signed-off-by: Simon Ser <contact@emersion.fr>
This commit is contained in:
Simon Ser 2021-06-03 14:41:30 +02:00
parent abcf1048e2
commit 1d71eeddbd

View file

@ -49,6 +49,10 @@
#include "wayland-private.h" #include "wayland-private.h"
#include "wayland-server.h" #include "wayland-server.h"
#ifndef MAP_NOSIGBUS
#define MAP_NOSIGBUS 0x200000
#endif
/* This once_t is used to synchronize installing the SIGBUS handler /* This once_t is used to synchronize installing the SIGBUS handler
* and creating the TLS key. This will be done in the first call * and creating the TLS key. This will be done in the first call
* wl_shm_buffer_begin_access which can happen from any thread */ * wl_shm_buffer_begin_access which can happen from any thread */
@ -284,7 +288,7 @@ shm_create_pool(struct wl_client *client, struct wl_resource *resource,
seals = 0; seals = 0;
pool->sigbus_is_impossible = (seals & F_SEAL_SHRINK) ? true : false; pool->sigbus_is_impossible = (seals & F_SEAL_SHRINK) ? true : false;
#else #else
pool->sigbus_is_impossible = false; pool->sigbus_is_impossible = true;
#endif #endif
pool->internal_refcount = 1; pool->internal_refcount = 1;
@ -292,7 +296,7 @@ shm_create_pool(struct wl_client *client, struct wl_resource *resource,
pool->size = size; pool->size = size;
pool->new_size = size; pool->new_size = size;
pool->data = mmap(NULL, size, pool->data = mmap(NULL, size,
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); PROT_READ, MAP_PRIVATE | MAP_NOSIGBUS, fd, 0);
if (pool->data == MAP_FAILED) { if (pool->data == MAP_FAILED) {
wl_resource_post_error(resource, wl_resource_post_error(resource,
WL_SHM_ERROR_INVALID_FD, WL_SHM_ERROR_INVALID_FD,