WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
189741
[Linux] Use memfd_create when available in SharedMemory implementation
https://bugs.webkit.org/show_bug.cgi?id=189741
Summary
[Linux] Use memfd_create when available in SharedMemory implementation
Carlos Garcia Campos
Reported
2018-09-19 03:04:55 PDT
Instead of shm_open.
Attachments
Patch
(5.00 KB, patch)
2018-09-19 03:08 PDT
,
Carlos Garcia Campos
mcatanzaro
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Carlos Garcia Campos
Comment 1
2018-09-19 03:08:22 PDT
Created
attachment 350101
[details]
Patch
Michael Catanzaro
Comment 2
2018-09-19 06:59:25 PDT
Comment on
attachment 350101
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=350101&action=review
In this case, I would check for sys/memfd.h instead of linux/memfd.h and use memfd_create() directly if it's available (glibc 2.27 or newer) rather than using syscall(). Then you don't have to check for EINTR or ENOSYS. This way works too, of course.
> Source/WebKit/Platform/unix/SharedMemoryUnix.cpp:128 > + if (errno == ENOSYS) > + return fileDescriptor;
Surely this isn't right? You should just remove this condition and fall through to isMemFdAvailable = false, right?
> Source/WebKit/Platform/unix/SharedMemoryUnix.cpp:154 > - WTFLogAlways("Failed to create shared memory file %s: %s", tempName.data(), strerror(errno)); > + WTFLogAlways("Failed to create shared memory file: %s", strerror(errno));
Drop the word "file"
Carlos Garcia Campos
Comment 3
2018-09-20 00:04:23 PDT
(In reply to Michael Catanzaro from
comment #2
)
> Comment on
attachment 350101
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=350101&action=review
> > In this case, I would check for sys/memfd.h instead of linux/memfd.h and use > memfd_create() directly if it's available (glibc 2.27 or newer) rather than > using syscall(). Then you don't have to check for EINTR or ENOSYS. > > This way works too, of course.
I'm assuming this is available in more systems, no?
> > Source/WebKit/Platform/unix/SharedMemoryUnix.cpp:128 > > + if (errno == ENOSYS) > > + return fileDescriptor; > > Surely this isn't right? You should just remove this condition and fall > through to isMemFdAvailable = false, right?
Yes, I changed this several times and ended up with the wrong check. Good catch!
> > Source/WebKit/Platform/unix/SharedMemoryUnix.cpp:154 > > - WTFLogAlways("Failed to create shared memory file %s: %s", tempName.data(), strerror(errno)); > > + WTFLogAlways("Failed to create shared memory file: %s", strerror(errno)); > > Drop the word "file"
Sure.
Michael Catanzaro
Comment 4
2018-09-20 09:11:38 PDT
(In reply to Carlos Garcia Campos from
comment #3
)
> I'm assuming this is available in more systems, no?
The syscall was added years before the glibc interface, but so what? It's nicer to use the glibc function, and there is a fallback, after all. syscall() is used in the sandbox code because it's really needed there, but here it's not: there is a fallback.
Carlos Garcia Campos
Comment 5
2018-09-22 00:54:35 PDT
(In reply to Michael Catanzaro from
comment #4
)
> (In reply to Carlos Garcia Campos from
comment #3
) > > I'm assuming this is available in more systems, no? > > The syscall was added years before the glibc interface, but so what? It's > nicer to use the glibc function, and there is a fallback, after all. > syscall() is used in the sandbox code because it's really needed there, but > here it's not: there is a fallback.
I still don't understand why sandbox code can't use SharedMemory.
Carlos Garcia Campos
Comment 6
2018-11-07 06:24:17 PST
Committed
r237922
: <
https://trac.webkit.org/changeset/237922
>
Radar WebKit Bug Importer
Comment 7
2018-11-07 06:25:49 PST
<
rdar://problem/45873944
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug