RESOLVED FIXED 217514
[GLIB] Fix linking error for systems not providing <sys/memfd.h>
https://bugs.webkit.org/show_bug.cgi?id=217514
Summary [GLIB] Fix linking error for systems not providing <sys/memfd.h>
Sergio Villar Senin
Reported 2020-10-09 04:35:49 PDT
[GLIB] Fix linking error for systems not providing <sys/memfd.h>
Attachments
Patch (1.27 KB, patch)
2020-10-09 04:38 PDT, Sergio Villar Senin
no flags
Patch (3.26 KB, patch)
2020-10-09 05:13 PDT, Sergio Villar Senin
no flags
Patch (1.95 KB, patch)
2020-10-13 02:10 PDT, Sergio Villar Senin
no flags
Sergio Villar Senin
Comment 1 2020-10-09 04:38:40 PDT
Sergio Villar Senin
Comment 2 2020-10-09 05:13:35 PDT
Sergio Villar Senin
Comment 3 2020-10-09 05:14:33 PDT
Thanks for the review Carlos!. Adrian suggested to do a compile check, so I'm attaching an alternative patch with some extra cmake changes.
Adrian Perez
Comment 4 2020-10-09 05:19:38 PDT
Comment on attachment 410931 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=410931&action=review I think there is a better approach, as outlined below. > Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp:45 > #include <sys/memfd.h> It seems that there was a mistake in the manual pages for memfd_create, and it was never intended for it to suggest using <sys/memfd.h>. There is some discussion about that here. https://stackoverflow.com/questions/56615488/getting-gcc-error-sys-memfd-h-no-such-file-or-directory > Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp:49 > +#include <sys/mman.h> The <sys/mman.h> header always exists, we do not need to check whether it's available. What we can do is: 1. Always include <sys/mman.h>. This also works for other systems, for example FreeBSD also has a memfd_create() function defined in this header: https://github.com/freebsd/freebsd/commit/575e351fdd996f72921b87e71c2c26466e887ed2 2. If the MFD_* macros are not defined, include <linux/memfd.h> and use syscall2() Note: Use this fall only for linux, e.g. with a __has_include(<linux/memfd.h>) guard.
Adrian Perez
Comment 5 2020-10-09 05:22:05 PDT
On a second thought, I think we do not need the CMake compile check when using the approach of always using <sys/mman.h> and the fallback with <linux/memfd.h>+syscall2() only on Linux. That will also cover the BSDs which implement a compatible memfd_create() function, without adding complexity in CMake. BTW, thanks Sergio for the patch, and sorry for the back and forth about the CMake check O:-)
Konstantin Tokarev
Comment 6 2020-10-09 05:28:06 PDT
Does bubblewrap work on BSD at all? BubblewrapLauncher makes unconditional use of seccomp which is Linux-only.
Konstantin Tokarev
Comment 7 2020-10-09 06:58:14 PDT
OTOH, we have other usage of memfd in Platform/unix/SharedMemoryUnix.cpp, where it indeed could be checked in more cross-platform way.
Patrick Griffis
Comment 8 2020-10-09 08:07:50 PDT
(In reply to Konstantin Tokarev from comment #6) > Does bubblewrap work on BSD at all? No it is Linux specific.
Carlos Garcia Campos
Comment 9 2020-10-11 00:24:04 PDT
Comment on attachment 410934 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=410934&action=review > Source/cmake/OptionsCommon.cmake:-126 > -WEBKIT_CHECK_HAVE_INCLUDE(HAVE_LINUX_MEMFD_H linux/memfd.h) We use this in SharedMemoryUnix.cpp
Sergio Villar Senin
Comment 10 2020-10-13 02:10:18 PDT
Konstantin Tokarev
Comment 11 2020-10-13 02:21:29 PDT
I think it would be more correct to add compilation tests for memfd_create and use its results in all places where memfd is used
EWS
Comment 12 2020-10-14 10:44:58 PDT
Committed r268472: <https://trac.webkit.org/changeset/268472> All reviewed patches have been landed. Closing bug and clearing flags on attachment 411203 [details].
Radar WebKit Bug Importer
Comment 13 2020-10-14 10:45:22 PDT
Note You need to log in before you can comment on or make changes to this bug.