| 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 long Sandbox::sandbox_madvise(void* start, size_t length, int advice) { | 10 long Sandbox::sandbox_madvise(void* start, size_t length, int advice) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 sizeof(madvise_req)) { | 31 sizeof(madvise_req)) { |
| 32 die("Failed to read parameters for madvise() [process]"); | 32 die("Failed to read parameters for madvise() [process]"); |
| 33 } | 33 } |
| 34 switch (madvise_req.advice) { | 34 switch (madvise_req.advice) { |
| 35 case MADV_NORMAL: | 35 case MADV_NORMAL: |
| 36 case MADV_RANDOM: | 36 case MADV_RANDOM: |
| 37 case MADV_SEQUENTIAL: | 37 case MADV_SEQUENTIAL: |
| 38 case MADV_WILLNEED: | 38 case MADV_WILLNEED: |
| 39 ok: | 39 ok: |
| 40 SecureMem::sendSystemCall(*info, SecureMem::SEND_UNLOCKED, | 40 SecureMem::sendSystemCall(*info, SecureMem::SEND_UNLOCKED, |
| 41 madvise_req.start, madvise_req.len, | 41 const_cast<void*>(madvise_req.start), |
| 42 madvise_req.advice); | 42 madvise_req.len, madvise_req.advice); |
| 43 return true; | 43 return true; |
| 44 default: | 44 default: |
| 45 // All other flags to madvise() are potential dangerous (as opposed to | 45 // All other flags to madvise() are potential dangerous (as opposed to |
| 46 // merely affecting overall performance). Do not allow them on memory | 46 // merely affecting overall performance). Do not allow them on memory |
| 47 // ranges that were part of the original mappings. | 47 // ranges that were part of the original mappings. |
| 48 if (isRegionProtected((void *) madvise_req.start, madvise_req.len)) { | 48 if (isRegionProtected((void *) madvise_req.start, madvise_req.len)) { |
| 49 SecureMem::abandonSystemCall(*info, -EINVAL); | 49 SecureMem::abandonSystemCall(*info, -EINVAL); |
| 50 return false; | 50 return false; |
| 51 } | 51 } |
| 52 | 52 |
| 53 // Changing attributes on memory regions that were newly mapped inside of | 53 // Changing attributes on memory regions that were newly mapped inside of |
| 54 // the sandbox is OK. | 54 // the sandbox is OK. |
| 55 goto ok; | 55 goto ok; |
| 56 } | 56 } |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace | 59 } // namespace |
| OLD | NEW |