OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 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 /* | 7 /* |
8 * NaCl service run-time, non-platform specific system call helper routines. | 8 * NaCl service run-time, non-platform specific system call helper routines. |
9 */ | 9 */ |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 NaClLog(LOG_FATAL, "Duplicate syscall number %d\n", num); | 101 NaClLog(LOG_FATAL, "Duplicate syscall number %d\n", num); |
102 } | 102 } |
103 nacl_syscall[num].handler = fn; | 103 nacl_syscall[num].handler = fn; |
104 } | 104 } |
105 | 105 |
106 int32_t NaClSysNull(struct NaClAppThread *natp) { | 106 int32_t NaClSysNull(struct NaClAppThread *natp) { |
107 UNREFERENCED_PARAMETER(natp); | 107 UNREFERENCED_PARAMETER(natp); |
108 return 0; | 108 return 0; |
109 } | 109 } |
110 | 110 |
111 int32_t NaClSetBreak(struct NaClAppThread *natp, | 111 int32_t NaClSysBrk(struct NaClAppThread *natp, |
112 uintptr_t new_break) { | 112 uintptr_t new_break) { |
113 struct NaClApp *nap = natp->nap; | 113 struct NaClApp *nap = natp->nap; |
114 uintptr_t break_addr; | 114 uintptr_t break_addr; |
115 int32_t rv = -NACL_ABI_EINVAL; | 115 int32_t rv = -NACL_ABI_EINVAL; |
116 struct NaClVmmapIter iter; | 116 struct NaClVmmapIter iter; |
117 struct NaClVmmapEntry *ent; | 117 struct NaClVmmapEntry *ent; |
118 struct NaClVmmapEntry *next_ent; | 118 struct NaClVmmapEntry *next_ent; |
119 uintptr_t sys_break; | 119 uintptr_t sys_break; |
120 uintptr_t sys_new_break; | 120 uintptr_t sys_new_break; |
121 uintptr_t usr_last_data_page; | 121 uintptr_t usr_last_data_page; |
122 uintptr_t usr_new_last_data_page; | 122 uintptr_t usr_new_last_data_page; |
123 uintptr_t last_internal_data_addr; | 123 uintptr_t last_internal_data_addr; |
124 uintptr_t last_internal_page; | 124 uintptr_t last_internal_page; |
125 uintptr_t start_new_region; | 125 uintptr_t start_new_region; |
126 uintptr_t region_size; | 126 uintptr_t region_size; |
127 | 127 |
128 break_addr = nap->break_addr; | 128 break_addr = nap->break_addr; |
129 | 129 |
130 NaClLog(3, "Entered NaClSetBreak(new_break 0x%08"NACL_PRIxPTR")\n", | 130 NaClLog(3, "Entered NaClSysBrk(new_break 0x%08"NACL_PRIxPTR")\n", |
131 new_break); | 131 new_break); |
132 | 132 |
133 sys_new_break = NaClUserToSysAddr(nap, new_break); | 133 sys_new_break = NaClUserToSysAddr(nap, new_break); |
134 NaClLog(3, "sys_new_break 0x%08"NACL_PRIxPTR"\n", sys_new_break); | 134 NaClLog(3, "sys_new_break 0x%08"NACL_PRIxPTR"\n", sys_new_break); |
135 | 135 |
136 if (kNaClBadAddress == sys_new_break) { | 136 if (kNaClBadAddress == sys_new_break) { |
137 goto cleanup_no_lock; | 137 goto cleanup_no_lock; |
138 } | 138 } |
139 if (NACL_SYNC_OK != NaClMutexLock(&nap->mu)) { | 139 if (NACL_SYNC_OK != NaClMutexLock(&nap->mu)) { |
140 NaClLog(LOG_ERROR, "Could not get app lock for 0x%08"NACL_PRIxPTR"\n", | 140 NaClLog(LOG_ERROR, "Could not get app lock for 0x%08"NACL_PRIxPTR"\n", |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 NaClXMutexUnlock(&nap->mu); | 247 NaClXMutexUnlock(&nap->mu); |
248 cleanup_no_lock: | 248 cleanup_no_lock: |
249 | 249 |
250 /* | 250 /* |
251 * This cast is safe because the incoming value (new_break) cannot | 251 * This cast is safe because the incoming value (new_break) cannot |
252 * exceed the user address space--even though its type (uintptr_t) | 252 * exceed the user address space--even though its type (uintptr_t) |
253 * theoretically allows larger values. | 253 * theoretically allows larger values. |
254 */ | 254 */ |
255 rv = (int32_t) break_addr; | 255 rv = (int32_t) break_addr; |
256 | 256 |
257 NaClLog(3, "NaClSetBreak: returning 0x%08"NACL_PRIx32"\n", rv); | 257 NaClLog(3, "NaClSysBrk: returning 0x%08"NACL_PRIx32"\n", rv); |
258 return rv; | 258 return rv; |
259 } | 259 } |
260 | 260 |
261 int NaClAclBypassChecks = 0; | 261 int NaClAclBypassChecks = 0; |
262 | 262 |
263 void NaClInsecurelyBypassAllAclChecks(void) { | 263 void NaClInsecurelyBypassAllAclChecks(void) { |
264 NaClLog(LOG_WARNING, "BYPASSING ALL ACL CHECKS\n"); | 264 NaClLog(LOG_WARNING, "BYPASSING ALL ACL CHECKS\n"); |
265 NaClAclBypassChecks = 1; | 265 NaClAclBypassChecks = 1; |
266 } | 266 } |
267 | 267 |
(...skipping 2942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3210 return NaClSysClockGetCommon(natp, clk_id, (uintptr_t) tsp, | 3210 return NaClSysClockGetCommon(natp, clk_id, (uintptr_t) tsp, |
3211 NaClClockGetRes); | 3211 NaClClockGetRes); |
3212 } | 3212 } |
3213 | 3213 |
3214 int32_t NaClSysClockGetTime(struct NaClAppThread *natp, | 3214 int32_t NaClSysClockGetTime(struct NaClAppThread *natp, |
3215 int clk_id, | 3215 int clk_id, |
3216 uint32_t tsp) { | 3216 uint32_t tsp) { |
3217 return NaClSysClockGetCommon(natp, clk_id, (uintptr_t) tsp, | 3217 return NaClSysClockGetCommon(natp, clk_id, (uintptr_t) tsp, |
3218 NaClClockGetTime); | 3218 NaClClockGetTime); |
3219 } | 3219 } |
OLD | NEW |