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

Unified Diff: chrome/browser/nacl_host/nacl_process_host.cc

Issue 8574065: Use nacl::CreateMemoryObject to create dynamic code shared memory object (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/nacl_host/nacl_process_host.cc
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc
index a119ec37bf24276cf5497883d5f1c251526a9c25..ebcd99e2973c9ddc3bc797629a2a7a2bab28ffab 100644
--- a/chrome/browser/nacl_host/nacl_process_host.cc
+++ b/chrome/browser/nacl_host/nacl_process_host.cc
@@ -501,22 +501,18 @@ void NaClProcessHost::SendStart(base::PlatformFile irt_file) {
#if defined(OS_POSIX)
// For dynamic loading support, NaCl requires a file descriptor on an
// anonymous file that can have PROT_EXEC applied to its mappings.
- // Rather than requiring an extra IPC round trip out of the sandbox,
- // we create an FD here.
- base::SharedMemory memory_buffer;
- if (!memory_buffer.CreateAnonymous(/* size= */ 1)) {
+ // Rather than requiring an extra IPC round trip out of the sandbox, we
+ // create an FD here. Note we're using nacl::CreateMemoryObject rather
+ // than base::SharedMemory here, because the former has code to handle
+ // the Linux cases where shm_open yields objects that do not support
+ // PROT_EXEC mappings.
+ nacl::Handle fd = nacl::CreateMemoryObject(1, true); // size, executable
+ if (fd == nacl::kInvalidHandle) {
LOG(ERROR) << "Failed to allocate memory buffer";
delete this;
return;
}
- nacl::FileDescriptor memory_fd;
- memory_fd.fd = dup(memory_buffer.handle().fd);
- if (memory_fd.fd < 0) {
- LOG(ERROR) << "Failed to dup() a file descriptor";
- delete this;
- return;
- }
- memory_fd.auto_close = true;
+ nacl::FileDescriptor memory_fd(fd, true);
handles_for_sel_ldr.push_back(memory_fd);
#endif
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698