| OLD | NEW |
| 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 void* Sandbox::sandbox_mmap(void *start, size_t length, int prot, int flags, | 6 void* Sandbox::sandbox_mmap(void *start, size_t length, int prot, int flags, |
| 7 int fd, off_t offset) { | 7 int fd, off_t offset) { |
| 8 Debug::syscall(__NR_mmap, "Executing handler"); | 8 Debug::syscall(__NR_mmap, "Executing handler"); |
| 9 struct { | 9 struct { |
| 10 int sysnum; | 10 int sysnum; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 void* rc; | 23 void* rc; |
| 24 SysCalls sys; | 24 SysCalls sys; |
| 25 if (write(sys, processFdPub(), &request, sizeof(request)) != | 25 if (write(sys, processFdPub(), &request, sizeof(request)) != |
| 26 sizeof(request) || | 26 sizeof(request) || |
| 27 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) { | 27 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) { |
| 28 die("Failed to forward mmap() request [sandbox]"); | 28 die("Failed to forward mmap() request [sandbox]"); |
| 29 } | 29 } |
| 30 return rc; | 30 return rc; |
| 31 } | 31 } |
| 32 | 32 |
| 33 bool Sandbox::process_mmap(int parentProc, int sandboxFd, int threadFdPub, | 33 bool Sandbox::process_mmap(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 MMap mmap_req; | 37 MMap mmap_req; |
| 38 if (read(sys, sandboxFd, &mmap_req, sizeof(mmap_req)) != sizeof(mmap_req)) { | 38 if (read(sys, sandboxFd, &mmap_req, sizeof(mmap_req)) != sizeof(mmap_req)) { |
| 39 die("Failed to read parameters for mmap() [process]"); | 39 die("Failed to read parameters for mmap() [process]"); |
| 40 } | 40 } |
| 41 | 41 |
| 42 if (mmap_req.flags & MAP_FIXED) { | 42 if (mmap_req.flags & MAP_FIXED) { |
| 43 // Cannot map a memory area that was part of the original memory mappings. | 43 // Cannot map a memory area that was part of the original memory mappings. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 60 } | 60 } |
| 61 | 61 |
| 62 // All other mmap() requests are OK | 62 // All other mmap() requests are OK |
| 63 SecureMem::sendSystemCall(threadFdPub, false, -1, mem, __NR_MMAP, | 63 SecureMem::sendSystemCall(threadFdPub, false, -1, mem, __NR_MMAP, |
| 64 mmap_req.start, mmap_req.length, mmap_req.prot, | 64 mmap_req.start, mmap_req.length, mmap_req.prot, |
| 65 mmap_req.flags, mmap_req.fd, mmap_req.offset); | 65 mmap_req.flags, mmap_req.fd, mmap_req.offset); |
| 66 return true; | 66 return true; |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace | 69 } // namespace |
| OLD | NEW |