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