Bug 113432 - shm_open is missing O_EXCL
Summary: shm_open is missing O_EXCL
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-27 12:07 PDT by Ted Unangst
Modified: 2015-11-11 10:04 PST (History)
8 users (show)

See Also:


Attachments
Patch (1.76 KB, patch)
2013-03-28 10:38 PDT, Matthew Dempsky
andersca: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ted Unangst 2013-03-27 12:07:49 PDT
From a visual inspection of http://trac.webkit.org/browser/releases/WebKitGTK/webkit-2.0/Source/WebKit2/Platform/unix/SharedMemoryUnix.cpp#L110

The call to shm_open lacks O_EXCL, meaning on a multiuser machine another user can create the shm object first. Iterating in a loop of random numbers is not sufficient to prevent this. They could in theory even create all possible names. And then webkit will be sharing memory with someone who is not the user running webkit.
Comment 1 Matthew Dempsky 2013-03-28 10:38:52 PDT
Created attachment 195596 [details]
Patch
Comment 2 Matthew Dempsky 2013-03-28 10:45:32 PDT
Also, it looks like there's a race condition in SharedMemory::createHandle(), by using dup() and then fcntl(fd, F_SETFD, FD_CLOEXEC).  This could be avoided by using fcntl(fd, F_DUPFD_CLOEXEC, 0) to atomically dup the file descriptor with FD_CLOEXEC set already.  Let me know if I should create a new bug for this or just include it in this patch.
Comment 3 Matthew Dempsky 2013-04-08 16:04:14 PDT
Any WK2 reviewers able to look at this?  Should be a simple review.  Thanks!  :)
Comment 4 Balazs Kelemen 2013-10-19 09:23:49 PDT
Makes sense. I think it's better to do do the dup thing in another patch.
Comment 5 Anders Carlsson 2015-11-11 10:04:21 PST
Comment on attachment 195596 [details]
Patch

There's no rationale for why we'd want to do this.