After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 761095 - wayland: use shm_open instead of open in tmpdir
wayland: use shm_open instead of open in tmpdir
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Wayland
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2016-01-25 16:56 UTC by Ray Strode [halfline]
Modified: 2016-01-25 18:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
wayland: use shm_open instead of open in tmpdir (4.58 KB, patch)
2016-01-25 16:56 UTC, Ray Strode [halfline]
accepted-commit_now Details | Review
wayland: use memfd_create instead of open in tmpdir (5.84 KB, patch)
2016-01-25 18:02 UTC, Ray Strode [halfline]
committed Details | Review

Description Ray Strode [halfline] 2016-01-25 16:56:41 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.
Comment 1 Ray Strode [halfline] 2016-01-25 16:56:45 UTC
Created attachment 319692 [details] [review]
wayland: use shm_open instead of open in tmpdir
Comment 2 Ray Strode [halfline] 2016-01-25 16:59:19 UTC
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.
Comment 3 Matthias Clasen 2016-01-25 17:05:23 UTC
Review of attachment 319692 [details] [review]:

Looks good to me
Comment 4 Ray Strode [halfline] 2016-01-25 18:02:09 UTC
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
Comment 5 Ray Strode [halfline] 2016-01-25 18:05:17 UTC
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.
Comment 6 Matthias Clasen 2016-01-25 18:21:14 UTC
Review of attachment 319697 [details] [review]:

I like that better.
Comment 7 Emmanuele Bassi (:ebassi) 2016-01-25 18:27:17 UTC
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).
Comment 8 Ray Strode [halfline] 2016-01-25 18:36:02 UTC
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.
Comment 9 Ray Strode [halfline] 2016-01-25 18:38:00 UTC
Attachment 319697 [details] pushed as df70e28 - wayland: use memfd_create instead of open in tmpdir