diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-03-25 17:30:21 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-03-25 17:30:21 +0000 |
| commit | dc42cc1d195a16683c45fc87eb2dc333087a90da (patch) | |
| tree | 29627227d7571268f52763d3d25e837a88757b34 | |
| parent | shm: scroll: keep shm pool around, and fix its size at max allowed (diff) | |
shm: seal the memfd
This both prevents accidental resizing of the memfd, and allows the
Wayland server to optimze reads from the buffer - it no longer has to
setup SIGBUS handlers.
| -rw-r--r-- | shm.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -277,6 +277,15 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie, goto err; } + /* 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"); + goto err; + } + pool = wl_shm_create_pool(shm, pool_fd, memfd_size); if (pool == NULL) { LOG_ERR("failed to create SHM pool"); |
