Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Issue 27265002: Implement SharedMemory::NewAnonymousReadOnly(contents). (Closed)

Created:
7 years, 2 months ago by Jeffrey Yasskin
Modified:
7 years, 1 month ago
Reviewers:
Mark Mentovai, jschuh
CC:
awong, ianbeer, Mark Mentovai, Robert Sesek, jln (very slow on Chromium), Will Harris, Fady Samuel
Visibility:
Public.

Description

Implement SharedMemory::ShareReadOnlyToProcess(). This avoids potential security holes where the renderer could be exploited and then write into space shared by other renderers or even the browser. I've done this on Posix by opening both a read/write and read-only file descriptor to the same file. Then ShareReadOnlyToProcess dup()s the read-only descriptor instead of the read/write one. It's an error to try to ShareReadOnly from a SharedMemory that was created from a single SharedMemoryHandle. The test checks that operations strictly through the file handle can't get write access to the memory. On Linux there's still a hole through /dev/fd in the filesystem, but jln@ assures me that the sandbox prevents the filesystem-based attack. We should eventually write an explicit test for this. Android needs http://crbug.com/320865 figured out. BUG=302724, 320865 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=236347

Patch Set 1 #

Patch Set 2 : Simplify Mac test and start implementing for Windows #

Patch Set 3 : Implement test on Windows #

Patch Set 4 : Remove extra includes from user_script_master #

Patch Set 5 : Add errno.h #

Total comments: 25

Patch Set 6 : Don't check /dev/fd on Android, which doesn't have such a path #

Patch Set 7 : Fix most of Julien's comments #

Patch Set 8 : Add some tests on the stat() of the returned FD to debug odd linux_asan failure #

Patch Set 9 : Fix signedness on Mac #

Total comments: 2

Patch Set 10 : Test Android; don't review this patch #

Patch Set 11 : Implement ShareReadOnlyToProcess instead #

Total comments: 2

Patch Set 12 : Try to fix Android and Windows #

Total comments: 1

Patch Set 13 : Open the file twice to get a read-only version #

Patch Set 14 : Leave the handle writable on Android #

Total comments: 6

Patch Set 15 : Fix Mark's comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+238 lines, -42 lines) Patch
M base/memory/shared_memory.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 5 chunks +43 lines, -5 lines 0 comments Download
M base/memory/shared_memory_android.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +9 lines, -0 lines 0 comments Download
M base/memory/shared_memory_nacl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +7 lines, -1 line 0 comments Download
M base/memory/shared_memory_posix.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 14 chunks +80 lines, -30 lines 0 comments Download
M base/memory/shared_memory_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 3 chunks +87 lines, -0 lines 0 comments Download
M base/memory/shared_memory_win.cc View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +3 lines, -2 lines 0 comments Download
M chrome/browser/extensions/user_script_master.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +9 lines, -4 lines 0 comments Download

Messages

Total messages: 21 (0 generated)
Jeffrey Yasskin
PTAL. Albert, are you comfortable LGTM'ing once the security folks are happy, or do you ...
7 years, 2 months ago (2013-10-15 23:03:52 UTC) #1
jln (very slow on Chromium)
Thanks a lot for taking on this Jeffrey! Will or Justin: could you do another ...
7 years, 2 months ago (2013-10-16 00:16:38 UTC) #2
Jeffrey Yasskin
Let's see how the trybots feel about the stricter checks. :) https://codereview.chromium.org/27265002/diff/29001/base/memory/shared_memory.h File base/memory/shared_memory.h (right): ...
7 years, 2 months ago (2013-10-16 01:16:39 UTC) #3
jschuh
This interface feels awkward. Wouldn't it be better to add a ShareReadOnlyToProcess and GiveReadOnlyToProcess? Or, ...
7 years, 2 months ago (2013-10-16 13:32:32 UTC) #4
Will Harris
https://codereview.chromium.org/27265002/diff/66001/base/memory/shared_memory_unittest.cc File base/memory/shared_memory_unittest.cc (right): https://codereview.chromium.org/27265002/diff/66001/base/memory/shared_memory_unittest.cc#newcode456 base/memory/shared_memory_unittest.cc:456: ::DuplicateHandle(GetCurrentProcess(), should probably CloseHandle after this succeeds, or just ...
7 years, 2 months ago (2013-10-16 17:01:02 UTC) #5
jln (very slow on Chromium)
I have to rush to a meeting, I'll take another quick look later, but this ...
7 years, 2 months ago (2013-10-16 17:51:14 UTC) #6
Jeffrey Yasskin
Here's a version that defines ShareReadOnlyToProcess and GiveReadOnlyToProcess. After looking through some of the ShareToProcess ...
7 years, 2 months ago (2013-10-16 22:27:52 UTC) #7
Jeffrey Yasskin
https://codereview.chromium.org/27265002/diff/89001/base/memory/shared_memory_posix.cc File base/memory/shared_memory_posix.cc (right): https://codereview.chromium.org/27265002/diff/89001/base/memory/shared_memory_posix.cc#newcode417 base/memory/shared_memory_posix.cc:417: StringPrintf("/dev/fd/%d", mapped_file_); Note that this is going to fail ...
7 years, 2 months ago (2013-10-16 23:22:21 UTC) #8
jln (very slow on Chromium)
https://codereview.chromium.org/27265002/diff/89001/base/memory/shared_memory_posix.cc File base/memory/shared_memory_posix.cc (right): https://codereview.chromium.org/27265002/diff/89001/base/memory/shared_memory_posix.cc#newcode417 base/memory/shared_memory_posix.cc:417: StringPrintf("/dev/fd/%d", mapped_file_); On 2013/10/16 23:22:21, Jeffrey Yasskin wrote: > ...
7 years, 2 months ago (2013-10-16 23:58:05 UTC) #9
Jeffrey Yasskin
https://codereview.chromium.org/27265002/diff/99001/base/memory/shared_memory_posix.cc File base/memory/shared_memory_posix.cc (right): https://codereview.chromium.org/27265002/diff/99001/base/memory/shared_memory_posix.cc#newcode423 base/memory/shared_memory_posix.cc:423: new_fd = HANDLE_EINTR(open(writable_fd_path.c_str(), O_RDONLY)); This approach doesn't work on ...
7 years, 2 months ago (2013-10-17 03:00:25 UTC) #10
jln (very slow on Chromium)
On 2013/10/17 03:00:25, Jeffrey Yasskin wrote: > https://codereview.chromium.org/27265002/diff/99001/base/memory/shared_memory_posix.cc > File base/memory/shared_memory_posix.cc (right): > > https://codereview.chromium.org/27265002/diff/99001/base/memory/shared_memory_posix.cc#newcode423 ...
7 years, 2 months ago (2013-10-17 19:15:10 UTC) #11
Jeffrey Yasskin
On 2013/10/17 19:15:10, jln wrote: > On 2013/10/17 03:00:25, Jeffrey Yasskin wrote: > > > ...
7 years, 2 months ago (2013-10-21 16:28:25 UTC) #12
Robert Sesek
On 2013/10/21 16:28:25, Jeffrey Yasskin wrote: > On 2013/10/17 19:15:10, jln wrote: > > On ...
7 years, 2 months ago (2013-10-21 20:10:24 UTC) #13
Mark Mentovai
I think that the best approach is to do a pair of opens, taking care ...
7 years, 1 month ago (2013-10-25 19:53:22 UTC) #14
Jeffrey Yasskin
This is finally ready. I bailed on getting Android to work, for now: http://crbug.com/320865.
7 years, 1 month ago (2013-11-19 00:03:06 UTC) #15
jschuh
LGTM on the general API and Windows implementation.
7 years, 1 month ago (2013-11-19 00:34:26 UTC) #16
Mark Mentovai
LGTM https://codereview.chromium.org/27265002/diff/549001/base/memory/shared_memory_posix.cc File base/memory/shared_memory_posix.cc (right): https://codereview.chromium.org/27265002/diff/549001/base/memory/shared_memory_posix.cc#newcode157 base/memory/shared_memory_posix.cc:157: // closed, Reflow this comment, this word doesn’t ...
7 years, 1 month ago (2013-11-20 14:21:41 UTC) #17
Jeffrey Yasskin
https://codereview.chromium.org/27265002/diff/549001/base/memory/shared_memory_posix.cc File base/memory/shared_memory_posix.cc (right): https://codereview.chromium.org/27265002/diff/549001/base/memory/shared_memory_posix.cc#newcode157 base/memory/shared_memory_posix.cc:157: // closed, On 2013/11/20 14:21:41, Mark Mentovai wrote: > ...
7 years, 1 month ago (2013-11-20 18:02:09 UTC) #18
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jyasskin@chromium.org/27265002/839001
7 years, 1 month ago (2013-11-20 18:02:41 UTC) #19
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jyasskin@chromium.org/27265002/839001
7 years, 1 month ago (2013-11-20 22:00:18 UTC) #20
commit-bot: I haz the power
7 years, 1 month ago (2013-11-20 23:41:27 UTC) #21
Message was sent while issue was closed.
Change committed as 236347

Powered by Google App Engine
This is Rietveld 408576698