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

Side by Side Diff: sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc

Issue 260793003: [MIPS] Add seccomp bpf support (Closed) Base URL: https://git.chromium.org/git/chromium/src.git@master
Patch Set: Update per code review Created 6 years, 6 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 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h" 5 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "sandbox/linux/services/linux_syscalls.h" 8 #include "sandbox/linux/services/linux_syscalls.h"
9 9
10 namespace sandbox { 10 namespace sandbox {
(...skipping 11 matching lines...) Expand all
22 return true; 22 return true;
23 default: 23 default:
24 return false; 24 return false;
25 } 25 }
26 } 26 }
27 27
28 bool SyscallSets::IsAllowedGettime(int sysno) { 28 bool SyscallSets::IsAllowedGettime(int sysno) {
29 switch (sysno) { 29 switch (sysno) {
30 case __NR_clock_gettime: 30 case __NR_clock_gettime:
31 case __NR_gettimeofday: 31 case __NR_gettimeofday:
32 #if defined(__i386__) || defined(__x86_64__) 32 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
33 case __NR_time: 33 case __NR_time:
34 #endif 34 #endif
35 return true; 35 return true;
36 case __NR_adjtimex: // Privileged. 36 case __NR_adjtimex: // Privileged.
37 case __NR_clock_adjtime: // Privileged. 37 case __NR_clock_adjtime: // Privileged.
38 case __NR_clock_getres: // Could be allowed. 38 case __NR_clock_getres: // Could be allowed.
39 case __NR_clock_nanosleep: // Could be allowed. 39 case __NR_clock_nanosleep: // Could be allowed.
40 case __NR_clock_settime: // Privileged. 40 case __NR_clock_settime: // Privileged.
41 #if defined(__i386__) 41 #if defined(__i386__) || defined(__mips__)
42 case __NR_ftime: // Obsolete. 42 case __NR_ftime: // Obsolete.
43 #endif 43 #endif
44 case __NR_settimeofday: // Privileged. 44 case __NR_settimeofday: // Privileged.
45 #if defined(__i386__) 45 #if defined(__i386__) || defined(__mips__)
46 case __NR_stime: 46 case __NR_stime:
47 #endif 47 #endif
48 default: 48 default:
49 return false; 49 return false;
50 } 50 }
51 } 51 }
52 52
53 bool SyscallSets::IsCurrentDirectory(int sysno) { 53 bool SyscallSets::IsCurrentDirectory(int sysno) {
54 switch (sysno) { 54 switch (sysno) {
55 case __NR_getcwd: 55 case __NR_getcwd:
(...skipping 26 matching lines...) Expand all
82 #if defined(__i386__) || defined(__arm__) 82 #if defined(__i386__) || defined(__arm__)
83 case __NR_chown32: 83 case __NR_chown32:
84 #endif 84 #endif
85 case __NR_creat: 85 case __NR_creat:
86 case __NR_execve: 86 case __NR_execve:
87 case __NR_faccessat: // EPERM not a valid errno. 87 case __NR_faccessat: // EPERM not a valid errno.
88 case __NR_fchmodat: 88 case __NR_fchmodat:
89 case __NR_fchownat: // Should be called chownat ? 89 case __NR_fchownat: // Should be called chownat ?
90 #if defined(__x86_64__) 90 #if defined(__x86_64__)
91 case __NR_newfstatat: // fstatat(). EPERM not a valid errno. 91 case __NR_newfstatat: // fstatat(). EPERM not a valid errno.
92 #elif defined(__i386__) || defined(__arm__) 92 #elif defined(__i386__) || defined(__arm__) || defined(__mips__)
93 case __NR_fstatat64: 93 case __NR_fstatat64:
94 #endif 94 #endif
95 case __NR_futimesat: // Should be called utimesat ? 95 case __NR_futimesat: // Should be called utimesat ?
96 case __NR_lchown: 96 case __NR_lchown:
97 #if defined(__i386__) || defined(__arm__) 97 #if defined(__i386__) || defined(__arm__)
98 case __NR_lchown32: 98 case __NR_lchown32:
99 #endif 99 #endif
100 case __NR_link: 100 case __NR_link:
101 case __NR_linkat: 101 case __NR_linkat:
102 case __NR_lookup_dcookie: // ENOENT not a valid errno. 102 case __NR_lookup_dcookie: // ENOENT not a valid errno.
103 case __NR_lstat: // EPERM not a valid errno. 103 case __NR_lstat: // EPERM not a valid errno.
104 #if defined(__i386__) 104 #if defined(__i386__)
105 case __NR_oldlstat: 105 case __NR_oldlstat:
106 #endif 106 #endif
107 #if defined(__i386__) || defined(__arm__) 107 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
108 case __NR_lstat64: 108 case __NR_lstat64:
109 #endif 109 #endif
110 case __NR_mkdir: 110 case __NR_mkdir:
111 case __NR_mkdirat: 111 case __NR_mkdirat:
112 case __NR_mknod: 112 case __NR_mknod:
113 case __NR_mknodat: 113 case __NR_mknodat:
114 case __NR_open: 114 case __NR_open:
115 case __NR_openat: 115 case __NR_openat:
116 case __NR_readlink: // EPERM not a valid errno. 116 case __NR_readlink: // EPERM not a valid errno.
117 case __NR_readlinkat: 117 case __NR_readlinkat:
118 case __NR_rename: 118 case __NR_rename:
119 case __NR_renameat: 119 case __NR_renameat:
120 case __NR_rmdir: 120 case __NR_rmdir:
121 case __NR_stat: // EPERM not a valid errno. 121 case __NR_stat: // EPERM not a valid errno.
122 #if defined(__i386__) 122 #if defined(__i386__)
123 case __NR_oldstat: 123 case __NR_oldstat:
124 #endif 124 #endif
125 #if defined(__i386__) || defined(__arm__) 125 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
126 case __NR_stat64: 126 case __NR_stat64:
127 #endif 127 #endif
128 case __NR_statfs: // EPERM not a valid errno. 128 case __NR_statfs: // EPERM not a valid errno.
129 #if defined(__i386__) || defined(__arm__) 129 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
130 case __NR_statfs64: 130 case __NR_statfs64:
131 #endif 131 #endif
132 case __NR_symlink: 132 case __NR_symlink:
133 case __NR_symlinkat: 133 case __NR_symlinkat:
134 case __NR_truncate: 134 case __NR_truncate:
135 #if defined(__i386__) || defined(__arm__) 135 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
136 case __NR_truncate64: 136 case __NR_truncate64:
137 #endif 137 #endif
138 case __NR_unlink: 138 case __NR_unlink:
139 case __NR_unlinkat: 139 case __NR_unlinkat:
140 case __NR_uselib: // Neither EPERM, nor ENOENT are valid errno. 140 case __NR_uselib: // Neither EPERM, nor ENOENT are valid errno.
141 case __NR_ustat: // Same as above. Deprecated. 141 case __NR_ustat: // Same as above. Deprecated.
142 #if defined(__i386__) || defined(__x86_64__) 142 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
143 case __NR_utime: 143 case __NR_utime:
144 #endif 144 #endif
145 case __NR_utimensat: // New. 145 case __NR_utimensat: // New.
146 case __NR_utimes: 146 case __NR_utimes:
147 return true; 147 return true;
148 default: 148 default:
149 return false; 149 return false;
150 } 150 }
151 } 151 }
152 152
153 bool SyscallSets::IsAllowedFileSystemAccessViaFd(int sysno) { 153 bool SyscallSets::IsAllowedFileSystemAccessViaFd(int sysno) {
154 switch (sysno) { 154 switch (sysno) {
155 case __NR_fstat: 155 case __NR_fstat:
156 #if defined(__i386__) || defined(__arm__) 156 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
157 case __NR_fstat64: 157 case __NR_fstat64:
158 #endif 158 #endif
159 return true; 159 return true;
160 // TODO(jln): these should be denied gracefully as well (moved below). 160 // TODO(jln): these should be denied gracefully as well (moved below).
161 #if defined(__i386__) || defined(__x86_64__) 161 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
162 case __NR_fadvise64: // EPERM not a valid errno. 162 case __NR_fadvise64: // EPERM not a valid errno.
163 #endif 163 #endif
164 #if defined(__i386__) 164 #if defined(__i386__)
165 case __NR_fadvise64_64: 165 case __NR_fadvise64_64:
166 #endif 166 #endif
167 #if defined(__arm__) 167 #if defined(__arm__)
168 case __NR_arm_fadvise64_64: 168 case __NR_arm_fadvise64_64:
169 #endif 169 #endif
170 case __NR_fdatasync: // EPERM not a valid errno. 170 case __NR_fdatasync: // EPERM not a valid errno.
171 case __NR_flock: // EPERM not a valid errno. 171 case __NR_flock: // EPERM not a valid errno.
172 case __NR_fstatfs: // Give information about the whole filesystem. 172 case __NR_fstatfs: // Give information about the whole filesystem.
173 #if defined(__i386__) || defined(__arm__) 173 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
174 case __NR_fstatfs64: 174 case __NR_fstatfs64:
175 #endif 175 #endif
176 case __NR_fsync: // EPERM not a valid errno. 176 case __NR_fsync: // EPERM not a valid errno.
177 #if defined(__i386__) 177 #if defined(__i386__)
178 case __NR_oldfstat: 178 case __NR_oldfstat:
179 #endif 179 #endif
180 #if defined(__i386__) || defined(__x86_64__) 180 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
181 case __NR_sync_file_range: // EPERM not a valid errno. 181 case __NR_sync_file_range: // EPERM not a valid errno.
182 #elif defined(__arm__) 182 #elif defined(__arm__)
183 case __NR_arm_sync_file_range: // EPERM not a valid errno. 183 case __NR_arm_sync_file_range: // EPERM not a valid errno.
184 #endif 184 #endif
185 default: 185 default:
186 return false; 186 return false;
187 } 187 }
188 } 188 }
189 189
190 // EPERM is a good errno for any of these. 190 // EPERM is a good errno for any of these.
191 bool SyscallSets::IsDeniedFileSystemAccessViaFd(int sysno) { 191 bool SyscallSets::IsDeniedFileSystemAccessViaFd(int sysno) {
192 switch (sysno) { 192 switch (sysno) {
193 case __NR_fallocate: 193 case __NR_fallocate:
194 case __NR_fchmod: 194 case __NR_fchmod:
195 case __NR_fchown: 195 case __NR_fchown:
196 case __NR_ftruncate: 196 case __NR_ftruncate:
197 #if defined(__i386__) || defined(__arm__) 197 #if defined(__i386__) || defined(__arm__)
198 case __NR_fchown32: 198 case __NR_fchown32:
199 #endif
200 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
199 case __NR_ftruncate64: 201 case __NR_ftruncate64:
200 #endif 202 #endif
201 case __NR_getdents: // EPERM not a valid errno. 203 case __NR_getdents: // EPERM not a valid errno.
202 case __NR_getdents64: // EPERM not a valid errno. 204 case __NR_getdents64: // EPERM not a valid errno.
203 #if defined(__i386__) 205 #if defined(__i386__) || defined(__mips__)
204 case __NR_readdir: 206 case __NR_readdir:
205 #endif 207 #endif
206 return true; 208 return true;
207 default: 209 default:
208 return false; 210 return false;
209 } 211 }
210 } 212 }
211 213
212 bool SyscallSets::IsGetSimpleId(int sysno) { 214 bool SyscallSets::IsGetSimpleId(int sysno) {
213 switch (sysno) { 215 switch (sysno) {
(...skipping 20 matching lines...) Expand all
234 #endif 236 #endif
235 return true; 237 return true;
236 default: 238 default:
237 return false; 239 return false;
238 } 240 }
239 } 241 }
240 242
241 bool SyscallSets::IsProcessPrivilegeChange(int sysno) { 243 bool SyscallSets::IsProcessPrivilegeChange(int sysno) {
242 switch (sysno) { 244 switch (sysno) {
243 case __NR_capset: 245 case __NR_capset:
244 #if defined(__i386__) || defined(__x86_64__) 246 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
245 case __NR_ioperm: // Intel privilege. 247 case __NR_ioperm: // Intel privilege.
246 case __NR_iopl: // Intel privilege. 248 case __NR_iopl: // Intel privilege.
247 #endif 249 #endif
248 case __NR_setfsgid: 250 case __NR_setfsgid:
249 case __NR_setfsuid: 251 case __NR_setfsuid:
250 case __NR_setgid: 252 case __NR_setgid:
251 case __NR_setgroups: 253 case __NR_setgroups:
252 case __NR_setregid: 254 case __NR_setregid:
253 case __NR_setresgid: 255 case __NR_setresgid:
254 case __NR_setresuid: 256 case __NR_setresuid:
(...skipping 26 matching lines...) Expand all
281 default: 283 default:
282 return false; 284 return false;
283 } 285 }
284 } 286 }
285 287
286 bool SyscallSets::IsAllowedSignalHandling(int sysno) { 288 bool SyscallSets::IsAllowedSignalHandling(int sysno) {
287 switch (sysno) { 289 switch (sysno) {
288 case __NR_rt_sigaction: 290 case __NR_rt_sigaction:
289 case __NR_rt_sigprocmask: 291 case __NR_rt_sigprocmask:
290 case __NR_rt_sigreturn: 292 case __NR_rt_sigreturn:
291 #if defined(__i386__) || defined(__arm__) 293 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
292 case __NR_sigaction: 294 case __NR_sigaction:
293 case __NR_sigprocmask: 295 case __NR_sigprocmask:
294 case __NR_sigreturn: 296 case __NR_sigreturn:
295 #endif 297 #endif
296 return true; 298 return true;
297 case __NR_rt_sigpending: 299 case __NR_rt_sigpending:
298 case __NR_rt_sigqueueinfo: 300 case __NR_rt_sigqueueinfo:
299 case __NR_rt_sigsuspend: 301 case __NR_rt_sigsuspend:
300 case __NR_rt_sigtimedwait: 302 case __NR_rt_sigtimedwait:
301 case __NR_rt_tgsigqueueinfo: 303 case __NR_rt_tgsigqueueinfo:
302 case __NR_sigaltstack: 304 case __NR_sigaltstack:
303 case __NR_signalfd: 305 case __NR_signalfd:
304 case __NR_signalfd4: 306 case __NR_signalfd4:
305 #if defined(__i386__) || defined(__arm__) 307 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
306 case __NR_sigpending: 308 case __NR_sigpending:
307 case __NR_sigsuspend: 309 case __NR_sigsuspend:
308 #endif 310 #endif
309 #if defined(__i386__) 311 #if defined(__i386__) || defined(__mips__)
310 case __NR_signal: 312 case __NR_signal:
311 case __NR_sgetmask: // Obsolete. 313 case __NR_sgetmask: // Obsolete.
312 case __NR_ssetmask: 314 case __NR_ssetmask:
313 #endif 315 #endif
314 default: 316 default:
315 return false; 317 return false;
316 } 318 }
317 } 319 }
318 320
319 bool SyscallSets::IsAllowedOperationOnFd(int sysno) { 321 bool SyscallSets::IsAllowedOperationOnFd(int sysno) {
320 switch (sysno) { 322 switch (sysno) {
321 case __NR_close: 323 case __NR_close:
322 case __NR_dup: 324 case __NR_dup:
323 case __NR_dup2: 325 case __NR_dup2:
324 case __NR_dup3: 326 case __NR_dup3:
325 #if defined(__x86_64__) || defined(__arm__) 327 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__)
326 case __NR_shutdown: 328 case __NR_shutdown:
327 #endif 329 #endif
328 return true; 330 return true;
329 case __NR_fcntl: 331 case __NR_fcntl:
330 #if defined(__i386__) || defined(__arm__) 332 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
331 case __NR_fcntl64: 333 case __NR_fcntl64:
332 #endif 334 #endif
333 default: 335 default:
334 return false; 336 return false;
335 } 337 }
336 } 338 }
337 339
338 bool SyscallSets::IsKernelInternalApi(int sysno) { 340 bool SyscallSets::IsKernelInternalApi(int sysno) {
339 switch (sysno) { 341 switch (sysno) {
340 case __NR_restart_syscall: 342 case __NR_restart_syscall:
(...skipping 15 matching lines...) Expand all
356 case __NR_waitid: 358 case __NR_waitid:
357 #if defined(__i386__) 359 #if defined(__i386__)
358 case __NR_waitpid: 360 case __NR_waitpid:
359 #endif 361 #endif
360 return true; 362 return true;
361 case __NR_clone: // Should be parameter-restricted. 363 case __NR_clone: // Should be parameter-restricted.
362 case __NR_setns: // Privileged. 364 case __NR_setns: // Privileged.
363 case __NR_fork: 365 case __NR_fork:
364 #if defined(__i386__) || defined(__x86_64__) 366 #if defined(__i386__) || defined(__x86_64__)
365 case __NR_get_thread_area: 367 case __NR_get_thread_area:
368 #endif
369 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
366 case __NR_set_thread_area: 370 case __NR_set_thread_area:
367 #endif 371 #endif
368 case __NR_set_tid_address: 372 case __NR_set_tid_address:
369 case __NR_unshare: 373 case __NR_unshare:
374 #if !defined(__mips__)
370 case __NR_vfork: 375 case __NR_vfork:
376 #endif
371 default: 377 default:
372 return false; 378 return false;
373 } 379 }
374 } 380 }
375 381
376 // It's difficult to restrict those, but there is attack surface here. 382 // It's difficult to restrict those, but there is attack surface here.
377 bool SyscallSets::IsAllowedFutex(int sysno) { 383 bool SyscallSets::IsAllowedFutex(int sysno) {
378 switch (sysno) { 384 switch (sysno) {
379 case __NR_get_robust_list: 385 case __NR_get_robust_list:
380 case __NR_set_robust_list: 386 case __NR_set_robust_list:
(...skipping 22 matching lines...) Expand all
403 return false; 409 return false;
404 } 410 }
405 } 411 }
406 412
407 bool SyscallSets::IsAllowedGetOrModifySocket(int sysno) { 413 bool SyscallSets::IsAllowedGetOrModifySocket(int sysno) {
408 switch (sysno) { 414 switch (sysno) {
409 case __NR_pipe: 415 case __NR_pipe:
410 case __NR_pipe2: 416 case __NR_pipe2:
411 return true; 417 return true;
412 default: 418 default:
413 #if defined(__x86_64__) || defined(__arm__) 419 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__)
414 case __NR_socketpair: // We will want to inspect its argument. 420 case __NR_socketpair: // We will want to inspect its argument.
415 #endif 421 #endif
416 return false; 422 return false;
417 } 423 }
418 } 424 }
419 425
420 bool SyscallSets::IsDeniedGetOrModifySocket(int sysno) { 426 bool SyscallSets::IsDeniedGetOrModifySocket(int sysno) {
421 switch (sysno) { 427 switch (sysno) {
422 #if defined(__x86_64__) || defined(__arm__) 428 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__)
423 case __NR_accept: 429 case __NR_accept:
424 case __NR_accept4: 430 case __NR_accept4:
425 case __NR_bind: 431 case __NR_bind:
426 case __NR_connect: 432 case __NR_connect:
427 case __NR_socket: 433 case __NR_socket:
428 case __NR_listen: 434 case __NR_listen:
429 return true; 435 return true;
430 #endif 436 #endif
431 default: 437 default:
432 return false; 438 return false;
433 } 439 }
434 } 440 }
435 441
436 #if defined(__i386__) 442 #if defined(__i386__) || defined(__mips__)
437 // Big multiplexing system call for sockets. 443 // Big multiplexing system call for sockets.
438 bool SyscallSets::IsSocketCall(int sysno) { 444 bool SyscallSets::IsSocketCall(int sysno) {
439 switch (sysno) { 445 switch (sysno) {
440 case __NR_socketcall: 446 case __NR_socketcall:
441 return true; 447 return true;
442 default: 448 default:
443 return false; 449 return false;
444 } 450 }
445 } 451 }
446 #endif 452 #endif
447 453
448 #if defined(__x86_64__) || defined(__arm__) 454 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__)
449 bool SyscallSets::IsNetworkSocketInformation(int sysno) { 455 bool SyscallSets::IsNetworkSocketInformation(int sysno) {
450 switch (sysno) { 456 switch (sysno) {
451 case __NR_getpeername: 457 case __NR_getpeername:
452 case __NR_getsockname: 458 case __NR_getsockname:
453 case __NR_getsockopt: 459 case __NR_getsockopt:
454 case __NR_setsockopt: 460 case __NR_setsockopt:
455 return true; 461 return true;
456 default: 462 default:
457 return false; 463 return false;
458 } 464 }
459 } 465 }
460 #endif 466 #endif
461 467
462 bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) { 468 bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) {
463 switch (sysno) { 469 switch (sysno) {
464 case __NR_brk: 470 case __NR_brk:
465 case __NR_mlock: 471 case __NR_mlock:
466 case __NR_munlock: 472 case __NR_munlock:
467 case __NR_munmap: 473 case __NR_munmap:
468 return true; 474 return true;
469 case __NR_madvise: 475 case __NR_madvise:
470 case __NR_mincore: 476 case __NR_mincore:
471 case __NR_mlockall: 477 case __NR_mlockall:
472 #if defined(__i386__) || defined(__x86_64__) 478 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
473 case __NR_mmap: 479 case __NR_mmap:
474 #endif 480 #endif
475 #if defined(__i386__) || defined(__arm__) 481 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
476 case __NR_mmap2: 482 case __NR_mmap2:
477 #endif 483 #endif
478 #if defined(__i386__) || defined(__x86_64__) 484 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
479 case __NR_modify_ldt: 485 case __NR_modify_ldt:
480 #endif 486 #endif
481 case __NR_mprotect: 487 case __NR_mprotect:
482 case __NR_mremap: 488 case __NR_mremap:
483 case __NR_msync: 489 case __NR_msync:
484 case __NR_munlockall: 490 case __NR_munlockall:
485 case __NR_readahead: 491 case __NR_readahead:
486 case __NR_remap_file_pages: 492 case __NR_remap_file_pages:
493 #if defined(__i386__) || defined(__mips__)
494 case __NR_vm86:
495 #endif
487 #if defined(__i386__) 496 #if defined(__i386__)
488 case __NR_vm86:
489 case __NR_vm86old: 497 case __NR_vm86old:
490 #endif 498 #endif
491 default: 499 default:
492 return false; 500 return false;
493 } 501 }
494 } 502 }
495 503
496 bool SyscallSets::IsAllowedGeneralIo(int sysno) { 504 bool SyscallSets::IsAllowedGeneralIo(int sysno) {
497 switch (sysno) { 505 switch (sysno) {
498 case __NR_lseek: 506 case __NR_lseek:
499 #if defined(__i386__) || defined(__arm__) 507 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
500 case __NR__llseek: 508 case __NR__llseek:
501 #endif 509 #endif
502 case __NR_poll: 510 case __NR_poll:
503 case __NR_ppoll: 511 case __NR_ppoll:
504 case __NR_pselect6: 512 case __NR_pselect6:
505 case __NR_read: 513 case __NR_read:
506 case __NR_readv: 514 case __NR_readv:
507 #if defined(__arm__) 515 #if defined(__arm__) || defined(__mips__)
508 case __NR_recv: 516 case __NR_recv:
509 #endif 517 #endif
510 #if defined(__x86_64__) || defined(__arm__) 518 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__)
511 case __NR_recvfrom: // Could specify source. 519 case __NR_recvfrom: // Could specify source.
512 case __NR_recvmsg: // Could specify source. 520 case __NR_recvmsg: // Could specify source.
513 #endif 521 #endif
514 #if defined(__i386__) || defined(__x86_64__) 522 #if defined(__i386__) || defined(__x86_64__)
515 case __NR_select: 523 case __NR_select:
516 #endif 524 #endif
517 #if defined(__i386__) || defined(__arm__) 525 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
518 case __NR__newselect: 526 case __NR__newselect:
519 #endif 527 #endif
520 #if defined(__arm__) 528 #if defined(__arm__)
521 case __NR_send: 529 case __NR_send:
522 #endif 530 #endif
523 #if defined(__x86_64__) || defined(__arm__) 531 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__)
524 case __NR_sendmsg: // Could specify destination. 532 case __NR_sendmsg: // Could specify destination.
525 case __NR_sendto: // Could specify destination. 533 case __NR_sendto: // Could specify destination.
526 #endif 534 #endif
527 case __NR_write: 535 case __NR_write:
528 case __NR_writev: 536 case __NR_writev:
529 return true; 537 return true;
530 case __NR_ioctl: // Can be very powerful. 538 case __NR_ioctl: // Can be very powerful.
531 case __NR_pread64: 539 case __NR_pread64:
532 case __NR_preadv: 540 case __NR_preadv:
533 case __NR_pwrite64: 541 case __NR_pwrite64:
534 case __NR_pwritev: 542 case __NR_pwritev:
535 case __NR_recvmmsg: // Could specify source. 543 case __NR_recvmmsg: // Could specify source.
536 case __NR_sendfile: 544 case __NR_sendfile:
537 #if defined(__i386__) || defined(__arm__) 545 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
538 case __NR_sendfile64: 546 case __NR_sendfile64:
539 #endif 547 #endif
540 case __NR_sendmmsg: // Could specify destination. 548 case __NR_sendmmsg: // Could specify destination.
541 case __NR_splice: 549 case __NR_splice:
542 case __NR_tee: 550 case __NR_tee:
543 case __NR_vmsplice: 551 case __NR_vmsplice:
544 default: 552 default:
545 return false; 553 return false;
546 } 554 }
547 } 555 }
(...skipping 10 matching lines...) Expand all
558 } 566 }
559 } 567 }
560 568
561 bool SyscallSets::IsAllowedBasicScheduler(int sysno) { 569 bool SyscallSets::IsAllowedBasicScheduler(int sysno) {
562 switch (sysno) { 570 switch (sysno) {
563 case __NR_sched_yield: 571 case __NR_sched_yield:
564 case __NR_pause: 572 case __NR_pause:
565 case __NR_nanosleep: 573 case __NR_nanosleep:
566 return true; 574 return true;
567 case __NR_getpriority: 575 case __NR_getpriority:
568 #if defined(__i386__) || defined(__arm__) 576 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
569 case __NR_nice: 577 case __NR_nice:
570 #endif 578 #endif
571 case __NR_setpriority: 579 case __NR_setpriority:
572 default: 580 default:
573 return false; 581 return false;
574 } 582 }
575 } 583 }
576 584
577 bool SyscallSets::IsAdminOperation(int sysno) { 585 bool SyscallSets::IsAdminOperation(int sysno) {
578 switch (sysno) { 586 switch (sysno) {
579 #if defined(__i386__) || defined(__arm__) 587 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
580 case __NR_bdflush: 588 case __NR_bdflush:
581 #endif 589 #endif
582 case __NR_kexec_load: 590 case __NR_kexec_load:
583 case __NR_reboot: 591 case __NR_reboot:
584 case __NR_setdomainname: 592 case __NR_setdomainname:
585 case __NR_sethostname: 593 case __NR_sethostname:
586 case __NR_syslog: 594 case __NR_syslog:
587 return true; 595 return true;
588 default: 596 default:
589 return false; 597 return false;
590 } 598 }
591 } 599 }
592 600
593 bool SyscallSets::IsKernelModule(int sysno) { 601 bool SyscallSets::IsKernelModule(int sysno) {
594 switch (sysno) { 602 switch (sysno) {
595 #if defined(__i386__) || defined(__x86_64__) 603 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
596 case __NR_create_module: 604 case __NR_create_module:
597 case __NR_get_kernel_syms: // Should ENOSYS. 605 case __NR_get_kernel_syms: // Should ENOSYS.
598 case __NR_query_module: 606 case __NR_query_module:
599 #endif 607 #endif
600 case __NR_delete_module: 608 case __NR_delete_module:
601 case __NR_init_module: 609 case __NR_init_module:
602 return true; 610 return true;
603 default: 611 default:
604 return false; 612 return false;
605 } 613 }
(...skipping 10 matching lines...) Expand all
616 } 624 }
617 } 625 }
618 626
619 bool SyscallSets::IsFsControl(int sysno) { 627 bool SyscallSets::IsFsControl(int sysno) {
620 switch (sysno) { 628 switch (sysno) {
621 case __NR_mount: 629 case __NR_mount:
622 case __NR_nfsservctl: 630 case __NR_nfsservctl:
623 case __NR_quotactl: 631 case __NR_quotactl:
624 case __NR_swapoff: 632 case __NR_swapoff:
625 case __NR_swapon: 633 case __NR_swapon:
626 #if defined(__i386__) 634 #if defined(__i386__) || defined(__mips__)
627 case __NR_umount: 635 case __NR_umount:
628 #endif 636 #endif
629 case __NR_umount2: 637 case __NR_umount2:
630 return true; 638 return true;
631 default: 639 default:
632 return false; 640 return false;
633 } 641 }
634 } 642 }
635 643
636 bool SyscallSets::IsNuma(int sysno) { 644 bool SyscallSets::IsNuma(int sysno) {
637 switch (sysno) { 645 switch (sysno) {
638 case __NR_get_mempolicy: 646 case __NR_get_mempolicy:
639 case __NR_getcpu: 647 case __NR_getcpu:
640 case __NR_mbind: 648 case __NR_mbind:
641 #if defined(__i386__) || defined(__x86_64__) 649 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
642 case __NR_migrate_pages: 650 case __NR_migrate_pages:
643 #endif 651 #endif
644 case __NR_move_pages: 652 case __NR_move_pages:
645 case __NR_set_mempolicy: 653 case __NR_set_mempolicy:
646 return true; 654 return true;
647 default: 655 default:
648 return false; 656 return false;
649 } 657 }
650 } 658 }
651 659
652 bool SyscallSets::IsMessageQueue(int sysno) { 660 bool SyscallSets::IsMessageQueue(int sysno) {
653 switch (sysno) { 661 switch (sysno) {
654 case __NR_mq_getsetattr: 662 case __NR_mq_getsetattr:
655 case __NR_mq_notify: 663 case __NR_mq_notify:
656 case __NR_mq_open: 664 case __NR_mq_open:
657 case __NR_mq_timedreceive: 665 case __NR_mq_timedreceive:
658 case __NR_mq_timedsend: 666 case __NR_mq_timedsend:
659 case __NR_mq_unlink: 667 case __NR_mq_unlink:
660 return true; 668 return true;
661 default: 669 default:
662 return false; 670 return false;
663 } 671 }
664 } 672 }
665 673
666 bool SyscallSets::IsGlobalProcessEnvironment(int sysno) { 674 bool SyscallSets::IsGlobalProcessEnvironment(int sysno) {
667 switch (sysno) { 675 switch (sysno) {
668 case __NR_acct: // Privileged. 676 case __NR_acct: // Privileged.
669 #if defined(__i386__) || defined(__x86_64__) 677 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
670 case __NR_getrlimit: 678 case __NR_getrlimit:
671 #endif 679 #endif
672 #if defined(__i386__) || defined(__arm__) 680 #if defined(__i386__) || defined(__arm__)
673 case __NR_ugetrlimit: 681 case __NR_ugetrlimit:
674 #endif 682 #endif
675 #if defined(__i386__) 683 #if defined(__i386__) || defined(__mips__)
676 case __NR_ulimit: 684 case __NR_ulimit:
677 #endif 685 #endif
678 case __NR_getrusage: 686 case __NR_getrusage:
679 case __NR_personality: // Can change its personality as well. 687 case __NR_personality: // Can change its personality as well.
680 case __NR_prlimit64: // Like setrlimit / getrlimit. 688 case __NR_prlimit64: // Like setrlimit / getrlimit.
681 case __NR_setrlimit: 689 case __NR_setrlimit:
682 case __NR_times: 690 case __NR_times:
683 return true; 691 return true;
684 default: 692 default:
685 return false; 693 return false;
686 } 694 }
687 } 695 }
688 696
689 bool SyscallSets::IsDebug(int sysno) { 697 bool SyscallSets::IsDebug(int sysno) {
690 switch (sysno) { 698 switch (sysno) {
691 case __NR_ptrace: 699 case __NR_ptrace:
692 case __NR_process_vm_readv: 700 case __NR_process_vm_readv:
693 case __NR_process_vm_writev: 701 case __NR_process_vm_writev:
694 #if defined(__i386__) || defined(__x86_64__) 702 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
695 case __NR_kcmp: 703 case __NR_kcmp:
696 #endif 704 #endif
697 return true; 705 return true;
698 default: 706 default:
699 return false; 707 return false;
700 } 708 }
701 } 709 }
702 710
703 bool SyscallSets::IsGlobalSystemStatus(int sysno) { 711 bool SyscallSets::IsGlobalSystemStatus(int sysno) {
704 switch (sysno) { 712 switch (sysno) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 case __NR_msgget: 795 case __NR_msgget:
788 case __NR_msgrcv: 796 case __NR_msgrcv:
789 case __NR_msgsnd: 797 case __NR_msgsnd:
790 return true; 798 return true;
791 default: 799 default:
792 return false; 800 return false;
793 } 801 }
794 } 802 }
795 #endif 803 #endif
796 804
797 #if defined(__i386__) 805 #if defined(__i386__) || defined(__mips__)
798 // Big system V multiplexing system call. 806 // Big system V multiplexing system call.
799 bool SyscallSets::IsSystemVIpc(int sysno) { 807 bool SyscallSets::IsSystemVIpc(int sysno) {
800 switch (sysno) { 808 switch (sysno) {
801 case __NR_ipc: 809 case __NR_ipc:
802 return true; 810 return true;
803 default: 811 default:
804 return false; 812 return false;
805 } 813 }
806 } 814 }
807 #endif 815 #endif
808 816
809 bool SyscallSets::IsAnySystemV(int sysno) { 817 bool SyscallSets::IsAnySystemV(int sysno) {
810 #if defined(__x86_64__) || defined(__arm__) 818 #if defined(__x86_64__) || defined(__arm__)
811 return IsSystemVMessageQueue(sysno) || IsSystemVSemaphores(sysno) || 819 return IsSystemVMessageQueue(sysno) || IsSystemVSemaphores(sysno) ||
812 IsSystemVSharedMemory(sysno); 820 IsSystemVSharedMemory(sysno);
813 #elif defined(__i386__) 821 #elif defined(__i386__) || defined(__mips__)
814 return IsSystemVIpc(sysno); 822 return IsSystemVIpc(sysno);
815 #endif 823 #endif
816 } 824 }
817 825
818 bool SyscallSets::IsAdvancedScheduler(int sysno) { 826 bool SyscallSets::IsAdvancedScheduler(int sysno) {
819 switch (sysno) { 827 switch (sysno) {
820 case __NR_ioprio_get: // IO scheduler. 828 case __NR_ioprio_get: // IO scheduler.
821 case __NR_ioprio_set: 829 case __NR_ioprio_set:
822 case __NR_sched_get_priority_max: 830 case __NR_sched_get_priority_max:
823 case __NR_sched_get_priority_min: 831 case __NR_sched_get_priority_min:
(...skipping 28 matching lines...) Expand all
852 case __NR_fanotify_mark: 860 case __NR_fanotify_mark:
853 return true; 861 return true;
854 default: 862 default:
855 return false; 863 return false;
856 } 864 }
857 } 865 }
858 866
859 bool SyscallSets::IsTimer(int sysno) { 867 bool SyscallSets::IsTimer(int sysno) {
860 switch (sysno) { 868 switch (sysno) {
861 case __NR_getitimer: 869 case __NR_getitimer:
862 #if defined(__i386__) || defined(__x86_64__) 870 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
863 case __NR_alarm: 871 case __NR_alarm:
864 #endif 872 #endif
865 case __NR_setitimer: 873 case __NR_setitimer:
866 return true; 874 return true;
867 default: 875 default:
868 return false; 876 return false;
869 } 877 }
870 } 878 }
871 879
872 bool SyscallSets::IsAdvancedTimer(int sysno) { 880 bool SyscallSets::IsAdvancedTimer(int sysno) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 // Various system calls that need to be researched. 916 // Various system calls that need to be researched.
909 // TODO(jln): classify this better. 917 // TODO(jln): classify this better.
910 bool SyscallSets::IsMisc(int sysno) { 918 bool SyscallSets::IsMisc(int sysno) {
911 switch (sysno) { 919 switch (sysno) {
912 case __NR_name_to_handle_at: 920 case __NR_name_to_handle_at:
913 case __NR_open_by_handle_at: 921 case __NR_open_by_handle_at:
914 case __NR_perf_event_open: 922 case __NR_perf_event_open:
915 case __NR_syncfs: 923 case __NR_syncfs:
916 case __NR_vhangup: 924 case __NR_vhangup:
917 // The system calls below are not implemented. 925 // The system calls below are not implemented.
918 #if defined(__i386__) || defined(__x86_64__) 926 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
919 case __NR_afs_syscall: 927 case __NR_afs_syscall:
920 #endif 928 #endif
921 #if defined(__i386__) 929 #if defined(__i386__) || defined(__mips__)
922 case __NR_break: 930 case __NR_break:
923 #endif 931 #endif
924 #if defined(__i386__) || defined(__x86_64__) 932 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
925 case __NR_getpmsg: 933 case __NR_getpmsg:
926 #endif 934 #endif
927 #if defined(__i386__) 935 #if defined(__i386__) || defined(__mips__)
928 case __NR_gtty: 936 case __NR_gtty:
929 case __NR_idle: 937 case __NR_idle:
930 case __NR_lock: 938 case __NR_lock:
931 case __NR_mpx: 939 case __NR_mpx:
932 case __NR_prof: 940 case __NR_prof:
933 case __NR_profil: 941 case __NR_profil:
934 #endif 942 #endif
935 #if defined(__i386__) || defined(__x86_64__) 943 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
936 case __NR_putpmsg: 944 case __NR_putpmsg:
937 #endif 945 #endif
938 #if defined(__x86_64__) 946 #if defined(__x86_64__)
939 case __NR_security: 947 case __NR_security:
940 #endif 948 #endif
941 #if defined(__i386__) 949 #if defined(__i386__) || defined(__mips__)
942 case __NR_stty: 950 case __NR_stty:
943 #endif 951 #endif
944 #if defined(__x86_64__) 952 #if defined(__x86_64__)
945 case __NR_tuxcall: 953 case __NR_tuxcall:
946 #endif 954 #endif
947 case __NR_vserver: 955 case __NR_vserver:
948 return true; 956 return true;
949 default: 957 default:
950 return false; 958 return false;
951 } 959 }
(...skipping 18 matching lines...) Expand all
970 case __ARM_NR_set_tls: 978 case __ARM_NR_set_tls:
971 case __ARM_NR_usr26: 979 case __ARM_NR_usr26:
972 case __ARM_NR_usr32: 980 case __ARM_NR_usr32:
973 return true; 981 return true;
974 default: 982 default:
975 return false; 983 return false;
976 } 984 }
977 } 985 }
978 #endif // defined(__arm__) 986 #endif // defined(__arm__)
979 987
988 #if defined(__mips__)
989 bool SyscallSets::IsMipsPrivate(int sysno) {
990 switch (sysno) {
991 case __NR_cacheflush:
992 case __NR_cachectl:
993 return true;
994 default:
995 return false;
996 }
997 }
998
999 bool SyscallSets::IsMipsMisc(int sysno) {
1000 switch (sysno) {
1001 case __NR_sysmips:
1002 case __NR_unused150:
1003 return true;
1004 default:
1005 return false;
1006 }
1007 }
1008 #endif // defined(__mips__)
980 } // namespace sandbox. 1009 } // namespace sandbox.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698