Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1595)

Side by Side Diff: src/trusted/service_runtime/nacl_syscall_common.c

Issue 1211173002: add restricted filesystem access to sel_ldr Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 #include <sys/stat.h> 11 #include <sys/stat.h>
12 12
13 #include <errno.h> 13 #include <errno.h>
14 #include <stdio.h> 14 #include <stdio.h>
15 #include <string.h>
15 16
16 #include "native_client/src/include/build_config.h" 17 #include "native_client/src/include/build_config.h"
17 18
18 #if NACL_WINDOWS 19 #if NACL_WINDOWS
19 #include <windows.h> 20 #include <windows.h>
20 #endif 21 #endif
21 22
22 #include "native_client/src/trusted/service_runtime/nacl_syscall_common.h" 23 #include "native_client/src/trusted/service_runtime/nacl_syscall_common.h"
23 24
24 #include "native_client/src/include/nacl_macros.h" 25 #include "native_client/src/include/nacl_macros.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 return 0; 85 return 0;
85 } 86 }
86 87
87 int NaClAclBypassChecks = 0; 88 int NaClAclBypassChecks = 0;
88 89
89 void NaClInsecurelyBypassAllAclChecks(void) { 90 void NaClInsecurelyBypassAllAclChecks(void) {
90 NaClLog(LOG_WARNING, "BYPASSING ALL ACL CHECKS\n"); 91 NaClLog(LOG_WARNING, "BYPASSING ALL ACL CHECKS\n");
91 NaClAclBypassChecks = 1; 92 NaClAclBypassChecks = 1;
92 } 93 }
93 94
95 char *NaClRootFolder = NULL;
96 size_t NaClRootFolderLen = 0;
97
98 void NaClMountRootFolder(char *root) {
99 /*
100 * TODO(jtolds): sanitize root, make sure it's well-formed, and does not
101 * end with a trailing slash.
jtolds 2015/06/25 23:05:05 hmm, i guess we'll need to use a path separator. n
Mark Seaborn 2015/06/25 23:55:08 I also don't know what the exact rules would need
102 */
103 NaClRootFolder = strdup(root);
104 NaClRootFolderLen = strlen(NaClRootFolder);
105 }
106
107 int NaClFileAccessEnabled(void) {
108 return NaClAclBypassChecks || (NaClRootFolder != NULL);
109 }
110
94 int NaClHighResolutionTimerEnabled(void) { 111 int NaClHighResolutionTimerEnabled(void) {
95 return NaClAclBypassChecks; 112 return NaClAclBypassChecks;
96 } 113 }
97 114
98 int32_t NaClSysGetpid(struct NaClAppThread *natp) { 115 int32_t NaClSysGetpid(struct NaClAppThread *natp) {
99 int32_t pid; 116 int32_t pid;
100 UNREFERENCED_PARAMETER(natp); 117 UNREFERENCED_PARAMETER(natp);
101 118
102 if (NaClAclBypassChecks) { 119 if (NaClAclBypassChecks) {
103 pid = GETPID(); 120 pid = GETPID();
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 #else 715 #else
699 #error Unsupported platform 716 #error Unsupported platform
700 #endif 717 #endif
701 break; 718 break;
702 } 719 }
703 case NACL_ABI__SC_PAGESIZE: { 720 case NACL_ABI__SC_PAGESIZE: {
704 result_value = 1 << 16; /* always 64k pages */ 721 result_value = 1 << 16; /* always 64k pages */
705 break; 722 break;
706 } 723 }
707 case NACL_ABI__SC_NACL_FILE_ACCESS_ENABLED: { 724 case NACL_ABI__SC_NACL_FILE_ACCESS_ENABLED: {
708 result_value = NaClAclBypassChecks; 725 result_value = NaClFileAccessEnabled();
709 break; 726 break;
710 } 727 }
711 case NACL_ABI__SC_NACL_LIST_MAPPINGS_ENABLED: { 728 case NACL_ABI__SC_NACL_LIST_MAPPINGS_ENABLED: {
712 result_value = nap->enable_list_mappings; 729 result_value = nap->enable_list_mappings;
713 break; 730 break;
714 } 731 }
715 case NACL_ABI__SC_NACL_PNACL_MODE: { 732 case NACL_ABI__SC_NACL_PNACL_MODE: {
716 result_value = nap->pnacl_mode; 733 result_value = nap->pnacl_mode;
717 break; 734 break;
718 } 735 }
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1007 return NaClSysClockGetCommon(natp, clk_id, (uintptr_t) tsp, 1024 return NaClSysClockGetCommon(natp, clk_id, (uintptr_t) tsp,
1008 NaClClockGetRes, 1); 1025 NaClClockGetRes, 1);
1009 } 1026 }
1010 1027
1011 int32_t NaClSysClockGetTime(struct NaClAppThread *natp, 1028 int32_t NaClSysClockGetTime(struct NaClAppThread *natp,
1012 int clk_id, 1029 int clk_id,
1013 uint32_t tsp) { 1030 uint32_t tsp) {
1014 return NaClSysClockGetCommon(natp, clk_id, (uintptr_t) tsp, 1031 return NaClSysClockGetCommon(natp, clk_id, (uintptr_t) tsp,
1015 NaClClockGetTime, 0); 1032 NaClClockGetTime, 0);
1016 } 1033 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698