aboutsummaryrefslogtreecommitdiffstats
path: root/community/chromium/musl-sandbox.patch
blob: 4414670cbaf3064df2c674a1439b3bc9f4028082 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--- ./sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
+++ ./sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
@@ -114,23 +114,13 @@
 // CLONE_VM, nor CLONE_THREAD, which includes all fork() implementations.
 ResultExpr RestrictCloneToThreadsAndEPERMFork() {
   const Arg<unsigned long> flags(0);
+  const int required = CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
+                       CLONE_THREAD | CLONE_SYSVSEM;
+  const int safe = CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID |
+                   CLONE_DETACHED;
+  const BoolExpr thread_clone_ok = (flags&~safe)==required;
 
-  // TODO(mdempsky): Extend DSL to support (flags & ~mask1) == mask2.
-  const uint64_t kAndroidCloneMask = CLONE_VM | CLONE_FS | CLONE_FILES |
-                                     CLONE_SIGHAND | CLONE_THREAD |
-                                     CLONE_SYSVSEM;
-  const uint64_t kObsoleteAndroidCloneMask = kAndroidCloneMask | CLONE_DETACHED;
-
-  const uint64_t kGlibcPthreadFlags =
-      CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_THREAD |
-      CLONE_SYSVSEM | CLONE_SETTLS | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID;
-  const BoolExpr glibc_test = flags == kGlibcPthreadFlags;
-
-  const BoolExpr android_test =
-      AnyOf(flags == kAndroidCloneMask, flags == kObsoleteAndroidCloneMask,
-            flags == kGlibcPthreadFlags);
-
-  return If(IsAndroid() ? android_test : glibc_test, Allow())
+  return If(thread_clone_ok, Allow())
       .ElseIf((flags & (CLONE_VM | CLONE_THREAD)) == 0, Error(EPERM))
       .Else(CrashSIGSYSClone());
 }
--- ./sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc.orig
+++ ./sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
@@ -494,6 +494,7 @@
     case __NR_mlock:
     case __NR_munlock:
     case __NR_munmap:
+    case __NR_mremap:
       return true;
     case __NR_madvise:
     case __NR_mincore:
@@ -509,7 +510,6 @@
     case __NR_modify_ldt:
 #endif
     case __NR_mprotect:
-    case __NR_mremap:
     case __NR_msync:
     case __NR_munlockall:
     case __NR_readahead: