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

Side by Side Diff: sandbox/linux/seccomp/madvise.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/ipc.cc ('k') | sandbox/linux/seccomp/maps.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_madvise(void* start, size_t length, int advice) { 6 int Sandbox::sandbox_madvise(void* start, size_t length, int advice) {
7 Debug::syscall(__NR_madvise, "Executing handler"); 7 Debug::syscall(__NR_madvise, "Executing handler");
8 struct { 8 struct {
9 int sysnum; 9 int sysnum;
10 long long cookie; 10 long long cookie;
11 MAdvise madvise_req; 11 MAdvise madvise_req;
12 } __attribute__((packed)) request; 12 } __attribute__((packed)) request;
13 request.sysnum = __NR_madvise; 13 request.sysnum = __NR_madvise;
14 request.cookie = cookie(); 14 request.cookie = cookie();
15 request.madvise_req.start = start; 15 request.madvise_req.start = start;
16 request.madvise_req.len = length; 16 request.madvise_req.len = length;
17 request.madvise_req.advice = advice; 17 request.madvise_req.advice = advice;
18 18
19 long rc; 19 long rc;
20 SysCalls sys; 20 SysCalls sys;
21 if (write(sys, processFdPub(), &request, sizeof(request)) != 21 if (write(sys, processFdPub(), &request, sizeof(request)) !=
22 sizeof(request) || 22 sizeof(request) ||
23 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) { 23 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) {
24 die("Failed to forward madvise() request [sandbox]"); 24 die("Failed to forward madvise() request [sandbox]");
25 } 25 }
26 return static_cast<int>(rc); 26 return static_cast<int>(rc);
27 } 27 }
28 28
29 bool Sandbox::process_madvise(int parentProc, int sandboxFd, int threadFdPub, 29 bool Sandbox::process_madvise(int parentMapsFd, int sandboxFd, int threadFdPub,
30 int threadFd, SecureMem::Args* mem) { 30 int threadFd, SecureMem::Args* mem) {
31 // Read request 31 // Read request
32 MAdvise madvise_req; 32 MAdvise madvise_req;
33 SysCalls sys; 33 SysCalls sys;
34 if (read(sys, sandboxFd, &madvise_req, sizeof(madvise_req)) != 34 if (read(sys, sandboxFd, &madvise_req, sizeof(madvise_req)) !=
35 sizeof(madvise_req)) { 35 sizeof(madvise_req)) {
36 die("Failed to read parameters for madvise() [process]"); 36 die("Failed to read parameters for madvise() [process]");
37 } 37 }
38 int rc = -EINVAL; 38 int rc = -EINVAL;
39 switch (madvise_req.advice) { 39 switch (madvise_req.advice) {
(...skipping 26 matching lines...) Expand all
66 } 66 }
67 } 67 }
68 68
69 // Changing attributes on memory regions that were newly mapped inside of 69 // Changing attributes on memory regions that were newly mapped inside of
70 // the sandbox is OK. 70 // the sandbox is OK.
71 goto ok; 71 goto ok;
72 } 72 }
73 } 73 }
74 74
75 } // namespace 75 } // namespace
OLDNEW
« no previous file with comments | « sandbox/linux/seccomp/ipc.cc ('k') | sandbox/linux/seccomp/maps.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698