| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "debug.h" | 5 #include "debug.h" |
| 6 #include "sandbox_impl.h" | 6 #include "sandbox_impl.h" |
| 7 | 7 |
| 8 namespace playground { | 8 namespace playground { |
| 9 | 9 |
| 10 #ifndef IPC_PRIVATE | 10 #ifndef IPC_PRIVATE |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 if (!g_policy.unrestricted_sysv_mem && | 98 if (!g_policy.unrestricted_sysv_mem && |
| 99 (shmat_req.shmaddr || shmat_req.shmflg || | 99 (shmat_req.shmaddr || shmat_req.shmflg || |
| 100 shmat_req.shmid != info->mem->shmId)) { | 100 shmat_req.shmid != info->mem->shmId)) { |
| 101 info->mem->shmId = -1; | 101 info->mem->shmId = -1; |
| 102 SecureMem::abandonSystemCall(*info, -EINVAL); | 102 SecureMem::abandonSystemCall(*info, -EINVAL); |
| 103 return false; | 103 return false; |
| 104 } | 104 } |
| 105 | 105 |
| 106 info->mem->shmId = -1; | 106 info->mem->shmId = -1; |
| 107 SecureMem::sendSystemCall(*info, SecureMem::SEND_UNLOCKED, shmat_req.shmid, | 107 SecureMem::sendSystemCall(*info, SecureMem::SEND_UNLOCKED, shmat_req.shmid, |
| 108 shmat_req.shmaddr, shmat_req.shmflg); | 108 const_cast<void*>(shmat_req.shmaddr), |
| 109 shmat_req.shmflg); |
| 109 return true; | 110 return true; |
| 110 } | 111 } |
| 111 | 112 |
| 112 bool Sandbox::process_shmctl(const SecureMem::SyscallRequestInfo* info) { | 113 bool Sandbox::process_shmctl(const SecureMem::SyscallRequestInfo* info) { |
| 113 // Read request | 114 // Read request |
| 114 ShmCtl shmctl_req; | 115 ShmCtl shmctl_req; |
| 115 SysCalls sys; | 116 SysCalls sys; |
| 116 if (read(sys, info->trustedProcessFd, &shmctl_req, sizeof(shmctl_req)) != | 117 if (read(sys, info->trustedProcessFd, &shmctl_req, sizeof(shmctl_req)) != |
| 117 sizeof(shmctl_req)) { | 118 sizeof(shmctl_req)) { |
| 118 die("Failed to read parameters for shmctl() [process]"); | 119 die("Failed to read parameters for shmctl() [process]"); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 146 // of a kernel bug, we make sure that the address does not fall into any | 147 // of a kernel bug, we make sure that the address does not fall into any |
| 147 // of the reserved memory regions. | 148 // of the reserved memory regions. |
| 148 if (!g_policy.unrestricted_sysv_mem && | 149 if (!g_policy.unrestricted_sysv_mem && |
| 149 isRegionProtected((void *) shmdt_req.shmaddr, 0x1000)) { | 150 isRegionProtected((void *) shmdt_req.shmaddr, 0x1000)) { |
| 150 info->mem->shmId = -1; | 151 info->mem->shmId = -1; |
| 151 SecureMem::abandonSystemCall(*info, -EINVAL); | 152 SecureMem::abandonSystemCall(*info, -EINVAL); |
| 152 return false; | 153 return false; |
| 153 } | 154 } |
| 154 | 155 |
| 155 info->mem->shmId = -1; | 156 info->mem->shmId = -1; |
| 156 SecureMem::sendSystemCall(*info, SecureMem::SEND_UNLOCKED, shmdt_req.shmaddr); | 157 SecureMem::sendSystemCall(*info, SecureMem::SEND_UNLOCKED, |
| 158 const_cast<void*>(shmdt_req.shmaddr)); |
| 157 return true; | 159 return true; |
| 158 } | 160 } |
| 159 | 161 |
| 160 bool Sandbox::process_shmget(const SecureMem::SyscallRequestInfo* info) { | 162 bool Sandbox::process_shmget(const SecureMem::SyscallRequestInfo* info) { |
| 161 // Read request | 163 // Read request |
| 162 ShmGet shmget_req; | 164 ShmGet shmget_req; |
| 163 SysCalls sys; | 165 SysCalls sys; |
| 164 if (read(sys, info->trustedProcessFd, &shmget_req, sizeof(shmget_req)) != | 166 if (read(sys, info->trustedProcessFd, &shmget_req, sizeof(shmget_req)) != |
| 165 sizeof(shmget_req)) { | 167 sizeof(shmget_req)) { |
| 166 die("Failed to read parameters for shmget() [process]"); | 168 die("Failed to read parameters for shmget() [process]"); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 // other SysV IPC calls. | 267 // other SysV IPC calls. |
| 266 deny: | 268 deny: |
| 267 info->mem->shmId = -1; | 269 info->mem->shmId = -1; |
| 268 SecureMem::abandonSystemCall(*info, -EINVAL); | 270 SecureMem::abandonSystemCall(*info, -EINVAL); |
| 269 return false; | 271 return false; |
| 270 } | 272 } |
| 271 } | 273 } |
| 272 #endif | 274 #endif |
| 273 | 275 |
| 274 } // namespace | 276 } // namespace |
| OLD | NEW |