shared: Use memfd_create() when available
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Mon, 22 Jul 2019 13:06:20 +0000 (15:06 +0200)
committerPekka Paalanen <pq@iki.fi>
Thu, 24 Oct 2019 07:32:17 +0000 (07:32 +0000)
commitdeae98ef45e060b8412a5edd195fb0c7c14f0321
treef753c0d188a218cd1fdd153d47dad9d5b3f210cb
parent23d01c67a320ab1920e4864f6d182bad93258112
shared: Use memfd_create() when available

This (so-far) Linux-only API lets users create file descriptors purely
in memory, without any backing file on the filesystem and the race
condition which could ensue when unlink()ing it.

It also allows seals to be placed on the file, ensuring to every other
process that we won’t be allowed to shrink the contents, potentially
causing a SIGBUS when they try reading it.

This patch is best viewed with the -w option of git log -p.

It is an almost exact copy of Wayland commit
6908c8c85a2e33e5654f64a55cd4f847bf385cae, see
https://gitlab.freedesktop.org/wayland/wayland/merge_requests/4

Signed-off-by: Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
meson.build
shared/os-compatibility.c
tests/bad-buffer-test.c