OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <asm/unistd.h> | 5 #include <asm/unistd.h> |
6 #include <dlfcn.h> | 6 #include <dlfcn.h> |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <linux/audit.h> | 9 #include <linux/audit.h> |
10 #include <linux/filter.h> | 10 #include <linux/filter.h> |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 } | 194 } |
195 } | 195 } |
196 | 196 |
197 // System calls that directly access the file system. They might aquire | 197 // System calls that directly access the file system. They might aquire |
198 // a new file descriptor or otherwise perform an operation directly | 198 // a new file descriptor or otherwise perform an operation directly |
199 // via a path. | 199 // via a path. |
200 // For many, EPERM is a valid errno, but not for all of them. | 200 // For many, EPERM is a valid errno, but not for all of them. |
201 bool IsFileSystemSyscall(int sysno) { | 201 bool IsFileSystemSyscall(int sysno) { |
202 switch (sysno) { | 202 switch (sysno) { |
203 case __NR_access: | 203 case __NR_access: |
204 // case __NR_chmod: | 204 case __NR_chmod: |
jln (very slow on Chromium)
2012/08/08 01:29:57
All of these will ENOENT. I have a TODO to return
| |
205 // case __NR_chown: | 205 case __NR_chown: |
206 // case __NR_creat: | 206 case __NR_creat: |
207 case __NR_execve: | 207 case __NR_execve: |
208 // case __NR_faccessat: | 208 case __NR_faccessat: |
209 // case __NR_fchmodat: | 209 case __NR_fchmodat: |
210 // case __NR_fchownat: // Should be called chownat ? | 210 case __NR_fchownat: // Should be called chownat ? |
211 // case __NR_futimesat: // Should be called utimesat ? | 211 case __NR_futimesat: // Should be called utimesat ? |
212 // case __NR_getdents: | 212 case __NR_getdents: |
213 // case __NR_getdents64: | 213 case __NR_getdents64: |
214 // case __NR_lchown: | 214 case __NR_lchown: |
215 // case __NR_link: | 215 case __NR_link: |
216 // case __NR_linkat: | 216 case __NR_linkat: |
217 // case __NR_lookup_dcookie: | 217 case __NR_lookup_dcookie: |
218 case __NR_lstat: | 218 case __NR_lstat: |
219 case __NR_mkdir: | 219 case __NR_mkdir: |
220 case __NR_mkdirat: | 220 case __NR_mkdirat: |
221 case __NR_mknod: | 221 case __NR_mknod: |
222 case __NR_mknodat: | 222 case __NR_mknodat: |
223 // case __NR_newfstatat: // Should be called statat ? | 223 case __NR_newfstatat: // Should be called statat ? |
224 case __NR_open: | 224 case __NR_open: |
225 case __NR_openat: | 225 case __NR_openat: |
226 case __NR_readlink: | 226 case __NR_readlink: |
227 case __NR_readlinkat: | 227 case __NR_readlinkat: |
228 // case __NR_rename: | 228 case __NR_rename: |
229 // case __NR_renameat: | 229 case __NR_renameat: |
230 // case __NR_rmdir: | 230 case __NR_rmdir: |
231 case __NR_stat: | 231 case __NR_stat: |
232 // case __NR_statfs: | 232 case __NR_statfs: |
233 // case __NR_symlink: | 233 case __NR_symlink: |
234 // case __NR_symlinkat: | 234 case __NR_symlinkat: |
235 // case __NR_truncate: | 235 case __NR_truncate: |
236 // case __NR_unlink: | 236 case __NR_unlink: |
237 // case __NR_unlinkat: | 237 case __NR_unlinkat: |
238 // case __NR_uselib: | 238 case __NR_uselib: |
239 // case __NR_ustat: // Deprecated. | 239 case __NR_ustat: // Deprecated. |
240 // case __NR_utime: | 240 case __NR_utime: |
241 // case __NR_utimensat: // New. | 241 case __NR_utimensat: // New. |
242 // case __NR_utimes: | 242 case __NR_utimes: |
243 return true; | 243 return true; |
244 default: | 244 default: |
245 return false; | 245 return false; |
246 } | 246 } |
247 } | 247 } |
248 | 248 |
249 // TODO(jln): these should be denied gracefully as well. | |
249 bool IsAllowedFileSystemCapabilitySyscall(int sysno) { | 250 bool IsAllowedFileSystemCapabilitySyscall(int sysno) { |
250 switch (sysno) { | 251 switch (sysno) { |
251 // case __NR_fadvise64: | 252 // case __NR_fadvise64: |
252 // case __NR_flock: | 253 // case __NR_flock: |
253 case __NR_fstat: | 254 case __NR_fstat: |
254 // case __NR_fsatfs: // Give information about the whole filesystem. | 255 // case __NR_fsatfs: // Give information about the whole filesystem. |
255 // case __NR_fsync: | 256 // case __NR_fsync: |
256 // case __NR_fdatasync: | 257 // case __NR_fdatasync: |
257 // case __NR_sync_file_range: | 258 // case __NR_sync_file_range: |
258 return true; | 259 return true; |
260 default: | |
261 return false; | |
262 } | |
263 } | |
264 | |
265 // EPERM is a good errno for any of these. | |
266 bool IsDeniedFileSystemCapabilitySyscall(int sysno) { | |
267 switch (sysno) { | |
259 case __NR_fallocate: | 268 case __NR_fallocate: |
260 case __NR_fchmod: | 269 case __NR_fchmod: |
261 case __NR_fchown: | 270 case __NR_fchown: |
262 case __NR_ftruncate: | 271 case __NR_ftruncate: |
272 return true; | |
263 default: | 273 default: |
264 return false; | 274 return false; |
265 } | 275 } |
266 } | 276 } |
267 | 277 |
268 bool IsGetProcessIdSyscall(int sysno) { | 278 bool IsGetProcessIdSyscall(int sysno) { |
269 switch (sysno) { | 279 switch (sysno) { |
270 // case __NR_capget: | 280 // case __NR_capget: |
271 case __NR_getegid: | 281 case __NR_getegid: |
272 case __NR_geteuid: | 282 case __NR_geteuid: |
273 case __NR_getgid: | 283 case __NR_getgid: |
274 // case __NR_getgroups: | 284 case __NR_getgroups: |
jln (very slow on Chromium)
2012/08/08 01:29:57
None of these should cause any problem.
| |
275 // case __NR_getpid: | 285 case __NR_getpid: |
276 // case __NR_getppid: | 286 case __NR_getppid: |
277 // case __NR_getresgid: | 287 case __NR_getresgid: |
278 // case __NR_getresuid: | 288 case __NR_getresuid: |
279 // case __NR_getsid: | 289 case __NR_getsid: |
280 case __NR_gettid: | 290 case __NR_gettid: |
281 case __NR_getuid: | 291 case __NR_getuid: |
282 return true; | 292 return true; |
283 default: | 293 default: |
284 return false; | 294 return false; |
285 } | 295 } |
286 } | 296 } |
287 | 297 |
288 bool IsProcessPrivilegeChange(int sysno) { | 298 bool IsProcessPrivilegeChange(int sysno) { |
289 switch (sysno) { | 299 switch (sysno) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
333 return true; | 343 return true; |
334 default: | 344 default: |
335 return false; | 345 return false; |
336 } | 346 } |
337 } | 347 } |
338 | 348 |
339 bool IsOperationOnFd(int sysno) { | 349 bool IsOperationOnFd(int sysno) { |
340 switch (sysno) { | 350 switch (sysno) { |
341 case __NR_close: | 351 case __NR_close: |
342 case __NR_dup: | 352 case __NR_dup: |
343 // case __NR_dup2: | 353 case __NR_dup2: |
jln (very slow on Chromium)
2012/08/08 01:29:57
This adds very little attack surface and makes us
| |
344 // case __NR_dup3: | 354 case __NR_dup3: |
345 case __NR_fcntl: | 355 case __NR_fcntl: |
346 case __NR_shutdown: | 356 case __NR_shutdown: |
347 return true; | 357 return true; |
348 default: | 358 default: |
349 return false; | 359 return false; |
350 } | 360 } |
351 } | 361 } |
352 | 362 |
353 bool IsKernelInteralApi(int sysno) { | 363 bool IsKernelInteralApi(int sysno) { |
354 switch (sysno) { | 364 switch (sysno) { |
355 case __NR_restart_syscall: | 365 case __NR_restart_syscall: |
356 return true; | 366 return true; |
357 default: | 367 default: |
358 return false; | 368 return false; |
359 } | 369 } |
360 } | 370 } |
361 | 371 |
362 bool IsAllowedProcessStartOrDeath(int sysno) { | 372 bool IsAllowedProcessStartOrDeath(int sysno) { |
363 switch (sysno) { | 373 switch (sysno) { |
364 case __NR_clone: // TODO(jln): restrict flags. | 374 case __NR_clone: // TODO(jln): restrict flags. |
365 case __NR_exit: | 375 case __NR_exit: |
366 case __NR_exit_group: | 376 case __NR_exit_group: |
367 // case __NR_fork: | 377 // case __NR_fork: |
368 // case __NR_get_thread_area: | 378 // case __NR_get_thread_area: |
369 // case __NR_set_thread_area: | 379 // case __NR_set_thread_area: |
370 // case __NR_set_tid_address: | 380 // case __NR_set_tid_address: |
371 // case __NR_unshare: | 381 // case __NR_unshare: |
372 // case __NR_vfork: | 382 // case __NR_vfork: |
373 // case __NR_wait4: | 383 case __NR_wait4: |
jln (very slow on Chromium)
2012/08/08 01:29:57
Adds very little attack surface and it's really th
Markus (顧孟勤)
2012/08/08 10:08:42
I tend to agree with your assessment about the att
jln (very slow on Chromium)
2012/08/08 18:57:28
Do you think I should put futex and the robust_lis
Markus (顧孟勤)
2012/08/08 21:55:35
That would probably work. It's not a perfect fit,
jln (very slow on Chromium)
2012/08/08 23:00:49
IsFutex is a relatively well-defined set so as a c
| |
374 // case __NR_waitid: | 384 case __NR_waitid: |
375 return true; | 385 return true; |
376 case __NR_setns: // Privileged. | 386 case __NR_setns: // Privileged. |
377 default: | 387 default: |
378 return false; | 388 return false; |
379 } | 389 } |
380 } | 390 } |
381 | 391 |
382 bool IsEpoll(int sysno) { | 392 bool IsEpoll(int sysno) { |
383 switch (sysno) { | 393 switch (sysno) { |
384 case __NR_epoll_create: | 394 case __NR_epoll_create: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 default: | 442 default: |
433 return false; | 443 return false; |
434 } | 444 } |
435 } | 445 } |
436 | 446 |
437 bool IsAddressSpaceAccess(int sysno) { | 447 bool IsAddressSpaceAccess(int sysno) { |
438 switch (sysno) { | 448 switch (sysno) { |
439 case __NR_brk: | 449 case __NR_brk: |
440 case __NR_madvise: | 450 case __NR_madvise: |
441 // case __NR_mincore: | 451 // case __NR_mincore: |
442 // case __NR_mlock: | 452 case __NR_mlock: |
jln (very slow on Chromium)
2012/08/08 01:29:57
little attack surface, and the amount of locked me
| |
443 // case __NR_mlockall: | 453 // case __NR_mlockall: |
444 case __NR_mmap: | 454 case __NR_mmap: |
445 // case __NR_modify_ldt: | 455 // case __NR_modify_ldt: |
446 case __NR_mprotect: | 456 case __NR_mprotect: |
447 // case __NR_mremap: | 457 // case __NR_mremap: |
448 // case __NR_msync: | 458 // case __NR_msync: |
449 // case __NR_munlock: | 459 case __NR_munlock: |
450 // case __NR_munlockall: | 460 // case __NR_munlockall: |
451 case __NR_munmap: | 461 case __NR_munmap: |
452 // case __NR_readahead: | 462 // case __NR_readahead: |
453 // case __NR_remap_file_pages: | 463 // case __NR_remap_file_pages: |
454 return true; | 464 return true; |
455 default: | 465 default: |
456 return false; | 466 return false; |
457 } | 467 } |
458 } | 468 } |
459 | 469 |
460 bool IsAllowedGeneralIo(int sysno) { | 470 bool IsAllowedGeneralIo(int sysno) { |
461 switch (sysno) { | 471 switch (sysno) { |
462 case __NR_lseek: | 472 case __NR_lseek: |
463 // case __NR_poll: | 473 case __NR_poll: |
464 // case __NR_ppoll: | 474 case __NR_ppoll: |
jln (very slow on Chromium)
2012/08/08 01:29:57
Some attack surface, but relatively well tested an
| |
465 // case __NR_pread64: | 475 // case __NR_pread64: |
466 // case __NR_preadv: | 476 // case __NR_preadv: |
467 // case __NR_pselect6: | 477 case __NR_pselect6: |
jln (very slow on Chromium)
2012/08/08 01:29:57
Same here.
| |
468 // case __NR_pwrite64: | 478 // case __NR_pwrite64: |
469 // case __NR_pwritev: | 479 // case __NR_pwritev: |
470 case __NR_read: | 480 case __NR_read: |
471 // case __NR_readv: | 481 case __NR_readv: |
472 // case __NR_recvfrom: // Could specify source. | 482 case __NR_recvfrom: // Could specify source. |
jln (very slow on Chromium)
2012/08/08 01:29:57
recvfrom allows to specify the source, but so does
| |
473 // case __NR_recvmmsg: // Could specify source. | 483 // case __NR_recvmmsg: // Could specify source. |
474 case __NR_recvmsg: // Could specify source. | 484 case __NR_recvmsg: // Could specify source. |
475 // case __NR_select: | 485 case __NR_select: |
476 // case __NR_sendfile: | 486 // case __NR_sendfile: |
477 // case __NR_sendmmsg: // Could specify destination. | 487 // case __NR_sendmmsg: // Could specify destination. |
478 case __NR_sendmsg: // Could specify destination. | 488 case __NR_sendmsg: // Could specify destination. |
479 // case __NR_sendto: // Could specify destination. | 489 case __NR_sendto: // Could specify destination. |
jln (very slow on Chromium)
2012/08/08 01:29:57
Same as for recvfrom: we allow sendmsg anyway.
Markus (顧孟勤)
2012/08/08 10:08:42
Allowing sendmsg() is pretty crazy. And yes, if yo
jln (very slow on Chromium)
2012/08/08 18:57:28
That might be something we'll want to broker out.
| |
480 // case __NR_splice: | 490 // case __NR_splice: |
481 // case __NR_tee: | 491 // case __NR_tee: |
482 // case __NR_vmsplice: | 492 // case __NR_vmsplice: |
483 case __NR_write: | 493 case __NR_write: |
484 // case __NR_writev: | 494 case __NR_writev: |
485 return true; | 495 return true; |
486 default: | 496 default: |
487 case __NR_ioctl: // Can be very powerful. | 497 case __NR_ioctl: // Can be very powerful. |
488 return false; | 498 return false; |
489 } | 499 } |
490 } | 500 } |
491 | 501 |
492 bool IsPrctl(int sysno) { | 502 bool IsPrctl(int sysno) { |
493 switch (sysno) { | 503 switch (sysno) { |
494 case __NR_prctl: | 504 case __NR_prctl: |
495 // case __NR_arch_prctl: | 505 // case __NR_arch_prctl: |
496 return true; | 506 return true; |
497 default: | 507 default: |
498 return false; | 508 return false; |
499 } | 509 } |
500 } | 510 } |
501 | 511 |
502 bool IsAllowedBasicScheduler(int sysno) { | 512 bool IsAllowedBasicScheduler(int sysno) { |
503 switch (sysno) { | 513 switch (sysno) { |
504 case __NR_sched_yield: | 514 case __NR_sched_yield: |
505 // case __NR_pause: | 515 case __NR_pause: |
jln (very slow on Chromium)
2012/08/08 01:29:57
harmless.
| |
506 // case __NR_nanosleep: | 516 case __NR_nanosleep: |
507 // case __NR_getpriority: | 517 // case __NR_getpriority: |
508 return true; | 518 return true; |
509 case __NR_setpriority: | 519 case __NR_setpriority: |
510 default: | 520 default: |
511 return false; | 521 return false; |
512 } | 522 } |
513 } | 523 } |
514 | 524 |
515 bool IsAdminOperation(int sysno) { | 525 bool IsAdminOperation(int sysno) { |
516 switch (sysno) { | 526 switch (sysno) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
626 case __NR_uname: | 636 case __NR_uname: |
627 return true; | 637 return true; |
628 default: | 638 default: |
629 return false; | 639 return false; |
630 } | 640 } |
631 } | 641 } |
632 | 642 |
633 bool IsEventFd(int sysno) { | 643 bool IsEventFd(int sysno) { |
634 switch (sysno) { | 644 switch (sysno) { |
635 case __NR_eventfd: | 645 case __NR_eventfd: |
636 // case __NR_eventfd2: | 646 case __NR_eventfd2: |
jln (very slow on Chromium)
2012/08/08 01:29:57
newest glibc actually uses eventfd2.
| |
637 return true; | 647 return true; |
638 default: | 648 default: |
639 return false; | 649 return false; |
640 } | 650 } |
641 } | 651 } |
642 | 652 |
643 // Asynchronous I/O API. | 653 // Asynchronous I/O API. |
644 bool IsAsyncIo(int sysno) { | 654 bool IsAsyncIo(int sysno) { |
645 switch (sysno) { | 655 switch (sysno) { |
646 case __NR_io_cancel: | 656 case __NR_io_cancel: |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
864 IsTimer(sysno)) { | 874 IsTimer(sysno)) { |
865 return true; | 875 return true; |
866 } else { | 876 } else { |
867 return false; | 877 return false; |
868 } | 878 } |
869 } | 879 } |
870 | 880 |
871 // x86_64 only because it references system calls that are multiplexed on IA32. | 881 // x86_64 only because it references system calls that are multiplexed on IA32. |
872 playground2::Sandbox::ErrorCode GpuProcessPolicy_x86_64(int sysno) { | 882 playground2::Sandbox::ErrorCode GpuProcessPolicy_x86_64(int sysno) { |
873 switch(sysno) { | 883 switch(sysno) { |
874 case __NR_getpid: // Nvidia binary driver. | |
875 case __NR_getppid: // ATI binary driver. | |
876 case __NR_ioctl: | 884 case __NR_ioctl: |
877 case __NR_mlock: | |
878 case __NR_munlock: | |
879 case __NR_poll: | |
880 case __NR_recvfrom: | |
881 case __NR_writev: | |
882 return playground2::Sandbox::SB_ALLOWED; | 885 return playground2::Sandbox::SB_ALLOWED; |
883 case __NR_socket: | 886 case __NR_socket: |
884 return EACCES; // Nvidia binary driver. | 887 return EACCES; // Nvidia binary driver. |
885 case __NR_fchmod: | |
886 return EPERM; // ATI binary driver. | |
887 case __NR_open: | 888 case __NR_open: |
888 // Accelerated video decode is enabled by default only on Chrome OS. | 889 // Accelerated video decode is enabled by default only on Chrome OS. |
889 if (IsAcceleratedVideoDecodeEnabled()) { | 890 if (IsAcceleratedVideoDecodeEnabled()) { |
890 // Accelerated video decode needs to open /dev/dri/card0, and | 891 // Accelerated video decode needs to open /dev/dri/card0, and |
891 // dup()'ing an already open file descriptor does not work. | 892 // dup()'ing an already open file descriptor does not work. |
892 // Allow open() even though it severely weakens the sandbox, | 893 // Allow open() even though it severely weakens the sandbox, |
893 // to test the sandboxing mechanism in general. | 894 // to test the sandboxing mechanism in general. |
894 // TODO(jorgelo): remove this once we solve the libva issue. | 895 // TODO(jorgelo): remove this once we solve the libva issue. |
895 return playground2::Sandbox::SB_ALLOWED; | 896 return playground2::Sandbox::SB_ALLOWED; |
896 } else { | 897 } else { |
897 // Hook open() in the GPU process to allow opening /etc/drirc, | 898 // Hook open() in the GPU process to allow opening /etc/drirc, |
898 // needed by Mesa. | 899 // needed by Mesa. |
899 // The hook needs dup(), lseek(), and close() to be allowed. | 900 // The hook needs dup(), lseek(), and close() to be allowed. |
900 return playground2::Sandbox::ErrorCode(GpuOpenSIGSYS_Handler, NULL); | 901 return playground2::Sandbox::ErrorCode(GpuOpenSIGSYS_Handler, NULL); |
901 } | 902 } |
902 default: | 903 default: |
903 if (IsGpuAndFlashPolicyAllowed_x86_64(sysno) || IsEventFd(sysno)) { | 904 if (IsGpuAndFlashPolicyAllowed_x86_64(sysno) || IsEventFd(sysno)) { |
904 return playground2::Sandbox::SB_ALLOWED; | 905 return playground2::Sandbox::SB_ALLOWED; |
905 } | 906 } |
906 // Generally, filename-based syscalls will fail with ENOENT to behave | 907 // Generally, filename-based syscalls will fail with ENOENT to behave |
907 // similarly to a possible future setuid sandbox. | 908 // similarly to a possible future setuid sandbox. |
909 // TODO(jln): some system calls in those sets are not supposed to | |
910 // return ENOENT. Return the appropriate error. | |
908 if (IsFileSystemSyscall(sysno) || IsAmbiantFileSystemSyscall(sysno)) { | 911 if (IsFileSystemSyscall(sysno) || IsAmbiantFileSystemSyscall(sysno)) { |
909 return ENOENT; | 912 return ENOENT; |
910 } | 913 } |
911 | 914 |
915 if (IsDeniedFileSystemCapabilitySyscall(sysno)) { | |
916 return EPERM; | |
917 } | |
918 | |
912 if (IsGpuAndFlashPolicyWatched_x86_64(sysno)) { | 919 if (IsGpuAndFlashPolicyWatched_x86_64(sysno)) { |
913 // Previously unseen syscalls. TODO(jln): some of these should | 920 // Previously unseen syscalls. TODO(jln): some of these should |
914 // be denied gracefully right away. | 921 // be denied gracefully right away. |
915 return playground2::Sandbox::ErrorCode(CrashSIGSYS_Handler, NULL); | 922 return playground2::Sandbox::ErrorCode(CrashSIGSYS_Handler, NULL); |
916 } | 923 } |
917 // In any other case crash the program with our SIGSYS handler | 924 // In any other case crash the program with our SIGSYS handler |
918 return playground2::Sandbox::ErrorCode(CrashSIGSYS_Handler, NULL); | 925 return playground2::Sandbox::ErrorCode(CrashSIGSYS_Handler, NULL); |
919 } | 926 } |
920 } | 927 } |
921 | 928 |
922 // x86_64 only because it references system calls that are multiplexed on IA32. | 929 // x86_64 only because it references system calls that are multiplexed on IA32. |
923 playground2::Sandbox::ErrorCode FlashProcessPolicy_x86_64(int sysno) { | 930 playground2::Sandbox::ErrorCode FlashProcessPolicy_x86_64(int sysno) { |
924 switch (sysno) { | 931 switch (sysno) { |
925 case __NR_sched_getaffinity: | 932 case __NR_sched_getaffinity: |
926 case __NR_sched_setscheduler: | 933 case __NR_sched_setscheduler: |
927 // These are under investigation, and hopefully not here for the long term. | 934 // These are under investigation, and hopefully not here for the long term. |
928 case __NR_times: | 935 case __NR_times: |
929 case __NR_wait4: | |
930 return playground2::Sandbox::SB_ALLOWED; | 936 return playground2::Sandbox::SB_ALLOWED; |
931 case __NR_ioctl: | 937 case __NR_ioctl: |
932 return ENOTTY; // Flash Access. | 938 return ENOTTY; // Flash Access. |
933 case __NR_socket: | 939 case __NR_socket: |
934 return EACCES; | 940 return EACCES; |
935 default: | 941 default: |
936 if (IsGpuAndFlashPolicyAllowed_x86_64(sysno) || | 942 if (IsGpuAndFlashPolicyAllowed_x86_64(sysno) || |
937 IsSystemVSharedMemory(sysno)) { | 943 IsSystemVSharedMemory(sysno)) { |
938 return playground2::Sandbox::SB_ALLOWED; | 944 return playground2::Sandbox::SB_ALLOWED; |
939 } | 945 } |
946 // TODO(jln): some system calls in those sets are not supposed to | |
947 // return ENOENT. Return the appropriate error. | |
940 if (IsFileSystemSyscall(sysno) || IsAmbiantFileSystemSyscall(sysno)) { | 948 if (IsFileSystemSyscall(sysno) || IsAmbiantFileSystemSyscall(sysno)) { |
941 return ENOENT; | 949 return ENOENT; |
942 } | 950 } |
951 | |
952 if (IsDeniedFileSystemCapabilitySyscall(sysno)) { | |
953 return EPERM; | |
954 } | |
955 | |
943 if (IsGpuAndFlashPolicyWatched_x86_64(sysno)) { | 956 if (IsGpuAndFlashPolicyWatched_x86_64(sysno)) { |
944 // Previously unseen syscalls. TODO(jln): some of these should | 957 // Previously unseen syscalls. TODO(jln): some of these should |
945 // be denied gracefully right away. | 958 // be denied gracefully right away. |
946 return playground2::Sandbox::ErrorCode(CrashSIGSYS_Handler, NULL); | 959 return playground2::Sandbox::ErrorCode(CrashSIGSYS_Handler, NULL); |
947 } | 960 } |
948 // In any other case crash the program with our SIGSYS handler. | 961 // In any other case crash the program with our SIGSYS handler. |
949 return playground2::Sandbox::ErrorCode(CrashSIGSYS_Handler, NULL); | 962 return playground2::Sandbox::ErrorCode(CrashSIGSYS_Handler, NULL); |
950 } | 963 } |
951 } | 964 } |
952 #endif | 965 #endif |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1095 // Process-specific policy. | 1108 // Process-specific policy. |
1096 ShouldEnableSeccompBpf(process_type) && | 1109 ShouldEnableSeccompBpf(process_type) && |
1097 SupportsSandbox()) { | 1110 SupportsSandbox()) { |
1098 return StartBpfSandbox_x86(command_line, process_type); | 1111 return StartBpfSandbox_x86(command_line, process_type); |
1099 } | 1112 } |
1100 #endif | 1113 #endif |
1101 return false; | 1114 return false; |
1102 } | 1115 } |
1103 | 1116 |
1104 } // namespace content | 1117 } // namespace content |
OLD | NEW |