NaCl: Reinstate the "nacl_revision" field in DEPS
[chromium-blink-merge.git] / sandbox / linux / seccomp-bpf-helpers / syscall_sets.cc
blobc0a720a3b6fb0bf86d2c6c1fdf6e1b4c086530ba
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
3 // found in the LICENSE file.
5 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h"
7 #include "build/build_config.h"
8 #include "sandbox/linux/services/linux_syscalls.h"
10 namespace sandbox {
12 // The functions below cover all existing i386, x86_64, and ARM system calls;
13 // excluding syscalls made obsolete in ARM EABI.
14 // The implicitly defined sets form a partition of the sets of
15 // system calls.
17 bool SyscallSets::IsKill(int sysno) {
18 switch (sysno) {
19 case __NR_kill:
20 case __NR_tgkill:
21 case __NR_tkill: // Deprecated.
22 return true;
23 default:
24 return false;
28 bool SyscallSets::IsAllowedGettime(int sysno) {
29 switch (sysno) {
30 case __NR_clock_gettime:
31 case __NR_gettimeofday:
32 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
33 case __NR_time:
34 #endif
35 return true;
36 case __NR_adjtimex: // Privileged.
37 case __NR_clock_adjtime: // Privileged.
38 case __NR_clock_getres: // Could be allowed.
39 case __NR_clock_nanosleep: // Could be allowed.
40 case __NR_clock_settime: // Privileged.
41 #if defined(__i386__) || defined(__mips__)
42 case __NR_ftime: // Obsolete.
43 #endif
44 case __NR_settimeofday: // Privileged.
45 #if defined(__i386__) || defined(__mips__)
46 case __NR_stime:
47 #endif
48 default:
49 return false;
53 bool SyscallSets::IsCurrentDirectory(int sysno) {
54 switch (sysno) {
55 case __NR_getcwd:
56 case __NR_chdir:
57 case __NR_fchdir:
58 return true;
59 default:
60 return false;
64 bool SyscallSets::IsUmask(int sysno) {
65 switch (sysno) {
66 case __NR_umask:
67 return true;
68 default:
69 return false;
73 // System calls that directly access the file system. They might acquire
74 // a new file descriptor or otherwise perform an operation directly
75 // via a path.
76 // Both EPERM and ENOENT are valid errno unless otherwise noted in comment.
77 bool SyscallSets::IsFileSystem(int sysno) {
78 switch (sysno) {
79 #if !defined(__aarch64__)
80 case __NR_access: // EPERM not a valid errno.
81 case __NR_chmod:
82 case __NR_chown:
83 #if defined(__i386__) || defined(__arm__)
84 case __NR_chown32:
85 #endif
86 case __NR_creat:
87 case __NR_futimesat: // Should be called utimesat ?
88 case __NR_lchown:
89 case __NR_link:
90 case __NR_lstat: // EPERM not a valid errno.
91 case __NR_mkdir:
92 case __NR_mknod:
93 case __NR_open:
94 case __NR_readlink: // EPERM not a valid errno.
95 case __NR_rename:
96 case __NR_rmdir:
97 case __NR_stat: // EPERM not a valid errno.
98 case __NR_symlink:
99 case __NR_unlink:
100 case __NR_uselib: // Neither EPERM, nor ENOENT are valid errno.
101 case __NR_ustat: // Same as above. Deprecated.
102 case __NR_utimes:
103 #endif // !defined(__aarch64__)
105 case __NR_execve:
106 case __NR_faccessat: // EPERM not a valid errno.
107 case __NR_fchmodat:
108 case __NR_fchownat: // Should be called chownat ?
109 #if defined(__x86_64__) || defined(__aarch64__)
110 case __NR_newfstatat: // fstatat(). EPERM not a valid errno.
111 #elif defined(__i386__) || defined(__arm__) || defined(__mips__)
112 case __NR_fstatat64:
113 #endif
114 #if defined(__i386__) || defined(__arm__)
115 case __NR_lchown32:
116 #endif
117 case __NR_linkat:
118 case __NR_lookup_dcookie: // ENOENT not a valid errno.
120 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
121 case __NR_lstat64:
122 #endif
123 #if defined(__i386__) || defined(__arm__) || defined(__x86_64__)
124 case __NR_memfd_create:
125 #endif
126 case __NR_mkdirat:
127 case __NR_mknodat:
128 #if defined(__i386__)
129 case __NR_oldlstat:
130 case __NR_oldstat:
131 #endif
132 case __NR_openat:
133 case __NR_readlinkat:
134 case __NR_renameat:
135 case __NR_renameat2:
136 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
137 case __NR_stat64:
138 #endif
139 case __NR_statfs: // EPERM not a valid errno.
140 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
141 case __NR_statfs64:
142 #endif
143 case __NR_symlinkat:
144 case __NR_truncate:
145 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
146 case __NR_truncate64:
147 #endif
148 case __NR_unlinkat:
149 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
150 case __NR_utime:
151 #endif
152 case __NR_utimensat: // New.
153 return true;
154 default:
155 return false;
159 bool SyscallSets::IsAllowedFileSystemAccessViaFd(int sysno) {
160 switch (sysno) {
161 case __NR_fstat:
162 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
163 case __NR_fstat64:
164 #endif
165 return true;
166 // TODO(jln): these should be denied gracefully as well (moved below).
167 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
168 case __NR_fadvise64: // EPERM not a valid errno.
169 #endif
170 #if defined(__i386__)
171 case __NR_fadvise64_64:
172 #endif
173 #if defined(__arm__)
174 case __NR_arm_fadvise64_64:
175 #endif
176 case __NR_fdatasync: // EPERM not a valid errno.
177 case __NR_flock: // EPERM not a valid errno.
178 case __NR_fstatfs: // Give information about the whole filesystem.
179 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
180 case __NR_fstatfs64:
181 #endif
182 case __NR_fsync: // EPERM not a valid errno.
183 #if defined(__i386__)
184 case __NR_oldfstat:
185 #endif
186 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
187 defined(__aarch64__)
188 case __NR_sync_file_range: // EPERM not a valid errno.
189 #elif defined(__arm__)
190 case __NR_arm_sync_file_range: // EPERM not a valid errno.
191 #endif
192 default:
193 return false;
197 // EPERM is a good errno for any of these.
198 bool SyscallSets::IsDeniedFileSystemAccessViaFd(int sysno) {
199 switch (sysno) {
200 case __NR_fallocate:
201 case __NR_fchmod:
202 case __NR_fchown:
203 case __NR_ftruncate:
204 #if defined(__i386__) || defined(__arm__)
205 case __NR_fchown32:
206 #endif
207 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
208 case __NR_ftruncate64:
209 #endif
210 #if !defined(__aarch64__)
211 case __NR_getdents: // EPERM not a valid errno.
212 #endif
213 case __NR_getdents64: // EPERM not a valid errno.
214 #if defined(__i386__) || defined(__mips__)
215 case __NR_readdir:
216 #endif
217 return true;
218 default:
219 return false;
223 bool SyscallSets::IsGetSimpleId(int sysno) {
224 switch (sysno) {
225 case __NR_capget:
226 case __NR_getegid:
227 case __NR_geteuid:
228 case __NR_getgid:
229 case __NR_getgroups:
230 case __NR_getpid:
231 case __NR_getppid:
232 case __NR_getresgid:
233 case __NR_getsid:
234 case __NR_gettid:
235 case __NR_getuid:
236 case __NR_getresuid:
237 #if defined(__i386__) || defined(__arm__)
238 case __NR_getegid32:
239 case __NR_geteuid32:
240 case __NR_getgid32:
241 case __NR_getgroups32:
242 case __NR_getresgid32:
243 case __NR_getresuid32:
244 case __NR_getuid32:
245 #endif
246 return true;
247 default:
248 return false;
252 bool SyscallSets::IsProcessPrivilegeChange(int sysno) {
253 switch (sysno) {
254 case __NR_capset:
255 #if defined(__i386__) || defined(__x86_64__)
256 case __NR_ioperm: // Intel privilege.
257 case __NR_iopl: // Intel privilege.
258 #endif
259 case __NR_setfsgid:
260 case __NR_setfsuid:
261 case __NR_setgid:
262 case __NR_setgroups:
263 case __NR_setregid:
264 case __NR_setresgid:
265 case __NR_setresuid:
266 case __NR_setreuid:
267 case __NR_setuid:
268 #if defined(__i386__) || defined(__arm__)
269 case __NR_setfsgid32:
270 case __NR_setfsuid32:
271 case __NR_setgid32:
272 case __NR_setgroups32:
273 case __NR_setregid32:
274 case __NR_setresgid32:
275 case __NR_setresuid32:
276 case __NR_setreuid32:
277 case __NR_setuid32:
278 #endif
279 return true;
280 default:
281 return false;
285 bool SyscallSets::IsProcessGroupOrSession(int sysno) {
286 switch (sysno) {
287 case __NR_setpgid:
288 #if !defined(__aarch64__)
289 case __NR_getpgrp:
290 #endif
291 case __NR_setsid:
292 case __NR_getpgid:
293 return true;
294 default:
295 return false;
299 bool SyscallSets::IsAllowedSignalHandling(int sysno) {
300 switch (sysno) {
301 case __NR_rt_sigaction:
302 case __NR_rt_sigprocmask:
303 case __NR_rt_sigreturn:
304 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
305 case __NR_sigaction:
306 case __NR_sigprocmask:
307 case __NR_sigreturn:
308 #endif
309 return true;
310 case __NR_rt_sigpending:
311 case __NR_rt_sigqueueinfo:
312 case __NR_rt_sigsuspend:
313 case __NR_rt_sigtimedwait:
314 case __NR_rt_tgsigqueueinfo:
315 case __NR_sigaltstack:
316 #if !defined(__aarch64__)
317 case __NR_signalfd:
318 #endif
319 case __NR_signalfd4:
320 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
321 case __NR_sigpending:
322 case __NR_sigsuspend:
323 #endif
324 #if defined(__i386__) || defined(__mips__)
325 case __NR_signal:
326 case __NR_sgetmask: // Obsolete.
327 case __NR_ssetmask:
328 #endif
329 default:
330 return false;
334 bool SyscallSets::IsAllowedOperationOnFd(int sysno) {
335 switch (sysno) {
336 case __NR_close:
337 case __NR_dup:
338 #if !defined(__aarch64__)
339 case __NR_dup2:
340 #endif
341 case __NR_dup3:
342 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
343 defined(__aarch64__)
344 case __NR_shutdown:
345 #endif
346 return true;
347 case __NR_fcntl:
348 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
349 case __NR_fcntl64:
350 #endif
351 default:
352 return false;
356 bool SyscallSets::IsKernelInternalApi(int sysno) {
357 switch (sysno) {
358 case __NR_restart_syscall:
359 #if defined(__arm__)
360 case __ARM_NR_cmpxchg:
361 #endif
362 return true;
363 default:
364 return false;
368 // This should be thought through in conjunction with IsFutex().
369 bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) {
370 switch (sysno) {
371 case __NR_exit:
372 case __NR_exit_group:
373 case __NR_wait4:
374 case __NR_waitid:
375 #if defined(__i386__)
376 case __NR_waitpid:
377 #endif
378 return true;
379 case __NR_clone: // Should be parameter-restricted.
380 case __NR_setns: // Privileged.
381 #if !defined(__aarch64__)
382 case __NR_fork:
383 #endif
384 #if defined(__i386__) || defined(__x86_64__)
385 case __NR_get_thread_area:
386 #endif
387 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
388 case __NR_set_thread_area:
389 #endif
390 case __NR_set_tid_address:
391 case __NR_unshare:
392 #if !defined(__mips__) && !defined(__aarch64__)
393 case __NR_vfork:
394 #endif
395 default:
396 return false;
400 // It's difficult to restrict those, but there is attack surface here.
401 bool SyscallSets::IsAllowedFutex(int sysno) {
402 switch (sysno) {
403 case __NR_get_robust_list:
404 case __NR_set_robust_list:
405 return true;
406 case __NR_futex:
407 default:
408 return false;
412 bool SyscallSets::IsAllowedEpoll(int sysno) {
413 switch (sysno) {
414 #if !defined(__aarch64__)
415 case __NR_epoll_create:
416 case __NR_epoll_wait:
417 #endif
418 case __NR_epoll_create1:
419 case __NR_epoll_ctl:
420 return true;
421 default:
422 #if defined(__x86_64__)
423 case __NR_epoll_ctl_old:
424 #endif
425 case __NR_epoll_pwait:
426 #if defined(__x86_64__)
427 case __NR_epoll_wait_old:
428 #endif
429 return false;
433 bool SyscallSets::IsAllowedGetOrModifySocket(int sysno) {
434 switch (sysno) {
435 #if !defined(__aarch64__)
436 case __NR_pipe:
437 #endif
438 case __NR_pipe2:
439 return true;
440 default:
441 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
442 defined(__aarch64__)
443 case __NR_socketpair: // We will want to inspect its argument.
444 #endif
445 return false;
449 bool SyscallSets::IsDeniedGetOrModifySocket(int sysno) {
450 switch (sysno) {
451 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
452 defined(__aarch64__)
453 case __NR_accept:
454 case __NR_accept4:
455 case __NR_bind:
456 case __NR_connect:
457 case __NR_socket:
458 case __NR_listen:
459 return true;
460 #endif
461 default:
462 return false;
466 #if defined(__i386__) || defined(__mips__)
467 // Big multiplexing system call for sockets.
468 bool SyscallSets::IsSocketCall(int sysno) {
469 switch (sysno) {
470 case __NR_socketcall:
471 return true;
472 default:
473 return false;
476 #endif
478 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__)
479 bool SyscallSets::IsNetworkSocketInformation(int sysno) {
480 switch (sysno) {
481 case __NR_getpeername:
482 case __NR_getsockname:
483 case __NR_getsockopt:
484 case __NR_setsockopt:
485 return true;
486 default:
487 return false;
490 #endif
492 bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) {
493 switch (sysno) {
494 case __NR_brk:
495 case __NR_mlock:
496 case __NR_munlock:
497 case __NR_munmap:
498 return true;
499 case __NR_madvise:
500 case __NR_mincore:
501 case __NR_mlockall:
502 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
503 defined(__aarch64__)
504 case __NR_mmap:
505 #endif
506 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
507 case __NR_mmap2:
508 #endif
509 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
510 case __NR_modify_ldt:
511 #endif
512 case __NR_mprotect:
513 case __NR_mremap:
514 case __NR_msync:
515 case __NR_munlockall:
516 case __NR_readahead:
517 case __NR_remap_file_pages:
518 #if defined(__i386__)
519 case __NR_vm86:
520 case __NR_vm86old:
521 #endif
522 default:
523 return false;
527 bool SyscallSets::IsAllowedGeneralIo(int sysno) {
528 switch (sysno) {
529 case __NR_lseek:
530 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
531 case __NR__llseek:
532 #endif
533 #if !defined(__aarch64__)
534 case __NR_poll:
535 #endif
536 case __NR_ppoll:
537 case __NR_pselect6:
538 case __NR_read:
539 case __NR_readv:
540 #if defined(__arm__) || defined(__mips__)
541 case __NR_recv:
542 #endif
543 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
544 defined(__aarch64__)
545 case __NR_recvfrom: // Could specify source.
546 case __NR_recvmsg: // Could specify source.
547 #endif
548 #if defined(__i386__) || defined(__x86_64__)
549 case __NR_select:
550 #endif
551 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
552 case __NR__newselect:
553 #endif
554 #if defined(__arm__)
555 case __NR_send:
556 #endif
557 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
558 defined(__aarch64__)
559 case __NR_sendmsg: // Could specify destination.
560 case __NR_sendto: // Could specify destination.
561 #endif
562 case __NR_write:
563 case __NR_writev:
564 return true;
565 case __NR_ioctl: // Can be very powerful.
566 case __NR_pread64:
567 case __NR_preadv:
568 case __NR_pwrite64:
569 case __NR_pwritev:
570 case __NR_recvmmsg: // Could specify source.
571 case __NR_sendfile:
572 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
573 case __NR_sendfile64:
574 #endif
575 case __NR_sendmmsg: // Could specify destination.
576 case __NR_splice:
577 case __NR_tee:
578 case __NR_vmsplice:
579 default:
580 return false;
584 bool SyscallSets::IsPrctl(int sysno) {
585 switch (sysno) {
586 #if defined(__x86_64__)
587 case __NR_arch_prctl:
588 #endif
589 case __NR_prctl:
590 return true;
591 default:
592 return false;
596 bool SyscallSets::IsSeccomp(int sysno) {
597 switch (sysno) {
598 case __NR_seccomp:
599 return true;
600 default:
601 return false;
605 bool SyscallSets::IsAllowedBasicScheduler(int sysno) {
606 switch (sysno) {
607 case __NR_sched_yield:
608 #if !defined(__aarch64__)
609 case __NR_pause:
610 #endif
611 case __NR_nanosleep:
612 return true;
613 case __NR_getpriority:
614 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
615 case __NR_nice:
616 #endif
617 case __NR_setpriority:
618 default:
619 return false;
623 bool SyscallSets::IsAdminOperation(int sysno) {
624 switch (sysno) {
625 #if defined(__i386__) || defined(__arm__) || defined(__mips__)
626 case __NR_bdflush:
627 #endif
628 case __NR_kexec_load:
629 case __NR_reboot:
630 case __NR_setdomainname:
631 case __NR_sethostname:
632 case __NR_syslog:
633 return true;
634 default:
635 return false;
639 bool SyscallSets::IsKernelModule(int sysno) {
640 switch (sysno) {
641 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
642 case __NR_create_module:
643 case __NR_get_kernel_syms: // Should ENOSYS.
644 case __NR_query_module:
645 #endif
646 case __NR_delete_module:
647 case __NR_init_module:
648 case __NR_finit_module:
649 return true;
650 default:
651 return false;
655 bool SyscallSets::IsGlobalFSViewChange(int sysno) {
656 switch (sysno) {
657 case __NR_pivot_root:
658 case __NR_chroot:
659 case __NR_sync:
660 return true;
661 default:
662 return false;
666 bool SyscallSets::IsFsControl(int sysno) {
667 switch (sysno) {
668 case __NR_mount:
669 case __NR_nfsservctl:
670 case __NR_quotactl:
671 case __NR_swapoff:
672 case __NR_swapon:
673 #if defined(__i386__) || defined(__mips__)
674 case __NR_umount:
675 #endif
676 case __NR_umount2:
677 return true;
678 default:
679 return false;
683 bool SyscallSets::IsNuma(int sysno) {
684 switch (sysno) {
685 case __NR_get_mempolicy:
686 case __NR_getcpu:
687 case __NR_mbind:
688 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
689 defined(__aarch64__)
690 case __NR_migrate_pages:
691 #endif
692 case __NR_move_pages:
693 case __NR_set_mempolicy:
694 return true;
695 default:
696 return false;
700 bool SyscallSets::IsMessageQueue(int sysno) {
701 switch (sysno) {
702 case __NR_mq_getsetattr:
703 case __NR_mq_notify:
704 case __NR_mq_open:
705 case __NR_mq_timedreceive:
706 case __NR_mq_timedsend:
707 case __NR_mq_unlink:
708 return true;
709 default:
710 return false;
714 bool SyscallSets::IsGlobalProcessEnvironment(int sysno) {
715 switch (sysno) {
716 case __NR_acct: // Privileged.
717 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
718 defined(__aarch64__)
719 case __NR_getrlimit:
720 #endif
721 #if defined(__i386__) || defined(__arm__)
722 case __NR_ugetrlimit:
723 #endif
724 #if defined(__i386__) || defined(__mips__)
725 case __NR_ulimit:
726 #endif
727 case __NR_getrusage:
728 case __NR_personality: // Can change its personality as well.
729 case __NR_prlimit64: // Like setrlimit / getrlimit.
730 case __NR_setrlimit:
731 case __NR_times:
732 return true;
733 default:
734 return false;
738 bool SyscallSets::IsDebug(int sysno) {
739 switch (sysno) {
740 case __NR_ptrace:
741 case __NR_process_vm_readv:
742 case __NR_process_vm_writev:
743 case __NR_kcmp:
744 return true;
745 default:
746 return false;
750 bool SyscallSets::IsGlobalSystemStatus(int sysno) {
751 switch (sysno) {
752 #if !defined(__aarch64__)
753 case __NR__sysctl:
754 case __NR_sysfs:
755 #endif
756 case __NR_sysinfo:
757 case __NR_uname:
758 #if defined(__i386__)
759 case __NR_olduname:
760 case __NR_oldolduname:
761 #endif
762 return true;
763 default:
764 return false;
768 bool SyscallSets::IsEventFd(int sysno) {
769 switch (sysno) {
770 #if !defined(__aarch64__)
771 case __NR_eventfd:
772 #endif
773 case __NR_eventfd2:
774 return true;
775 default:
776 return false;
780 // Asynchronous I/O API.
781 bool SyscallSets::IsAsyncIo(int sysno) {
782 switch (sysno) {
783 case __NR_io_cancel:
784 case __NR_io_destroy:
785 case __NR_io_getevents:
786 case __NR_io_setup:
787 case __NR_io_submit:
788 return true;
789 default:
790 return false;
794 bool SyscallSets::IsKeyManagement(int sysno) {
795 switch (sysno) {
796 case __NR_add_key:
797 case __NR_keyctl:
798 case __NR_request_key:
799 return true;
800 default:
801 return false;
805 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
806 bool SyscallSets::IsSystemVSemaphores(int sysno) {
807 switch (sysno) {
808 case __NR_semctl:
809 case __NR_semget:
810 case __NR_semop:
811 case __NR_semtimedop:
812 return true;
813 default:
814 return false;
817 #endif
819 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
820 // These give a lot of ambient authority and bypass the setuid sandbox.
821 bool SyscallSets::IsSystemVSharedMemory(int sysno) {
822 switch (sysno) {
823 case __NR_shmat:
824 case __NR_shmctl:
825 case __NR_shmdt:
826 case __NR_shmget:
827 return true;
828 default:
829 return false;
832 #endif
834 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
835 bool SyscallSets::IsSystemVMessageQueue(int sysno) {
836 switch (sysno) {
837 case __NR_msgctl:
838 case __NR_msgget:
839 case __NR_msgrcv:
840 case __NR_msgsnd:
841 return true;
842 default:
843 return false;
846 #endif
848 #if defined(__i386__) || defined(__mips__)
849 // Big system V multiplexing system call.
850 bool SyscallSets::IsSystemVIpc(int sysno) {
851 switch (sysno) {
852 case __NR_ipc:
853 return true;
854 default:
855 return false;
858 #endif
860 bool SyscallSets::IsAnySystemV(int sysno) {
861 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
862 return IsSystemVMessageQueue(sysno) || IsSystemVSemaphores(sysno) ||
863 IsSystemVSharedMemory(sysno);
864 #elif defined(__i386__) || defined(__mips__)
865 return IsSystemVIpc(sysno);
866 #endif
869 bool SyscallSets::IsAdvancedScheduler(int sysno) {
870 switch (sysno) {
871 case __NR_ioprio_get: // IO scheduler.
872 case __NR_ioprio_set:
873 case __NR_sched_get_priority_max:
874 case __NR_sched_get_priority_min:
875 case __NR_sched_getaffinity:
876 case __NR_sched_getattr:
877 case __NR_sched_getparam:
878 case __NR_sched_getscheduler:
879 case __NR_sched_rr_get_interval:
880 case __NR_sched_setaffinity:
881 case __NR_sched_setattr:
882 case __NR_sched_setparam:
883 case __NR_sched_setscheduler:
884 return true;
885 default:
886 return false;
890 bool SyscallSets::IsInotify(int sysno) {
891 switch (sysno) {
892 case __NR_inotify_add_watch:
893 #if !defined(__aarch64__)
894 case __NR_inotify_init:
895 #endif
896 case __NR_inotify_init1:
897 case __NR_inotify_rm_watch:
898 return true;
899 default:
900 return false;
904 bool SyscallSets::IsFaNotify(int sysno) {
905 switch (sysno) {
906 case __NR_fanotify_init:
907 case __NR_fanotify_mark:
908 return true;
909 default:
910 return false;
914 bool SyscallSets::IsTimer(int sysno) {
915 switch (sysno) {
916 case __NR_getitimer:
917 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
918 case __NR_alarm:
919 #endif
920 case __NR_setitimer:
921 return true;
922 default:
923 return false;
927 bool SyscallSets::IsAdvancedTimer(int sysno) {
928 switch (sysno) {
929 case __NR_timer_create:
930 case __NR_timer_delete:
931 case __NR_timer_getoverrun:
932 case __NR_timer_gettime:
933 case __NR_timer_settime:
934 case __NR_timerfd_create:
935 case __NR_timerfd_gettime:
936 case __NR_timerfd_settime:
937 return true;
938 default:
939 return false;
943 bool SyscallSets::IsExtendedAttributes(int sysno) {
944 switch (sysno) {
945 case __NR_fgetxattr:
946 case __NR_flistxattr:
947 case __NR_fremovexattr:
948 case __NR_fsetxattr:
949 case __NR_getxattr:
950 case __NR_lgetxattr:
951 case __NR_listxattr:
952 case __NR_llistxattr:
953 case __NR_lremovexattr:
954 case __NR_lsetxattr:
955 case __NR_removexattr:
956 case __NR_setxattr:
957 return true;
958 default:
959 return false;
963 // Various system calls that need to be researched.
964 // TODO(jln): classify this better.
965 bool SyscallSets::IsMisc(int sysno) {
966 switch (sysno) {
967 #if !defined(__mips__)
968 case __NR_getrandom:
969 #endif
970 case __NR_name_to_handle_at:
971 case __NR_open_by_handle_at:
972 case __NR_perf_event_open:
973 case __NR_syncfs:
974 case __NR_vhangup:
975 // The system calls below are not implemented.
976 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
977 case __NR_afs_syscall:
978 #endif
979 #if defined(__i386__) || defined(__mips__)
980 case __NR_break:
981 #endif
982 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
983 case __NR_getpmsg:
984 #endif
985 #if defined(__i386__) || defined(__mips__)
986 case __NR_gtty:
987 case __NR_idle:
988 case __NR_lock:
989 case __NR_mpx:
990 case __NR_prof:
991 case __NR_profil:
992 #endif
993 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
994 case __NR_putpmsg:
995 #endif
996 #if defined(__x86_64__)
997 case __NR_security:
998 #endif
999 #if defined(__i386__) || defined(__mips__)
1000 case __NR_stty:
1001 #endif
1002 #if defined(__x86_64__)
1003 case __NR_tuxcall:
1004 #endif
1005 #if !defined(__aarch64__)
1006 case __NR_vserver:
1007 #endif
1008 return true;
1009 default:
1010 return false;
1014 #if defined(__arm__)
1015 bool SyscallSets::IsArmPciConfig(int sysno) {
1016 switch (sysno) {
1017 case __NR_pciconfig_iobase:
1018 case __NR_pciconfig_read:
1019 case __NR_pciconfig_write:
1020 return true;
1021 default:
1022 return false;
1026 bool SyscallSets::IsArmPrivate(int sysno) {
1027 switch (sysno) {
1028 case __ARM_NR_breakpoint:
1029 case __ARM_NR_cacheflush:
1030 case __ARM_NR_set_tls:
1031 case __ARM_NR_usr26:
1032 case __ARM_NR_usr32:
1033 return true;
1034 default:
1035 return false;
1038 #endif // defined(__arm__)
1040 #if defined(__mips__)
1041 bool SyscallSets::IsMipsPrivate(int sysno) {
1042 switch (sysno) {
1043 case __NR_cacheflush:
1044 case __NR_cachectl:
1045 return true;
1046 default:
1047 return false;
1051 bool SyscallSets::IsMipsMisc(int sysno) {
1052 switch (sysno) {
1053 case __NR_sysmips:
1054 case __NR_unused150:
1055 return true;
1056 default:
1057 return false;
1060 #endif // defined(__mips__)
1061 } // namespace sandbox.