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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/mount_node.cc

Issue 14642024: [NaCl SDK] nacl_io: Fix dlopen'ing a file not in the .nmf (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 #include "nacl_io/mount_node.h" 5 #include "nacl_io/mount_node.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <string.h> 9 #include <string.h>
10 #include <sys/stat.h> 10 #include <sys/stat.h>
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return -1; 73 return -1;
74 } 74 }
75 75
76 int MountNode::Write(size_t offs, const void* buf, size_t count) { 76 int MountNode::Write(size_t offs, const void* buf, size_t count) {
77 errno = EINVAL; 77 errno = EINVAL;
78 return -1; 78 return -1;
79 } 79 }
80 80
81 void* MountNode::MMap(void* addr, size_t length, int prot, int flags, 81 void* MountNode::MMap(void* addr, size_t length, int prot, int flags,
82 size_t offset) { 82 size_t offset) {
83 // Never allow mmap'ing PROT_EXEC. The passthrough node supports this, but we
84 // don't. Fortunately, glibc will fallback if this fails, so dlopen will
85 // continue to work.
86 if (prot & PROT_EXEC) {
87 errno = EPERM;
88 return MAP_FAILED;
89 }
90
83 // This default mmap support is just enough to make dlopen work. 91 // This default mmap support is just enough to make dlopen work.
84 // This implementation just reads from the mount into the mmap'd memory area. 92 // This implementation just reads from the mount into the mmap'd memory area.
85 void* new_addr = addr; 93 void* new_addr = addr;
86 int err = _real_mmap(&new_addr, length, prot | PROT_WRITE, flags | 94 int err = _real_mmap(&new_addr, length, prot | PROT_WRITE, flags |
87 MAP_ANONYMOUS, -1, 0); 95 MAP_ANONYMOUS, -1, 0);
88 if (new_addr == MAP_FAILED) { 96 if (new_addr == MAP_FAILED) {
89 _real_munmap(new_addr, length); 97 _real_munmap(new_addr, length);
90 errno = err; 98 errno = err;
91 return MAP_FAILED; 99 return MAP_FAILED;
92 } 100 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 164
157 void MountNode::Link() { 165 void MountNode::Link() {
158 Acquire(); 166 Acquire();
159 stat_.st_nlink++; 167 stat_.st_nlink++;
160 } 168 }
161 169
162 void MountNode::Unlink() { 170 void MountNode::Unlink() {
163 stat_.st_nlink--; 171 stat_.st_nlink--;
164 Release(); 172 Release();
165 } 173 }
OLDNEW
« 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