Commit da57715a authored by jorgelo@chromium.org's avatar jorgelo@chromium.org

Add ARM syscalls to syscall sets.

BUG=141157
TEST=Build and boot on daisy.


Review URL: https://chromiumcodereview.appspot.com/10830348

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152164 0039d316-1c4b-4281-b951-d872f2087c98
parent c3a05e9f
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
#include "content/public/common/content_switches.h" #include "content/public/common/content_switches.h"
// These are the only architectures supported for now. // These are the only architectures supported for now.
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) #if defined(__i386__) || defined(__x86_64__) || \
(defined(__arm__) && (defined(__thumb__) || defined(__ARM_EABI__)))
#define SECCOMP_BPF_SANDBOX #define SECCOMP_BPF_SANDBOX
#endif #endif
...@@ -153,9 +154,8 @@ intptr_t GpuOpenSIGSYS_Handler(const struct arch_seccomp_data& args, ...@@ -153,9 +154,8 @@ intptr_t GpuOpenSIGSYS_Handler(const struct arch_seccomp_data& args,
} }
} }
#if defined(__i386__) || defined(__x86_64__) // The functions below cover all existing i386, x86_64, and ARM system calls;
// excluding syscalls made obsolete in ARM EABI.
// The functions below cover all existing x86_64 and i386 system calls.
// The implicitly defined sets form a partition of the sets of // The implicitly defined sets form a partition of the sets of
// system calls. // system calls.
...@@ -175,7 +175,9 @@ bool IsAllowedGettime(int sysno) { ...@@ -175,7 +175,9 @@ bool IsAllowedGettime(int sysno) {
switch (sysno) { switch (sysno) {
case __NR_clock_gettime: case __NR_clock_gettime:
case __NR_gettimeofday: case __NR_gettimeofday:
#if defined(__i386__) || defined(__x86_64__)
case __NR_time: case __NR_time:
#endif
return true; return true;
case __NR_adjtimex: // Privileged. case __NR_adjtimex: // Privileged.
case __NR_clock_adjtime: // Privileged. case __NR_clock_adjtime: // Privileged.
...@@ -279,7 +281,9 @@ bool IsFileSystem(int sysno) { ...@@ -279,7 +281,9 @@ bool IsFileSystem(int sysno) {
case __NR_unlinkat: case __NR_unlinkat:
case __NR_uselib: // Neither EPERM, nor ENOENT are valid errno. case __NR_uselib: // Neither EPERM, nor ENOENT are valid errno.
case __NR_ustat: // Same as above. Deprecated. case __NR_ustat: // Same as above. Deprecated.
#if defined(__i386__) || defined(__x86_64__)
case __NR_utime: case __NR_utime:
#endif
case __NR_utimensat: // New. case __NR_utimensat: // New.
case __NR_utimes: case __NR_utimes:
return true; return true;
...@@ -296,9 +300,14 @@ bool IsAllowedFileSystemAccessViaFd(int sysno) { ...@@ -296,9 +300,14 @@ bool IsAllowedFileSystemAccessViaFd(int sysno) {
#endif #endif
return true; return true;
// TODO(jln): these should be denied gracefully as well (moved below). // TODO(jln): these should be denied gracefully as well (moved below).
#if defined(__i386__) || defined(__x86_64__)
case __NR_fadvise64: // EPERM not a valid errno. case __NR_fadvise64: // EPERM not a valid errno.
#endif
#if defined(__i386__) #if defined(__i386__)
case __NR_fadvise64_64: case __NR_fadvise64_64:
#endif
#if defined(__arm__)
case __NR_arm_fadvise64_64:
#endif #endif
case __NR_fdatasync: // EPERM not a valid errno. case __NR_fdatasync: // EPERM not a valid errno.
case __NR_flock: // EPERM not a valid errno. case __NR_flock: // EPERM not a valid errno.
...@@ -310,7 +319,11 @@ bool IsAllowedFileSystemAccessViaFd(int sysno) { ...@@ -310,7 +319,11 @@ bool IsAllowedFileSystemAccessViaFd(int sysno) {
#if defined(__i386__) #if defined(__i386__)
case __NR_oldfstat: case __NR_oldfstat:
#endif #endif
#if defined(__i386__) || defined(__x86_64__)
case __NR_sync_file_range: // EPERM not a valid errno. case __NR_sync_file_range: // EPERM not a valid errno.
#elif defined(__arm__)
case __NR_arm_sync_file_range: // EPERM not a valid errno.
#endif
default: default:
return false; return false;
} }
...@@ -384,8 +397,10 @@ bool IsGetSimpleId(int sysno) { ...@@ -384,8 +397,10 @@ bool IsGetSimpleId(int sysno) {
bool IsProcessPrivilegeChange(int sysno) { bool IsProcessPrivilegeChange(int sysno) {
switch (sysno) { switch (sysno) {
case __NR_capset: case __NR_capset:
#if defined(__i386__) || defined(__x86_64__)
case __NR_ioperm: // Intel privilege. case __NR_ioperm: // Intel privilege.
case __NR_iopl: // Intel privilege. case __NR_iopl: // Intel privilege.
#endif
case __NR_setfsgid: case __NR_setfsgid:
case __NR_setfsuid: case __NR_setfsuid:
case __NR_setgid: case __NR_setgid:
...@@ -474,9 +489,12 @@ bool IsOperationOnFd(int sysno) { ...@@ -474,9 +489,12 @@ bool IsOperationOnFd(int sysno) {
} }
} }
bool IsKernelInteralApi(int sysno) { bool IsKernelInternalApi(int sysno) {
switch (sysno) { switch (sysno) {
case __NR_restart_syscall: case __NR_restart_syscall:
#if defined(__arm__)
case __ARM_NR_cmpxchg:
#endif
return true; return true;
default: default:
return false; return false;
...@@ -497,8 +515,10 @@ bool IsAllowedProcessStartOrDeath(int sysno) { ...@@ -497,8 +515,10 @@ bool IsAllowedProcessStartOrDeath(int sysno) {
return true; return true;
case __NR_setns: // Privileged. case __NR_setns: // Privileged.
case __NR_fork: case __NR_fork:
#if defined(__i386__) || defined(__x86_64__)
case __NR_get_thread_area: case __NR_get_thread_area:
case __NR_set_thread_area: case __NR_set_thread_area:
#endif
case __NR_set_tid_address: case __NR_set_tid_address:
case __NR_unshare: case __NR_unshare:
case __NR_vfork: case __NR_vfork:
...@@ -590,8 +610,10 @@ bool IsAllowedAddressSpaceAccess(int sysno) { ...@@ -590,8 +610,10 @@ bool IsAllowedAddressSpaceAccess(int sysno) {
case __NR_brk: case __NR_brk:
case __NR_madvise: case __NR_madvise:
case __NR_mlock: case __NR_mlock:
#if defined(__i386__) || defined(__x86_64__)
case __NR_mmap: // TODO(jln): to restrict flags. case __NR_mmap: // TODO(jln): to restrict flags.
#if defined(__i386__) #endif
#if defined(__i386__) || defined(__arm__)
case __NR_mmap2: case __NR_mmap2:
#endif #endif
case __NR_mprotect: case __NR_mprotect:
...@@ -600,7 +622,9 @@ bool IsAllowedAddressSpaceAccess(int sysno) { ...@@ -600,7 +622,9 @@ bool IsAllowedAddressSpaceAccess(int sysno) {
return true; return true;
case __NR_mincore: case __NR_mincore:
case __NR_mlockall: case __NR_mlockall:
#if defined(__i386__) || defined(__x86_64__)
case __NR_modify_ldt: case __NR_modify_ldt:
#endif
case __NR_mremap: case __NR_mremap:
case __NR_msync: case __NR_msync:
case __NR_munlockall: case __NR_munlockall:
...@@ -626,14 +650,22 @@ bool IsAllowedGeneralIo(int sysno) { ...@@ -626,14 +650,22 @@ bool IsAllowedGeneralIo(int sysno) {
case __NR_pselect6: case __NR_pselect6:
case __NR_read: case __NR_read:
case __NR_readv: case __NR_readv:
#if defined(__arm__)
case __NR_recv:
#endif
#if defined(__x86_64__) #if defined(__x86_64__)
case __NR_recvfrom: // Could specify source. case __NR_recvfrom: // Could specify source.
case __NR_recvmsg: // Could specify source. case __NR_recvmsg: // Could specify source.
#endif #endif
#if defined(__i386__) || defined(__x86_64__)
case __NR_select: case __NR_select:
#if defined(__i386__) #endif
#if defined(__i386__) || defined(__arm__)
case __NR__newselect: case __NR__newselect:
#endif #endif
#if defined(__arm__)
case __NR_send:
#endif
#if defined(__x86_64__) #if defined(__x86_64__)
case __NR_sendmsg: // Could specify destination. case __NR_sendmsg: // Could specify destination.
case __NR_sendto: // Could specify destination. case __NR_sendto: // Could specify destination.
...@@ -706,11 +738,13 @@ bool IsAdminOperation(int sysno) { ...@@ -706,11 +738,13 @@ bool IsAdminOperation(int sysno) {
bool IsKernelModule(int sysno) { bool IsKernelModule(int sysno) {
switch (sysno) { switch (sysno) {
#if defined(__i386__) || defined(__x86_64__)
case __NR_create_module: case __NR_create_module:
case __NR_delete_module:
case __NR_get_kernel_syms: // Should ENOSYS. case __NR_get_kernel_syms: // Should ENOSYS.
case __NR_init_module:
case __NR_query_module: case __NR_query_module:
#endif
case __NR_delete_module:
case __NR_init_module:
return true; return true;
default: default:
return false; return false;
...@@ -750,7 +784,9 @@ bool IsNuma(int sysno) { ...@@ -750,7 +784,9 @@ bool IsNuma(int sysno) {
case __NR_get_mempolicy: case __NR_get_mempolicy:
case __NR_getcpu: case __NR_getcpu:
case __NR_mbind: case __NR_mbind:
#if defined(__i386__) || defined(__x86_64__)
case __NR_migrate_pages: case __NR_migrate_pages:
#endif
case __NR_move_pages: case __NR_move_pages:
case __NR_set_mempolicy: case __NR_set_mempolicy:
return true; return true;
...@@ -776,9 +812,12 @@ bool IsMessageQueue(int sysno) { ...@@ -776,9 +812,12 @@ bool IsMessageQueue(int sysno) {
bool IsGlobalProcessEnvironment(int sysno) { bool IsGlobalProcessEnvironment(int sysno) {
switch (sysno) { switch (sysno) {
case __NR_acct: // Privileged. case __NR_acct: // Privileged.
#if defined(__i386__) || defined(__x86_64__)
case __NR_getrlimit: case __NR_getrlimit:
#if defined(__i386__) #endif
#if defined(__i386__) || defined(__arm__)
case __NR_ugetrlimit: case __NR_ugetrlimit:
#elif defined(__i386__)
case __NR_ulimit: case __NR_ulimit:
#endif #endif
case __NR_getrusage: case __NR_getrusage:
...@@ -797,7 +836,9 @@ bool IsDebug(int sysno) { ...@@ -797,7 +836,9 @@ bool IsDebug(int sysno) {
case __NR_ptrace: case __NR_ptrace:
case __NR_process_vm_readv: case __NR_process_vm_readv:
case __NR_process_vm_writev: case __NR_process_vm_writev:
#if defined(__i386__) || defined(__x86_64__)
case __NR_kcmp: case __NR_kcmp:
#endif
return true; return true;
default: default:
return false; return false;
...@@ -954,7 +995,9 @@ bool IsFaNotify(int sysno) { ...@@ -954,7 +995,9 @@ bool IsFaNotify(int sysno) {
bool IsTimer(int sysno) { bool IsTimer(int sysno) {
switch (sysno) { switch (sysno) {
case __NR_getitimer: case __NR_getitimer:
#if defined(__i386__) || defined(__x86_64__)
case __NR_alarm: case __NR_alarm:
#endif
case __NR_setitimer: case __NR_setitimer:
return true; return true;
default: default:
...@@ -1008,11 +1051,15 @@ bool IsMisc(int sysno) { ...@@ -1008,11 +1051,15 @@ bool IsMisc(int sysno) {
case __NR_syncfs: case __NR_syncfs:
case __NR_vhangup: case __NR_vhangup:
// The system calls below are not implemented. // The system calls below are not implemented.
#if defined(__i386__) || defined(__x86_64__)
case __NR_afs_syscall: case __NR_afs_syscall:
#endif
#if defined(__i386__) #if defined(__i386__)
case __NR_break: case __NR_break:
#endif #endif
#if defined(__i386__) || defined(__x86_64__)
case __NR_getpmsg: case __NR_getpmsg:
#endif
#if defined(__i386__) #if defined(__i386__)
case __NR_gtty: case __NR_gtty:
case __NR_idle: case __NR_idle:
...@@ -1021,7 +1068,9 @@ bool IsMisc(int sysno) { ...@@ -1021,7 +1068,9 @@ bool IsMisc(int sysno) {
case __NR_prof: case __NR_prof:
case __NR_profil: case __NR_profil:
#endif #endif
#if defined(__i386__) || defined(__x86_64__)
case __NR_putpmsg: case __NR_putpmsg:
#endif
#if defined(__x86_64__) #if defined(__x86_64__)
case __NR_security: case __NR_security:
#endif #endif
...@@ -1038,6 +1087,32 @@ bool IsMisc(int sysno) { ...@@ -1038,6 +1087,32 @@ bool IsMisc(int sysno) {
} }
} }
#if defined(__arm__)
bool IsArmPciConfig(int sysno) {
switch (sysno) {
case __NR_pciconfig_iobase:
case __NR_pciconfig_read:
case __NR_pciconfig_write:
return true;
default:
return false;
}
}
bool IsArmPrivate(int sysno) {
switch (sysno) {
case __ARM_NR_breakpoint:
case __ARM_NR_cacheflush:
case __ARM_NR_set_tls:
case __ARM_NR_usr26:
case __ARM_NR_usr32:
return true;
default:
return false;
}
}
#endif // defined(__arm__)
// End of the system call sets section. // End of the system call sets section.
bool IsBaselinePolicyAllowed_x86_64(int sysno) { bool IsBaselinePolicyAllowed_x86_64(int sysno) {
...@@ -1053,7 +1128,10 @@ bool IsBaselinePolicyAllowed_x86_64(int sysno) { ...@@ -1053,7 +1128,10 @@ bool IsBaselinePolicyAllowed_x86_64(int sysno) {
IsAllowedSignalHandling(sysno) || IsAllowedSignalHandling(sysno) ||
IsFutex(sysno) || IsFutex(sysno) ||
IsGetSimpleId(sysno) || IsGetSimpleId(sysno) ||
IsKernelInteralApi(sysno) || IsKernelInternalApi(sysno) ||
#if defined(__arm__)
IsArmPrivate(sysno) ||
#endif
IsKill(sysno) || IsKill(sysno) ||
IsOperationOnFd(sysno)) { IsOperationOnFd(sysno)) {
return true; return true;
...@@ -1099,6 +1177,9 @@ bool IsBaselinePolicyWatched_x86_64(int sysno) { ...@@ -1099,6 +1177,9 @@ bool IsBaselinePolicyWatched_x86_64(int sysno) {
IsSystemVSemaphores(sysno) || IsSystemVSemaphores(sysno) ||
#elif defined(__i386__) #elif defined(__i386__)
IsSystemVIpc(sysno) || IsSystemVIpc(sysno) ||
#endif
#if defined(__arm__)
IsArmPciConfig(sysno) ||
#endif #endif
IsTimer(sysno)) { IsTimer(sysno)) {
return true; return true;
...@@ -1189,7 +1270,6 @@ playground2::Sandbox::ErrorCode FlashProcessPolicy_x86_64(int sysno) { ...@@ -1189,7 +1270,6 @@ playground2::Sandbox::ErrorCode FlashProcessPolicy_x86_64(int sysno) {
return BaselinePolicy_x86_64(sysno); return BaselinePolicy_x86_64(sysno);
} }
} }
#endif // defined(__i386__) || defined(__x86_64__)
playground2::Sandbox::ErrorCode BlacklistPtracePolicy(int sysno) { playground2::Sandbox::ErrorCode BlacklistPtracePolicy(int sysno) {
if (sysno < static_cast<int>(MIN_SYSCALL) || if (sysno < static_cast<int>(MIN_SYSCALL) ||
......
...@@ -24,5 +24,9 @@ ...@@ -24,5 +24,9 @@
#define __NR_process_vm_writev (__NR_SYSCALL_BASE+377) #define __NR_process_vm_writev (__NR_SYSCALL_BASE+377)
#endif #endif
#ifndef __ARM_NR_cmpxchg
#define __ARM_NR_cmpxchg (__ARM_NR_BASE+0x00fff0)
#endif
#endif // SANDBOX_LINUX_SERVICES_ARM_LINUX_SYSCALLS_H_ #endif // SANDBOX_LINUX_SERVICES_ARM_LINUX_SYSCALLS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment