| OLD | NEW |
| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 return false; | 69 return false; |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 // System calls that directly access the file system. They might acquire | 73 // System calls that directly access the file system. They might acquire |
| 74 // a new file descriptor or otherwise perform an operation directly | 74 // a new file descriptor or otherwise perform an operation directly |
| 75 // via a path. | 75 // via a path. |
| 76 // Both EPERM and ENOENT are valid errno unless otherwise noted in comment. | 76 // Both EPERM and ENOENT are valid errno unless otherwise noted in comment. |
| 77 bool SyscallSets::IsFileSystem(int sysno) { | 77 bool SyscallSets::IsFileSystem(int sysno) { |
| 78 switch (sysno) { | 78 switch (sysno) { |
| 79 #if !defined(__aarch64__) |
| 79 case __NR_access: // EPERM not a valid errno. | 80 case __NR_access: // EPERM not a valid errno. |
| 80 case __NR_chmod: | 81 case __NR_chmod: |
| 81 case __NR_chown: | 82 case __NR_chown: |
| 82 #if defined(__i386__) || defined(__arm__) | 83 #if defined(__i386__) || defined(__arm__) |
| 83 case __NR_chown32: | 84 case __NR_chown32: |
| 84 #endif | 85 #endif |
| 85 case __NR_creat: | 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__) |
| 104 |
| 86 case __NR_execve: | 105 case __NR_execve: |
| 87 case __NR_faccessat: // EPERM not a valid errno. | 106 case __NR_faccessat: // EPERM not a valid errno. |
| 88 case __NR_fchmodat: | 107 case __NR_fchmodat: |
| 89 case __NR_fchownat: // Should be called chownat ? | 108 case __NR_fchownat: // Should be called chownat ? |
| 90 #if defined(__x86_64__) | 109 #if defined(__x86_64__) || defined(__aarch64__) |
| 91 case __NR_newfstatat: // fstatat(). EPERM not a valid errno. | 110 case __NR_newfstatat: // fstatat(). EPERM not a valid errno. |
| 92 #elif defined(__i386__) || defined(__arm__) || defined(__mips__) | 111 #elif defined(__i386__) || defined(__arm__) || defined(__mips__) |
| 93 case __NR_fstatat64: | 112 case __NR_fstatat64: |
| 94 #endif | 113 #endif |
| 95 case __NR_futimesat: // Should be called utimesat ? | |
| 96 case __NR_lchown: | |
| 97 #if defined(__i386__) || defined(__arm__) | 114 #if defined(__i386__) || defined(__arm__) |
| 98 case __NR_lchown32: | 115 case __NR_lchown32: |
| 99 #endif | 116 #endif |
| 100 case __NR_link: | |
| 101 case __NR_linkat: | 117 case __NR_linkat: |
| 102 case __NR_lookup_dcookie: // ENOENT not a valid errno. | 118 case __NR_lookup_dcookie: // ENOENT not a valid errno. |
| 103 case __NR_lstat: // EPERM not a valid errno. | 119 |
| 104 #if defined(__i386__) | |
| 105 case __NR_oldlstat: | |
| 106 #endif | |
| 107 #if defined(__i386__) || defined(__arm__) || defined(__mips__) | 120 #if defined(__i386__) || defined(__arm__) || defined(__mips__) |
| 108 case __NR_lstat64: | 121 case __NR_lstat64: |
| 109 #endif | 122 #endif |
| 110 #if !defined(__mips__) | 123 #if defined(__i386__) || defined(__arm__) || defined(__x86_64__) |
| 111 case __NR_memfd_create: | 124 case __NR_memfd_create: |
| 112 #endif | 125 #endif |
| 113 case __NR_mkdir: | |
| 114 case __NR_mkdirat: | 126 case __NR_mkdirat: |
| 115 case __NR_mknod: | |
| 116 case __NR_mknodat: | 127 case __NR_mknodat: |
| 117 case __NR_open: | 128 #if defined(__i386__) |
| 129 case __NR_oldlstat: |
| 130 case __NR_oldstat: |
| 131 #endif |
| 118 case __NR_openat: | 132 case __NR_openat: |
| 119 case __NR_readlink: // EPERM not a valid errno. | |
| 120 case __NR_readlinkat: | 133 case __NR_readlinkat: |
| 121 case __NR_rename: | |
| 122 case __NR_renameat: | 134 case __NR_renameat: |
| 123 case __NR_renameat2: | 135 case __NR_renameat2: |
| 124 case __NR_rmdir: | |
| 125 case __NR_stat: // EPERM not a valid errno. | |
| 126 #if defined(__i386__) | |
| 127 case __NR_oldstat: | |
| 128 #endif | |
| 129 #if defined(__i386__) || defined(__arm__) || defined(__mips__) | 136 #if defined(__i386__) || defined(__arm__) || defined(__mips__) |
| 130 case __NR_stat64: | 137 case __NR_stat64: |
| 131 #endif | 138 #endif |
| 132 case __NR_statfs: // EPERM not a valid errno. | 139 case __NR_statfs: // EPERM not a valid errno. |
| 133 #if defined(__i386__) || defined(__arm__) || defined(__mips__) | 140 #if defined(__i386__) || defined(__arm__) || defined(__mips__) |
| 134 case __NR_statfs64: | 141 case __NR_statfs64: |
| 135 #endif | 142 #endif |
| 136 case __NR_symlink: | |
| 137 case __NR_symlinkat: | 143 case __NR_symlinkat: |
| 138 case __NR_truncate: | 144 case __NR_truncate: |
| 139 #if defined(__i386__) || defined(__arm__) || defined(__mips__) | 145 #if defined(__i386__) || defined(__arm__) || defined(__mips__) |
| 140 case __NR_truncate64: | 146 case __NR_truncate64: |
| 141 #endif | 147 #endif |
| 142 case __NR_unlink: | |
| 143 case __NR_unlinkat: | 148 case __NR_unlinkat: |
| 144 case __NR_uselib: // Neither EPERM, nor ENOENT are valid errno. | |
| 145 case __NR_ustat: // Same as above. Deprecated. | |
| 146 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) | 149 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) |
| 147 case __NR_utime: | 150 case __NR_utime: |
| 148 #endif | 151 #endif |
| 149 case __NR_utimensat: // New. | 152 case __NR_utimensat: // New. |
| 150 case __NR_utimes: | |
| 151 return true; | 153 return true; |
| 152 default: | 154 default: |
| 153 return false; | 155 return false; |
| 154 } | 156 } |
| 155 } | 157 } |
| 156 | 158 |
| 157 bool SyscallSets::IsAllowedFileSystemAccessViaFd(int sysno) { | 159 bool SyscallSets::IsAllowedFileSystemAccessViaFd(int sysno) { |
| 158 switch (sysno) { | 160 switch (sysno) { |
| 159 case __NR_fstat: | 161 case __NR_fstat: |
| 160 #if defined(__i386__) || defined(__arm__) || defined(__mips__) | 162 #if defined(__i386__) || defined(__arm__) || defined(__mips__) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 174 case __NR_fdatasync: // EPERM not a valid errno. | 176 case __NR_fdatasync: // EPERM not a valid errno. |
| 175 case __NR_flock: // EPERM not a valid errno. | 177 case __NR_flock: // EPERM not a valid errno. |
| 176 case __NR_fstatfs: // Give information about the whole filesystem. | 178 case __NR_fstatfs: // Give information about the whole filesystem. |
| 177 #if defined(__i386__) || defined(__arm__) || defined(__mips__) | 179 #if defined(__i386__) || defined(__arm__) || defined(__mips__) |
| 178 case __NR_fstatfs64: | 180 case __NR_fstatfs64: |
| 179 #endif | 181 #endif |
| 180 case __NR_fsync: // EPERM not a valid errno. | 182 case __NR_fsync: // EPERM not a valid errno. |
| 181 #if defined(__i386__) | 183 #if defined(__i386__) |
| 182 case __NR_oldfstat: | 184 case __NR_oldfstat: |
| 183 #endif | 185 #endif |
| 184 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) | 186 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ |
| 187 defined(__aarch64__) |
| 185 case __NR_sync_file_range: // EPERM not a valid errno. | 188 case __NR_sync_file_range: // EPERM not a valid errno. |
| 186 #elif defined(__arm__) | 189 #elif defined(__arm__) |
| 187 case __NR_arm_sync_file_range: // EPERM not a valid errno. | 190 case __NR_arm_sync_file_range: // EPERM not a valid errno. |
| 188 #endif | 191 #endif |
| 189 default: | 192 default: |
| 190 return false; | 193 return false; |
| 191 } | 194 } |
| 192 } | 195 } |
| 193 | 196 |
| 194 // EPERM is a good errno for any of these. | 197 // EPERM is a good errno for any of these. |
| 195 bool SyscallSets::IsDeniedFileSystemAccessViaFd(int sysno) { | 198 bool SyscallSets::IsDeniedFileSystemAccessViaFd(int sysno) { |
| 196 switch (sysno) { | 199 switch (sysno) { |
| 197 case __NR_fallocate: | 200 case __NR_fallocate: |
| 198 case __NR_fchmod: | 201 case __NR_fchmod: |
| 199 case __NR_fchown: | 202 case __NR_fchown: |
| 200 case __NR_ftruncate: | 203 case __NR_ftruncate: |
| 201 #if defined(__i386__) || defined(__arm__) | 204 #if defined(__i386__) || defined(__arm__) |
| 202 case __NR_fchown32: | 205 case __NR_fchown32: |
| 203 #endif | 206 #endif |
| 204 #if defined(__i386__) || defined(__arm__) || defined(__mips__) | 207 #if defined(__i386__) || defined(__arm__) || defined(__mips__) |
| 205 case __NR_ftruncate64: | 208 case __NR_ftruncate64: |
| 206 #endif | 209 #endif |
| 210 #if !defined(__aarch64__) |
| 207 case __NR_getdents: // EPERM not a valid errno. | 211 case __NR_getdents: // EPERM not a valid errno. |
| 212 #endif |
| 208 case __NR_getdents64: // EPERM not a valid errno. | 213 case __NR_getdents64: // EPERM not a valid errno. |
| 209 #if defined(__i386__) || defined(__mips__) | 214 #if defined(__i386__) || defined(__mips__) |
| 210 case __NR_readdir: | 215 case __NR_readdir: |
| 211 #endif | 216 #endif |
| 212 return true; | 217 return true; |
| 213 default: | 218 default: |
| 214 return false; | 219 return false; |
| 215 } | 220 } |
| 216 } | 221 } |
| 217 | 222 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 #endif | 278 #endif |
| 274 return true; | 279 return true; |
| 275 default: | 280 default: |
| 276 return false; | 281 return false; |
| 277 } | 282 } |
| 278 } | 283 } |
| 279 | 284 |
| 280 bool SyscallSets::IsProcessGroupOrSession(int sysno) { | 285 bool SyscallSets::IsProcessGroupOrSession(int sysno) { |
| 281 switch (sysno) { | 286 switch (sysno) { |
| 282 case __NR_setpgid: | 287 case __NR_setpgid: |
| 288 #if !defined(__aarch64__) |
| 283 case __NR_getpgrp: | 289 case __NR_getpgrp: |
| 290 #endif |
| 284 case __NR_setsid: | 291 case __NR_setsid: |
| 285 case __NR_getpgid: | 292 case __NR_getpgid: |
| 286 return true; | 293 return true; |
| 287 default: | 294 default: |
| 288 return false; | 295 return false; |
| 289 } | 296 } |
| 290 } | 297 } |
| 291 | 298 |
| 292 bool SyscallSets::IsAllowedSignalHandling(int sysno) { | 299 bool SyscallSets::IsAllowedSignalHandling(int sysno) { |
| 293 switch (sysno) { | 300 switch (sysno) { |
| 294 case __NR_rt_sigaction: | 301 case __NR_rt_sigaction: |
| 295 case __NR_rt_sigprocmask: | 302 case __NR_rt_sigprocmask: |
| 296 case __NR_rt_sigreturn: | 303 case __NR_rt_sigreturn: |
| 297 #if defined(__i386__) || defined(__arm__) || defined(__mips__) | 304 #if defined(__i386__) || defined(__arm__) || defined(__mips__) |
| 298 case __NR_sigaction: | 305 case __NR_sigaction: |
| 299 case __NR_sigprocmask: | 306 case __NR_sigprocmask: |
| 300 case __NR_sigreturn: | 307 case __NR_sigreturn: |
| 301 #endif | 308 #endif |
| 302 return true; | 309 return true; |
| 303 case __NR_rt_sigpending: | 310 case __NR_rt_sigpending: |
| 304 case __NR_rt_sigqueueinfo: | 311 case __NR_rt_sigqueueinfo: |
| 305 case __NR_rt_sigsuspend: | 312 case __NR_rt_sigsuspend: |
| 306 case __NR_rt_sigtimedwait: | 313 case __NR_rt_sigtimedwait: |
| 307 case __NR_rt_tgsigqueueinfo: | 314 case __NR_rt_tgsigqueueinfo: |
| 308 case __NR_sigaltstack: | 315 case __NR_sigaltstack: |
| 316 #if !defined(__aarch64__) |
| 309 case __NR_signalfd: | 317 case __NR_signalfd: |
| 318 #endif |
| 310 case __NR_signalfd4: | 319 case __NR_signalfd4: |
| 311 #if defined(__i386__) || defined(__arm__) || defined(__mips__) | 320 #if defined(__i386__) || defined(__arm__) || defined(__mips__) |
| 312 case __NR_sigpending: | 321 case __NR_sigpending: |
| 313 case __NR_sigsuspend: | 322 case __NR_sigsuspend: |
| 314 #endif | 323 #endif |
| 315 #if defined(__i386__) || defined(__mips__) | 324 #if defined(__i386__) || defined(__mips__) |
| 316 case __NR_signal: | 325 case __NR_signal: |
| 317 case __NR_sgetmask: // Obsolete. | 326 case __NR_sgetmask: // Obsolete. |
| 318 case __NR_ssetmask: | 327 case __NR_ssetmask: |
| 319 #endif | 328 #endif |
| 320 default: | 329 default: |
| 321 return false; | 330 return false; |
| 322 } | 331 } |
| 323 } | 332 } |
| 324 | 333 |
| 325 bool SyscallSets::IsAllowedOperationOnFd(int sysno) { | 334 bool SyscallSets::IsAllowedOperationOnFd(int sysno) { |
| 326 switch (sysno) { | 335 switch (sysno) { |
| 327 case __NR_close: | 336 case __NR_close: |
| 328 case __NR_dup: | 337 case __NR_dup: |
| 338 #if !defined(__aarch64__) |
| 329 case __NR_dup2: | 339 case __NR_dup2: |
| 340 #endif |
| 330 case __NR_dup3: | 341 case __NR_dup3: |
| 331 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) | 342 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ |
| 343 defined(__aarch64__) |
| 332 case __NR_shutdown: | 344 case __NR_shutdown: |
| 333 #endif | 345 #endif |
| 334 return true; | 346 return true; |
| 335 case __NR_fcntl: | 347 case __NR_fcntl: |
| 336 #if defined(__i386__) || defined(__arm__) || defined(__mips__) | 348 #if defined(__i386__) || defined(__arm__) || defined(__mips__) |
| 337 case __NR_fcntl64: | 349 case __NR_fcntl64: |
| 338 #endif | 350 #endif |
| 339 default: | 351 default: |
| 340 return false; | 352 return false; |
| 341 } | 353 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 359 case __NR_exit: | 371 case __NR_exit: |
| 360 case __NR_exit_group: | 372 case __NR_exit_group: |
| 361 case __NR_wait4: | 373 case __NR_wait4: |
| 362 case __NR_waitid: | 374 case __NR_waitid: |
| 363 #if defined(__i386__) | 375 #if defined(__i386__) |
| 364 case __NR_waitpid: | 376 case __NR_waitpid: |
| 365 #endif | 377 #endif |
| 366 return true; | 378 return true; |
| 367 case __NR_clone: // Should be parameter-restricted. | 379 case __NR_clone: // Should be parameter-restricted. |
| 368 case __NR_setns: // Privileged. | 380 case __NR_setns: // Privileged. |
| 381 #if !defined(__aarch64__) |
| 369 case __NR_fork: | 382 case __NR_fork: |
| 383 #endif |
| 370 #if defined(__i386__) || defined(__x86_64__) | 384 #if defined(__i386__) || defined(__x86_64__) |
| 371 case __NR_get_thread_area: | 385 case __NR_get_thread_area: |
| 372 #endif | 386 #endif |
| 373 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) | 387 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) |
| 374 case __NR_set_thread_area: | 388 case __NR_set_thread_area: |
| 375 #endif | 389 #endif |
| 376 case __NR_set_tid_address: | 390 case __NR_set_tid_address: |
| 377 case __NR_unshare: | 391 case __NR_unshare: |
| 378 #if !defined(__mips__) | 392 #if !defined(__mips__) && !defined(__aarch64__) |
| 379 case __NR_vfork: | 393 case __NR_vfork: |
| 380 #endif | 394 #endif |
| 381 default: | 395 default: |
| 382 return false; | 396 return false; |
| 383 } | 397 } |
| 384 } | 398 } |
| 385 | 399 |
| 386 // It's difficult to restrict those, but there is attack surface here. | 400 // It's difficult to restrict those, but there is attack surface here. |
| 387 bool SyscallSets::IsAllowedFutex(int sysno) { | 401 bool SyscallSets::IsAllowedFutex(int sysno) { |
| 388 switch (sysno) { | 402 switch (sysno) { |
| 389 case __NR_get_robust_list: | 403 case __NR_get_robust_list: |
| 390 case __NR_set_robust_list: | 404 case __NR_set_robust_list: |
| 391 return true; | 405 return true; |
| 392 case __NR_futex: | 406 case __NR_futex: |
| 393 default: | 407 default: |
| 394 return false; | 408 return false; |
| 395 } | 409 } |
| 396 } | 410 } |
| 397 | 411 |
| 398 bool SyscallSets::IsAllowedEpoll(int sysno) { | 412 bool SyscallSets::IsAllowedEpoll(int sysno) { |
| 399 switch (sysno) { | 413 switch (sysno) { |
| 414 #if !defined(__aarch64__) |
| 400 case __NR_epoll_create: | 415 case __NR_epoll_create: |
| 416 case __NR_epoll_wait: |
| 417 #endif |
| 401 case __NR_epoll_create1: | 418 case __NR_epoll_create1: |
| 402 case __NR_epoll_ctl: | 419 case __NR_epoll_ctl: |
| 403 case __NR_epoll_wait: | |
| 404 return true; | 420 return true; |
| 405 default: | 421 default: |
| 406 #if defined(__x86_64__) | 422 #if defined(__x86_64__) |
| 407 case __NR_epoll_ctl_old: | 423 case __NR_epoll_ctl_old: |
| 408 #endif | 424 #endif |
| 409 case __NR_epoll_pwait: | 425 case __NR_epoll_pwait: |
| 410 #if defined(__x86_64__) | 426 #if defined(__x86_64__) |
| 411 case __NR_epoll_wait_old: | 427 case __NR_epoll_wait_old: |
| 412 #endif | 428 #endif |
| 413 return false; | 429 return false; |
| 414 } | 430 } |
| 415 } | 431 } |
| 416 | 432 |
| 417 bool SyscallSets::IsAllowedGetOrModifySocket(int sysno) { | 433 bool SyscallSets::IsAllowedGetOrModifySocket(int sysno) { |
| 418 switch (sysno) { | 434 switch (sysno) { |
| 435 #if !defined(__aarch64__) |
| 419 case __NR_pipe: | 436 case __NR_pipe: |
| 437 #endif |
| 420 case __NR_pipe2: | 438 case __NR_pipe2: |
| 421 return true; | 439 return true; |
| 422 default: | 440 default: |
| 423 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) | 441 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ |
| 442 defined(__aarch64__) |
| 424 case __NR_socketpair: // We will want to inspect its argument. | 443 case __NR_socketpair: // We will want to inspect its argument. |
| 425 #endif | 444 #endif |
| 426 return false; | 445 return false; |
| 427 } | 446 } |
| 428 } | 447 } |
| 429 | 448 |
| 430 bool SyscallSets::IsDeniedGetOrModifySocket(int sysno) { | 449 bool SyscallSets::IsDeniedGetOrModifySocket(int sysno) { |
| 431 switch (sysno) { | 450 switch (sysno) { |
| 432 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) | 451 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ |
| 452 defined(__aarch64__) |
| 433 case __NR_accept: | 453 case __NR_accept: |
| 434 case __NR_accept4: | 454 case __NR_accept4: |
| 435 case __NR_bind: | 455 case __NR_bind: |
| 436 case __NR_connect: | 456 case __NR_connect: |
| 437 case __NR_socket: | 457 case __NR_socket: |
| 438 case __NR_listen: | 458 case __NR_listen: |
| 439 return true; | 459 return true; |
| 440 #endif | 460 #endif |
| 441 default: | 461 default: |
| 442 return false; | 462 return false; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 472 bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) { | 492 bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) { |
| 473 switch (sysno) { | 493 switch (sysno) { |
| 474 case __NR_brk: | 494 case __NR_brk: |
| 475 case __NR_mlock: | 495 case __NR_mlock: |
| 476 case __NR_munlock: | 496 case __NR_munlock: |
| 477 case __NR_munmap: | 497 case __NR_munmap: |
| 478 return true; | 498 return true; |
| 479 case __NR_madvise: | 499 case __NR_madvise: |
| 480 case __NR_mincore: | 500 case __NR_mincore: |
| 481 case __NR_mlockall: | 501 case __NR_mlockall: |
| 482 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) | 502 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ |
| 503 defined(__aarch64__) |
| 483 case __NR_mmap: | 504 case __NR_mmap: |
| 484 #endif | 505 #endif |
| 485 #if defined(__i386__) || defined(__arm__) || defined(__mips__) | 506 #if defined(__i386__) || defined(__arm__) || defined(__mips__) |
| 486 case __NR_mmap2: | 507 case __NR_mmap2: |
| 487 #endif | 508 #endif |
| 488 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) | 509 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) |
| 489 case __NR_modify_ldt: | 510 case __NR_modify_ldt: |
| 490 #endif | 511 #endif |
| 491 case __NR_mprotect: | 512 case __NR_mprotect: |
| 492 case __NR_mremap: | 513 case __NR_mremap: |
| 493 case __NR_msync: | 514 case __NR_msync: |
| 494 case __NR_munlockall: | 515 case __NR_munlockall: |
| 495 case __NR_readahead: | 516 case __NR_readahead: |
| 496 case __NR_remap_file_pages: | 517 case __NR_remap_file_pages: |
| 497 #if defined(__i386__) | 518 #if defined(__i386__) |
| 498 case __NR_vm86: | 519 case __NR_vm86: |
| 499 case __NR_vm86old: | 520 case __NR_vm86old: |
| 500 #endif | 521 #endif |
| 501 default: | 522 default: |
| 502 return false; | 523 return false; |
| 503 } | 524 } |
| 504 } | 525 } |
| 505 | 526 |
| 506 bool SyscallSets::IsAllowedGeneralIo(int sysno) { | 527 bool SyscallSets::IsAllowedGeneralIo(int sysno) { |
| 507 switch (sysno) { | 528 switch (sysno) { |
| 508 case __NR_lseek: | 529 case __NR_lseek: |
| 509 #if defined(__i386__) || defined(__arm__) || defined(__mips__) | 530 #if defined(__i386__) || defined(__arm__) || defined(__mips__) |
| 510 case __NR__llseek: | 531 case __NR__llseek: |
| 511 #endif | 532 #endif |
| 533 #if !defined(__aarch64__) |
| 512 case __NR_poll: | 534 case __NR_poll: |
| 535 #endif |
| 513 case __NR_ppoll: | 536 case __NR_ppoll: |
| 514 case __NR_pselect6: | 537 case __NR_pselect6: |
| 515 case __NR_read: | 538 case __NR_read: |
| 516 case __NR_readv: | 539 case __NR_readv: |
| 517 #if defined(__arm__) || defined(__mips__) | 540 #if defined(__arm__) || defined(__mips__) |
| 518 case __NR_recv: | 541 case __NR_recv: |
| 519 #endif | 542 #endif |
| 520 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) | 543 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ |
| 544 defined(__aarch64__) |
| 521 case __NR_recvfrom: // Could specify source. | 545 case __NR_recvfrom: // Could specify source. |
| 522 case __NR_recvmsg: // Could specify source. | 546 case __NR_recvmsg: // Could specify source. |
| 523 #endif | 547 #endif |
| 524 #if defined(__i386__) || defined(__x86_64__) | 548 #if defined(__i386__) || defined(__x86_64__) |
| 525 case __NR_select: | 549 case __NR_select: |
| 526 #endif | 550 #endif |
| 527 #if defined(__i386__) || defined(__arm__) || defined(__mips__) | 551 #if defined(__i386__) || defined(__arm__) || defined(__mips__) |
| 528 case __NR__newselect: | 552 case __NR__newselect: |
| 529 #endif | 553 #endif |
| 530 #if defined(__arm__) | 554 #if defined(__arm__) |
| 531 case __NR_send: | 555 case __NR_send: |
| 532 #endif | 556 #endif |
| 533 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) | 557 #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \ |
| 558 defined(__aarch64__) |
| 534 case __NR_sendmsg: // Could specify destination. | 559 case __NR_sendmsg: // Could specify destination. |
| 535 case __NR_sendto: // Could specify destination. | 560 case __NR_sendto: // Could specify destination. |
| 536 #endif | 561 #endif |
| 537 case __NR_write: | 562 case __NR_write: |
| 538 case __NR_writev: | 563 case __NR_writev: |
| 539 return true; | 564 return true; |
| 540 case __NR_ioctl: // Can be very powerful. | 565 case __NR_ioctl: // Can be very powerful. |
| 541 case __NR_pread64: | 566 case __NR_pread64: |
| 542 case __NR_preadv: | 567 case __NR_preadv: |
| 543 case __NR_pwrite64: | 568 case __NR_pwrite64: |
| (...skipping 29 matching lines...) Expand all Loading... |
| 573 case __NR_seccomp: | 598 case __NR_seccomp: |
| 574 return true; | 599 return true; |
| 575 default: | 600 default: |
| 576 return false; | 601 return false; |
| 577 } | 602 } |
| 578 } | 603 } |
| 579 | 604 |
| 580 bool SyscallSets::IsAllowedBasicScheduler(int sysno) { | 605 bool SyscallSets::IsAllowedBasicScheduler(int sysno) { |
| 581 switch (sysno) { | 606 switch (sysno) { |
| 582 case __NR_sched_yield: | 607 case __NR_sched_yield: |
| 608 #if !defined(__aarch64__) |
| 583 case __NR_pause: | 609 case __NR_pause: |
| 610 #endif |
| 584 case __NR_nanosleep: | 611 case __NR_nanosleep: |
| 585 return true; | 612 return true; |
| 586 case __NR_getpriority: | 613 case __NR_getpriority: |
| 587 #if defined(__i386__) || defined(__arm__) || defined(__mips__) | 614 #if defined(__i386__) || defined(__arm__) || defined(__mips__) |
| 588 case __NR_nice: | 615 case __NR_nice: |
| 589 #endif | 616 #endif |
| 590 case __NR_setpriority: | 617 case __NR_setpriority: |
| 591 default: | 618 default: |
| 592 return false; | 619 return false; |
| 593 } | 620 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 default: | 678 default: |
| 652 return false; | 679 return false; |
| 653 } | 680 } |
| 654 } | 681 } |
| 655 | 682 |
| 656 bool SyscallSets::IsNuma(int sysno) { | 683 bool SyscallSets::IsNuma(int sysno) { |
| 657 switch (sysno) { | 684 switch (sysno) { |
| 658 case __NR_get_mempolicy: | 685 case __NR_get_mempolicy: |
| 659 case __NR_getcpu: | 686 case __NR_getcpu: |
| 660 case __NR_mbind: | 687 case __NR_mbind: |
| 661 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) | 688 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ |
| 689 defined(__aarch64__) |
| 662 case __NR_migrate_pages: | 690 case __NR_migrate_pages: |
| 663 #endif | 691 #endif |
| 664 case __NR_move_pages: | 692 case __NR_move_pages: |
| 665 case __NR_set_mempolicy: | 693 case __NR_set_mempolicy: |
| 666 return true; | 694 return true; |
| 667 default: | 695 default: |
| 668 return false; | 696 return false; |
| 669 } | 697 } |
| 670 } | 698 } |
| 671 | 699 |
| 672 bool SyscallSets::IsMessageQueue(int sysno) { | 700 bool SyscallSets::IsMessageQueue(int sysno) { |
| 673 switch (sysno) { | 701 switch (sysno) { |
| 674 case __NR_mq_getsetattr: | 702 case __NR_mq_getsetattr: |
| 675 case __NR_mq_notify: | 703 case __NR_mq_notify: |
| 676 case __NR_mq_open: | 704 case __NR_mq_open: |
| 677 case __NR_mq_timedreceive: | 705 case __NR_mq_timedreceive: |
| 678 case __NR_mq_timedsend: | 706 case __NR_mq_timedsend: |
| 679 case __NR_mq_unlink: | 707 case __NR_mq_unlink: |
| 680 return true; | 708 return true; |
| 681 default: | 709 default: |
| 682 return false; | 710 return false; |
| 683 } | 711 } |
| 684 } | 712 } |
| 685 | 713 |
| 686 bool SyscallSets::IsGlobalProcessEnvironment(int sysno) { | 714 bool SyscallSets::IsGlobalProcessEnvironment(int sysno) { |
| 687 switch (sysno) { | 715 switch (sysno) { |
| 688 case __NR_acct: // Privileged. | 716 case __NR_acct: // Privileged. |
| 689 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) | 717 #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \ |
| 718 defined(__aarch64__) |
| 690 case __NR_getrlimit: | 719 case __NR_getrlimit: |
| 691 #endif | 720 #endif |
| 692 #if defined(__i386__) || defined(__arm__) | 721 #if defined(__i386__) || defined(__arm__) |
| 693 case __NR_ugetrlimit: | 722 case __NR_ugetrlimit: |
| 694 #endif | 723 #endif |
| 695 #if defined(__i386__) || defined(__mips__) | 724 #if defined(__i386__) || defined(__mips__) |
| 696 case __NR_ulimit: | 725 case __NR_ulimit: |
| 697 #endif | 726 #endif |
| 698 case __NR_getrusage: | 727 case __NR_getrusage: |
| 699 case __NR_personality: // Can change its personality as well. | 728 case __NR_personality: // Can change its personality as well. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 713 case __NR_process_vm_writev: | 742 case __NR_process_vm_writev: |
| 714 case __NR_kcmp: | 743 case __NR_kcmp: |
| 715 return true; | 744 return true; |
| 716 default: | 745 default: |
| 717 return false; | 746 return false; |
| 718 } | 747 } |
| 719 } | 748 } |
| 720 | 749 |
| 721 bool SyscallSets::IsGlobalSystemStatus(int sysno) { | 750 bool SyscallSets::IsGlobalSystemStatus(int sysno) { |
| 722 switch (sysno) { | 751 switch (sysno) { |
| 752 #if !defined(__aarch64__) |
| 723 case __NR__sysctl: | 753 case __NR__sysctl: |
| 724 case __NR_sysfs: | 754 case __NR_sysfs: |
| 755 #endif |
| 725 case __NR_sysinfo: | 756 case __NR_sysinfo: |
| 726 case __NR_uname: | 757 case __NR_uname: |
| 727 #if defined(__i386__) | 758 #if defined(__i386__) |
| 728 case __NR_olduname: | 759 case __NR_olduname: |
| 729 case __NR_oldolduname: | 760 case __NR_oldolduname: |
| 730 #endif | 761 #endif |
| 731 return true; | 762 return true; |
| 732 default: | 763 default: |
| 733 return false; | 764 return false; |
| 734 } | 765 } |
| 735 } | 766 } |
| 736 | 767 |
| 737 bool SyscallSets::IsEventFd(int sysno) { | 768 bool SyscallSets::IsEventFd(int sysno) { |
| 738 switch (sysno) { | 769 switch (sysno) { |
| 770 #if !defined(__aarch64__) |
| 739 case __NR_eventfd: | 771 case __NR_eventfd: |
| 772 #endif |
| 740 case __NR_eventfd2: | 773 case __NR_eventfd2: |
| 741 return true; | 774 return true; |
| 742 default: | 775 default: |
| 743 return false; | 776 return false; |
| 744 } | 777 } |
| 745 } | 778 } |
| 746 | 779 |
| 747 // Asynchronous I/O API. | 780 // Asynchronous I/O API. |
| 748 bool SyscallSets::IsAsyncIo(int sysno) { | 781 bool SyscallSets::IsAsyncIo(int sysno) { |
| 749 switch (sysno) { | 782 switch (sysno) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 762 switch (sysno) { | 795 switch (sysno) { |
| 763 case __NR_add_key: | 796 case __NR_add_key: |
| 764 case __NR_keyctl: | 797 case __NR_keyctl: |
| 765 case __NR_request_key: | 798 case __NR_request_key: |
| 766 return true; | 799 return true; |
| 767 default: | 800 default: |
| 768 return false; | 801 return false; |
| 769 } | 802 } |
| 770 } | 803 } |
| 771 | 804 |
| 772 #if defined(__x86_64__) || defined(__arm__) | 805 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) |
| 773 bool SyscallSets::IsSystemVSemaphores(int sysno) { | 806 bool SyscallSets::IsSystemVSemaphores(int sysno) { |
| 774 switch (sysno) { | 807 switch (sysno) { |
| 775 case __NR_semctl: | 808 case __NR_semctl: |
| 776 case __NR_semget: | 809 case __NR_semget: |
| 777 case __NR_semop: | 810 case __NR_semop: |
| 778 case __NR_semtimedop: | 811 case __NR_semtimedop: |
| 779 return true; | 812 return true; |
| 780 default: | 813 default: |
| 781 return false; | 814 return false; |
| 782 } | 815 } |
| 783 } | 816 } |
| 784 #endif | 817 #endif |
| 785 | 818 |
| 786 #if defined(__x86_64__) || defined(__arm__) | 819 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) |
| 787 // These give a lot of ambient authority and bypass the setuid sandbox. | 820 // These give a lot of ambient authority and bypass the setuid sandbox. |
| 788 bool SyscallSets::IsSystemVSharedMemory(int sysno) { | 821 bool SyscallSets::IsSystemVSharedMemory(int sysno) { |
| 789 switch (sysno) { | 822 switch (sysno) { |
| 790 case __NR_shmat: | 823 case __NR_shmat: |
| 791 case __NR_shmctl: | 824 case __NR_shmctl: |
| 792 case __NR_shmdt: | 825 case __NR_shmdt: |
| 793 case __NR_shmget: | 826 case __NR_shmget: |
| 794 return true; | 827 return true; |
| 795 default: | 828 default: |
| 796 return false; | 829 return false; |
| 797 } | 830 } |
| 798 } | 831 } |
| 799 #endif | 832 #endif |
| 800 | 833 |
| 801 #if defined(__x86_64__) || defined(__arm__) | 834 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) |
| 802 bool SyscallSets::IsSystemVMessageQueue(int sysno) { | 835 bool SyscallSets::IsSystemVMessageQueue(int sysno) { |
| 803 switch (sysno) { | 836 switch (sysno) { |
| 804 case __NR_msgctl: | 837 case __NR_msgctl: |
| 805 case __NR_msgget: | 838 case __NR_msgget: |
| 806 case __NR_msgrcv: | 839 case __NR_msgrcv: |
| 807 case __NR_msgsnd: | 840 case __NR_msgsnd: |
| 808 return true; | 841 return true; |
| 809 default: | 842 default: |
| 810 return false; | 843 return false; |
| 811 } | 844 } |
| 812 } | 845 } |
| 813 #endif | 846 #endif |
| 814 | 847 |
| 815 #if defined(__i386__) || defined(__mips__) | 848 #if defined(__i386__) || defined(__mips__) |
| 816 // Big system V multiplexing system call. | 849 // Big system V multiplexing system call. |
| 817 bool SyscallSets::IsSystemVIpc(int sysno) { | 850 bool SyscallSets::IsSystemVIpc(int sysno) { |
| 818 switch (sysno) { | 851 switch (sysno) { |
| 819 case __NR_ipc: | 852 case __NR_ipc: |
| 820 return true; | 853 return true; |
| 821 default: | 854 default: |
| 822 return false; | 855 return false; |
| 823 } | 856 } |
| 824 } | 857 } |
| 825 #endif | 858 #endif |
| 826 | 859 |
| 827 bool SyscallSets::IsAnySystemV(int sysno) { | 860 bool SyscallSets::IsAnySystemV(int sysno) { |
| 828 #if defined(__x86_64__) || defined(__arm__) | 861 #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) |
| 829 return IsSystemVMessageQueue(sysno) || IsSystemVSemaphores(sysno) || | 862 return IsSystemVMessageQueue(sysno) || IsSystemVSemaphores(sysno) || |
| 830 IsSystemVSharedMemory(sysno); | 863 IsSystemVSharedMemory(sysno); |
| 831 #elif defined(__i386__) || defined(__mips__) | 864 #elif defined(__i386__) || defined(__mips__) |
| 832 return IsSystemVIpc(sysno); | 865 return IsSystemVIpc(sysno); |
| 833 #endif | 866 #endif |
| 834 } | 867 } |
| 835 | 868 |
| 836 bool SyscallSets::IsAdvancedScheduler(int sysno) { | 869 bool SyscallSets::IsAdvancedScheduler(int sysno) { |
| 837 switch (sysno) { | 870 switch (sysno) { |
| 838 case __NR_ioprio_get: // IO scheduler. | 871 case __NR_ioprio_get: // IO scheduler. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 850 case __NR_sched_setscheduler: | 883 case __NR_sched_setscheduler: |
| 851 return true; | 884 return true; |
| 852 default: | 885 default: |
| 853 return false; | 886 return false; |
| 854 } | 887 } |
| 855 } | 888 } |
| 856 | 889 |
| 857 bool SyscallSets::IsInotify(int sysno) { | 890 bool SyscallSets::IsInotify(int sysno) { |
| 858 switch (sysno) { | 891 switch (sysno) { |
| 859 case __NR_inotify_add_watch: | 892 case __NR_inotify_add_watch: |
| 893 #if !defined(__aarch64__) |
| 860 case __NR_inotify_init: | 894 case __NR_inotify_init: |
| 895 #endif |
| 861 case __NR_inotify_init1: | 896 case __NR_inotify_init1: |
| 862 case __NR_inotify_rm_watch: | 897 case __NR_inotify_rm_watch: |
| 863 return true; | 898 return true; |
| 864 default: | 899 default: |
| 865 return false; | 900 return false; |
| 866 } | 901 } |
| 867 } | 902 } |
| 868 | 903 |
| 869 bool SyscallSets::IsFaNotify(int sysno) { | 904 bool SyscallSets::IsFaNotify(int sysno) { |
| 870 switch (sysno) { | 905 switch (sysno) { |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 #endif | 995 #endif |
| 961 #if defined(__x86_64__) | 996 #if defined(__x86_64__) |
| 962 case __NR_security: | 997 case __NR_security: |
| 963 #endif | 998 #endif |
| 964 #if defined(__i386__) || defined(__mips__) | 999 #if defined(__i386__) || defined(__mips__) |
| 965 case __NR_stty: | 1000 case __NR_stty: |
| 966 #endif | 1001 #endif |
| 967 #if defined(__x86_64__) | 1002 #if defined(__x86_64__) |
| 968 case __NR_tuxcall: | 1003 case __NR_tuxcall: |
| 969 #endif | 1004 #endif |
| 1005 #if !defined(__aarch64__) |
| 970 case __NR_vserver: | 1006 case __NR_vserver: |
| 1007 #endif |
| 971 return true; | 1008 return true; |
| 972 default: | 1009 default: |
| 973 return false; | 1010 return false; |
| 974 } | 1011 } |
| 975 } | 1012 } |
| 976 | 1013 |
| 977 #if defined(__arm__) | 1014 #if defined(__arm__) |
| 978 bool SyscallSets::IsArmPciConfig(int sysno) { | 1015 bool SyscallSets::IsArmPciConfig(int sysno) { |
| 979 switch (sysno) { | 1016 switch (sysno) { |
| 980 case __NR_pciconfig_iobase: | 1017 case __NR_pciconfig_iobase: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 switch (sysno) { | 1052 switch (sysno) { |
| 1016 case __NR_sysmips: | 1053 case __NR_sysmips: |
| 1017 case __NR_unused150: | 1054 case __NR_unused150: |
| 1018 return true; | 1055 return true; |
| 1019 default: | 1056 default: |
| 1020 return false; | 1057 return false; |
| 1021 } | 1058 } |
| 1022 } | 1059 } |
| 1023 #endif // defined(__mips__) | 1060 #endif // defined(__mips__) |
| 1024 } // namespace sandbox. | 1061 } // namespace sandbox. |
| OLD | NEW |