Lines 135-141
Link Here
|
135 |
#if !defined(OS_NACL_NONSFI) |
135 |
#if !defined(OS_NACL_NONSFI) |
136 |
// Allow Glibc's and Android pthread creation flags, crash on any other |
136 |
// Allow Glibc's and Android pthread creation flags, crash on any other |
137 |
// thread creation attempts and EPERM attempts to use neither |
137 |
// thread creation attempts and EPERM attempts to use neither |
138 |
// CLONE_VM, nor CLONE_THREAD, which includes all fork() implementations. |
138 |
// CLONE_VM nor CLONE_THREAD (all fork implementations), unless CLONE_VFORK is |
|
|
139 |
// present (as in newer versions of posix_spawn). |
139 |
ResultExpr RestrictCloneToThreadsAndEPERMFork() { |
140 |
ResultExpr RestrictCloneToThreadsAndEPERMFork() { |
140 |
const Arg<unsigned long> flags(0); |
141 |
const Arg<unsigned long> flags(0); |
141 |
|
142 |
|
Lines 154-161
Link Here
|
154 |
AnyOf(flags == kAndroidCloneMask, flags == kObsoleteAndroidCloneMask, |
155 |
AnyOf(flags == kAndroidCloneMask, flags == kObsoleteAndroidCloneMask, |
155 |
flags == kGlibcPthreadFlags); |
156 |
flags == kGlibcPthreadFlags); |
156 |
|
157 |
|
|
|
158 |
// The following two flags are the two important flags in any vfork-emulating |
159 |
// clone call. EPERM any clone call that contains both of them. |
160 |
const uint64_t kImportantCloneVforkFlags = CLONE_VFORK | CLONE_VM; |
161 |
|
162 |
const BoolExpr is_fork_or_clone_vfork = |
163 |
AnyOf((flags & (CLONE_VM | CLONE_THREAD)) == 0, |
164 |
(flags & kImportantCloneVforkFlags) == kImportantCloneVforkFlags); |
165 |
|
157 |
return If(IsAndroid() ? android_test : glibc_test, Allow()) |
166 |
return If(IsAndroid() ? android_test : glibc_test, Allow()) |
158 |
.ElseIf((flags & (CLONE_VM | CLONE_THREAD)) == 0, Error(EPERM)) |
167 |
.ElseIf(is_fork_or_clone_vfork, Error(EPERM)) |
159 |
.Else(CrashSIGSYSClone()); |
168 |
.Else(CrashSIGSYSClone()); |
160 |
} |
169 |
} |
161 |
|
170 |
|