| 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 int Sandbox::sandbox_munmap(void* start, size_t length) { | 6 int Sandbox::sandbox_munmap(void* start, size_t length) { |
| 7 Debug::syscall(__NR_munmap, "Executing handler"); | 7 Debug::syscall(__NR_munmap, "Executing handler"); |
| 8 struct { | 8 struct { |
| 9 int sysnum; | 9 int sysnum; |
| 10 long long cookie; | 10 long long cookie; |
| 11 MUnmap munmap_req; | 11 MUnmap munmap_req; |
| 12 } __attribute__((packed)) request; | 12 } __attribute__((packed)) request; |
| 13 request.sysnum = __NR_munmap; | 13 request.sysnum = __NR_munmap; |
| 14 request.cookie = cookie(); | 14 request.cookie = cookie(); |
| 15 request.munmap_req.start = start; | 15 request.munmap_req.start = start; |
| 16 request.munmap_req.length = length; | 16 request.munmap_req.length = length; |
| 17 | 17 |
| 18 long rc; | 18 long rc; |
| 19 SysCalls sys; | 19 SysCalls sys; |
| 20 if (write(sys, processFdPub(), &request, sizeof(request)) != | 20 if (write(sys, processFdPub(), &request, sizeof(request)) != |
| 21 sizeof(request) || | 21 sizeof(request) || |
| 22 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) { | 22 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) { |
| 23 die("Failed to forward munmap() request [sandbox]"); | 23 die("Failed to forward munmap() request [sandbox]"); |
| 24 } | 24 } |
| 25 return static_cast<int>(rc); | 25 return static_cast<int>(rc); |
| 26 } | 26 } |
| 27 | 27 |
| 28 bool Sandbox::process_munmap(int parentProc, int sandboxFd, int threadFdPub, | 28 bool Sandbox::process_munmap(int parentMapsFd, int sandboxFd, int threadFdPub, |
| 29 int threadFd, SecureMem::Args* mem) { | 29 int threadFd, SecureMem::Args* mem) { |
| 30 // Read request | 30 // Read request |
| 31 SysCalls sys; | 31 SysCalls sys; |
| 32 MUnmap munmap_req; | 32 MUnmap munmap_req; |
| 33 if (read(sys, sandboxFd, &munmap_req, sizeof(munmap_req)) != | 33 if (read(sys, sandboxFd, &munmap_req, sizeof(munmap_req)) != |
| 34 sizeof(munmap_req)) { | 34 sizeof(munmap_req)) { |
| 35 die("Failed to read parameters for munmap() [process]"); | 35 die("Failed to read parameters for munmap() [process]"); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // Cannot unmap any memory region that was part of the original memory | 38 // Cannot unmap any memory region that was part of the original memory |
| (...skipping 16 matching lines...) Expand all Loading... |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Unmapping memory regions that were newly mapped inside of the sandbox | 57 // Unmapping memory regions that were newly mapped inside of the sandbox |
| 58 // is OK. | 58 // is OK. |
| 59 SecureMem::sendSystemCall(threadFdPub, false, -1, mem, __NR_munmap, | 59 SecureMem::sendSystemCall(threadFdPub, false, -1, mem, __NR_munmap, |
| 60 munmap_req.start, munmap_req.length); | 60 munmap_req.start, munmap_req.length); |
| 61 return true; | 61 return true; |
| 62 } | 62 } |
| 63 | 63 |
| 64 } // namespace | 64 } // namespace |
| OLD | NEW |