GNOME Bugzilla – Bug 761095
wayland: use shm_open instead of open in tmpdir
Last modified: 2016-01-25 18:38:04 UTC
The tmpdir is used for a wide assortment of things, and can easily fill up. If it fills then desktop will start crashing with SIGBUS errors. This commit changes the shm pool allocation code, to use shm_open, so the shared memory files will go in their dedicated space.
Created attachment 319692 [details] [review] wayland: use shm_open instead of open in tmpdir
an alternative idea would be to use memfd_create, but that's apparently not in my glibc yet, so I'd have to use syscall() directly.
Review of attachment 319692 [details] [review]: Looks good to me
Created attachment 319697 [details] [review] wayland: use memfd_create instead of open in tmpdir The tmpdir is used for a wide assortment of things, and can easily fill up. If it fills then desktop will start crashing with SIGBUS errors. This commit changes the shm pool allocation code, to use memfd_create, instead, so the shared memory files will be anonymous and not associated with /tmp
for completeness, this is the memfd_create approach ^ as mentioned before it uses syscall() directly since the wrapper isn't on my system. The SYS_ definition is, though, I so I made use of it. There's no fallback code path since this is in wayland and linux specific parts of gtk anyway. Since there's no fallback code path, I also didn't bother adding configure logic.
Review of attachment 319697 [details] [review]: I like that better.
Review of attachment 319697 [details] [review]: ::: gdk/wayland/gdkdisplay-wayland.c @@ +23,3 @@ #include <unistd.h> #include <fcntl.h> +#include <linux/memfd.h> I guess we should add a HAVE_MEMFD_H check inside configure, in order to be able to build the Wayland backend on Linux kernels without memfd (e.g. too old).
let's see if there are such people before we add a fall back code path that might not get tested in practice. wayland is pretty unique in that the people using it, aren't really using legacy systems. memfd has been in the kernel for over a year now I think. Of course, we can always land a fallback path later if there are complaints.
Attachment 319697 [details] pushed as df70e28 - wayland: use memfd_create instead of open in tmpdir