| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2013 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include "native_client/src/trusted/service_runtime/sys_memory.h" | 7 #include "native_client/src/trusted/service_runtime/sys_memory.h" |
| 8 | 8 |
| 9 #include <errno.h> | 9 #include <errno.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 /* | 396 /* |
| 397 * Preemptively refuse to map anything that's not a regular file or | 397 * Preemptively refuse to map anything that's not a regular file or |
| 398 * shared memory segment. Other types usually report st_size of zero, | 398 * shared memory segment. Other types usually report st_size of zero, |
| 399 * which the code below will handle by just doing a dummy PROT_NONE | 399 * which the code below will handle by just doing a dummy PROT_NONE |
| 400 * mapping for the requested size and never attempting the underlying | 400 * mapping for the requested size and never attempting the underlying |
| 401 * NaClDesc Map operation. So without this check, the host OS never | 401 * NaClDesc Map operation. So without this check, the host OS never |
| 402 * gets the chance to refuse the mapping operation on an object that | 402 * gets the chance to refuse the mapping operation on an object that |
| 403 * can't do it. | 403 * can't do it. |
| 404 */ | 404 */ |
| 405 if (!NACL_ABI_S_ISREG(stbuf.nacl_abi_st_mode) && | 405 if (!NACL_ABI_S_ISREG(stbuf.nacl_abi_st_mode) && |
| 406 !NACL_ABI_S_ISSHM(stbuf.nacl_abi_st_mode) && | 406 !NACL_ABI_S_ISSHM(stbuf.nacl_abi_st_mode)) { |
| 407 !NACL_ABI_S_ISSHM_SYSV(stbuf.nacl_abi_st_mode)) { | |
| 408 map_result = -NACL_ABI_ENODEV; | 407 map_result = -NACL_ABI_ENODEV; |
| 409 goto cleanup; | 408 goto cleanup; |
| 410 } | 409 } |
| 411 | 410 |
| 412 /* | 411 /* |
| 413 * BUG(bsy): there's a race between this fstat and the actual mmap | 412 * BUG(bsy): there's a race between this fstat and the actual mmap |
| 414 * below. It's probably insoluble. Even if we fstat again after | 413 * below. It's probably insoluble. Even if we fstat again after |
| 415 * mmap and compared, the mmap could have "seen" the file with a | 414 * mmap and compared, the mmap could have "seen" the file with a |
| 416 * different size, after which the racing thread restored back to | 415 * different size, after which the racing thread restored back to |
| 417 * the same value before the 2nd fstat takes place. | 416 * the same value before the 2nd fstat takes place. |
| (...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 size_t length, | 1369 size_t length, |
| 1371 int prot) { | 1370 int prot) { |
| 1372 struct NaClApp *nap = natp->nap; | 1371 struct NaClApp *nap = natp->nap; |
| 1373 | 1372 |
| 1374 NaClLog(3, "Entered NaClSysMprotect(0x%08"NACL_PRIxPTR", " | 1373 NaClLog(3, "Entered NaClSysMprotect(0x%08"NACL_PRIxPTR", " |
| 1375 "0x%08"NACL_PRIxPTR", 0x%"NACL_PRIxS", 0x%x)\n", | 1374 "0x%08"NACL_PRIxPTR", 0x%"NACL_PRIxS", 0x%x)\n", |
| 1376 (uintptr_t) natp, (uintptr_t) start, length, prot); | 1375 (uintptr_t) natp, (uintptr_t) start, length, prot); |
| 1377 | 1376 |
| 1378 return NaClSysMprotectInternal(nap, start, length, prot); | 1377 return NaClSysMprotectInternal(nap, start, length, prot); |
| 1379 } | 1378 } |
| OLD | NEW |