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

Side by Side Diff: sandbox/linux/seccomp/open.cc

Issue 371047: Allow the seccomp sandbox to be enabled, even if the suid sandbox has... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sandbox/linux/seccomp/munmap.cc ('k') | sandbox/linux/seccomp/sandbox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
1 #include "debug.h" 1 #include "debug.h"
2 #include "sandbox_impl.h" 2 #include "sandbox_impl.h"
3 3
4 namespace playground { 4 namespace playground {
5 5
6 int Sandbox::sandbox_open(const char *pathname, int flags, mode_t mode) { 6 int Sandbox::sandbox_open(const char *pathname, int flags, mode_t mode) {
7 Debug::syscall(__NR_open, "Executing handler"); 7 Debug::syscall(__NR_open, "Executing handler");
8 size_t len = strlen(pathname); 8 size_t len = strlen(pathname);
9 struct Request { 9 struct Request {
10 int sysnum; 10 int sysnum;
(...skipping 12 matching lines...) Expand all
23 23
24 long rc; 24 long rc;
25 SysCalls sys; 25 SysCalls sys;
26 if (write(sys, processFdPub(), request, sizeof(data)) != (int)sizeof(data) || 26 if (write(sys, processFdPub(), request, sizeof(data)) != (int)sizeof(data) ||
27 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) { 27 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) {
28 die("Failed to forward open() request [sandbox]"); 28 die("Failed to forward open() request [sandbox]");
29 } 29 }
30 return static_cast<int>(rc); 30 return static_cast<int>(rc);
31 } 31 }
32 32
33 bool Sandbox::process_open(int parentProc, int sandboxFd, int threadFdPub, 33 bool Sandbox::process_open(int parentMapsFd, int sandboxFd, int threadFdPub,
34 int threadFd, SecureMem::Args* mem) { 34 int threadFd, SecureMem::Args* mem) {
35 // Read request 35 // Read request
36 SysCalls sys; 36 SysCalls sys;
37 Open open_req; 37 Open open_req;
38 if (read(sys, sandboxFd, &open_req, sizeof(open_req)) != sizeof(open_req)) { 38 if (read(sys, sandboxFd, &open_req, sizeof(open_req)) != sizeof(open_req)) {
39 read_parm_failed: 39 read_parm_failed:
40 die("Failed to read parameters for open() [process]"); 40 die("Failed to read parameters for open() [process]");
41 } 41 }
42 int rc = -ENAMETOOLONG; 42 int rc = -ENAMETOOLONG;
43 if (open_req.path_length >= sizeof(mem->pathname)) { 43 if (open_req.path_length >= sizeof(mem->pathname)) {
(...skipping 19 matching lines...) Expand all
63 char tmp[open_req.path_length]; 63 char tmp[open_req.path_length];
64 if (read(sys, sandboxFd, tmp, open_req.path_length) != 64 if (read(sys, sandboxFd, tmp, open_req.path_length) !=
65 (ssize_t)open_req.path_length) { 65 (ssize_t)open_req.path_length) {
66 goto read_parm_failed; 66 goto read_parm_failed;
67 } 67 }
68 Debug::message(("Denying access to \"" + std::string(tmp) + "\"").c_str()); 68 Debug::message(("Denying access to \"" + std::string(tmp) + "\"").c_str());
69 SecureMem::abandonSystemCall(threadFd, -EACCES); 69 SecureMem::abandonSystemCall(threadFd, -EACCES);
70 return false; 70 return false;
71 } 71 }
72 72
73 SecureMem::lockSystemCall(parentProc, mem); 73 SecureMem::lockSystemCall(parentMapsFd, mem);
74 if (read(sys, sandboxFd, mem->pathname, open_req.path_length) != 74 if (read(sys, sandboxFd, mem->pathname, open_req.path_length) !=
75 (ssize_t)open_req.path_length) { 75 (ssize_t)open_req.path_length) {
76 goto read_parm_failed; 76 goto read_parm_failed;
77 } 77 }
78 mem->pathname[open_req.path_length] = '\000'; 78 mem->pathname[open_req.path_length] = '\000';
79 79
80 // TODO(markus): Implement sandboxing policy. For now, we allow read 80 // TODO(markus): Implement sandboxing policy. For now, we allow read
81 // access to everything. That's probably not correct. 81 // access to everything. That's probably not correct.
82 Debug::message(("Allowing access to \"" + std::string(mem->pathname) + 82 Debug::message(("Allowing access to \"" + std::string(mem->pathname) +
83 "\"").c_str()); 83 "\"").c_str());
84 84
85 // Tell trusted thread to open the file. 85 // Tell trusted thread to open the file.
86 SecureMem::sendSystemCall(threadFdPub, true, parentProc, mem, __NR_open, 86 SecureMem::sendSystemCall(threadFdPub, true, parentMapsFd, mem, __NR_open,
87 mem->pathname - (char*)mem + (char*)mem->self, 87 mem->pathname - (char*)mem + (char*)mem->self,
88 open_req.flags, open_req.mode); 88 open_req.flags, open_req.mode);
89 return true; 89 return true;
90 } 90 }
91 91
92 } // namespace 92 } // namespace
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp/munmap.cc ('k') | sandbox/linux/seccomp/sandbox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698