| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 1 #include "debug.h" | 5 #include "debug.h" |
| 2 #include "sandbox_impl.h" | 6 #include "sandbox_impl.h" |
| 3 | 7 |
| 4 namespace playground { | 8 namespace playground { |
| 5 | 9 |
| 6 void* Sandbox::sandbox_mmap(void *start, size_t length, int prot, int flags, | 10 void* Sandbox::sandbox_mmap(void *start, size_t length, int prot, int flags, |
| 7 int fd, off_t offset) { | 11 int fd, off_t offset) { |
| 8 Debug::syscall(__NR_mmap, "Executing handler"); | 12 long long tm; |
| 13 Debug::syscall(&tm, __NR_mmap, "Executing handler"); |
| 9 struct { | 14 struct { |
| 10 int sysnum; | 15 int sysnum; |
| 11 long long cookie; | 16 long long cookie; |
| 12 MMap mmap_req; | 17 MMap mmap_req; |
| 13 } __attribute__((packed)) request; | 18 } __attribute__((packed)) request; |
| 14 request.sysnum = __NR_MMAP; | 19 request.sysnum = __NR_MMAP; |
| 15 request.cookie = cookie(); | 20 request.cookie = cookie(); |
| 16 request.mmap_req.start = start; | 21 request.mmap_req.start = start; |
| 17 request.mmap_req.length = length; | 22 request.mmap_req.length = length; |
| 18 request.mmap_req.prot = prot; | 23 request.mmap_req.prot = prot; |
| 19 request.mmap_req.flags = flags; | 24 request.mmap_req.flags = flags; |
| 20 request.mmap_req.fd = fd; | 25 request.mmap_req.fd = fd; |
| 21 request.mmap_req.offset = offset; | 26 request.mmap_req.offset = offset; |
| 22 | 27 |
| 23 void* rc; | 28 void* rc; |
| 24 SysCalls sys; | 29 SysCalls sys; |
| 25 if (write(sys, processFdPub(), &request, sizeof(request)) != | 30 if (write(sys, processFdPub(), &request, sizeof(request)) != |
| 26 sizeof(request) || | 31 sizeof(request) || |
| 27 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) { | 32 read(sys, threadFdPub(), &rc, sizeof(rc)) != sizeof(rc)) { |
| 28 die("Failed to forward mmap() request [sandbox]"); | 33 die("Failed to forward mmap() request [sandbox]"); |
| 29 } | 34 } |
| 35 Debug::elapsed(tm, __NR_mmap); |
| 30 return rc; | 36 return rc; |
| 31 } | 37 } |
| 32 | 38 |
| 33 bool Sandbox::process_mmap(int parentMapsFd, int sandboxFd, int threadFdPub, | 39 bool Sandbox::process_mmap(int parentMapsFd, int sandboxFd, int threadFdPub, |
| 34 int threadFd, SecureMem::Args* mem) { | 40 int threadFd, SecureMem::Args* mem) { |
| 35 // Read request | 41 // Read request |
| 36 SysCalls sys; | 42 SysCalls sys; |
| 37 MMap mmap_req; | 43 MMap mmap_req; |
| 38 if (read(sys, sandboxFd, &mmap_req, sizeof(mmap_req)) != sizeof(mmap_req)) { | 44 if (read(sys, sandboxFd, &mmap_req, sizeof(mmap_req)) != sizeof(mmap_req)) { |
| 39 die("Failed to read parameters for mmap() [process]"); | 45 die("Failed to read parameters for mmap() [process]"); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 60 } | 66 } |
| 61 | 67 |
| 62 // All other mmap() requests are OK | 68 // All other mmap() requests are OK |
| 63 SecureMem::sendSystemCall(threadFdPub, false, -1, mem, __NR_MMAP, | 69 SecureMem::sendSystemCall(threadFdPub, false, -1, mem, __NR_MMAP, |
| 64 mmap_req.start, mmap_req.length, mmap_req.prot, | 70 mmap_req.start, mmap_req.length, mmap_req.prot, |
| 65 mmap_req.flags, mmap_req.fd, mmap_req.offset); | 71 mmap_req.flags, mmap_req.fd, mmap_req.offset); |
| 66 return true; | 72 return true; |
| 67 } | 73 } |
| 68 | 74 |
| 69 } // namespace | 75 } // namespace |
| OLD | NEW |