@@ -126,7 +126,8 @@ namespace sandbox {
126
126
#if !defined(OS_NACL_NONSFI)
127
127
// Allow Glibc's and Android pthread creation flags, crash on any other
128
128
// thread creation attempts and EPERM attempts to use neither
129
- // CLONE_VM, nor CLONE_THREAD, which includes all fork() implementations.
129
+ // CLONE_VM nor CLONE_THREAD (all fork implementations), unless CLONE_VFORK is
130
+ // present (as in newer versions of posix_spawn).
130
131
ResultExpr RestrictCloneToThreadsAndEPERMFork () {
131
132
const Arg<unsigned long > flags (0 );
132
133
@@ -145,8 +146,16 @@ ResultExpr RestrictCloneToThreadsAndEPERMFork() {
145
146
AnyOf (flags == kAndroidCloneMask , flags == kObsoleteAndroidCloneMask ,
146
147
flags == kGlibcPthreadFlags );
147
148
149
+ // The following two flags are the two important flags in any vfork-emulating
150
+ // clone call. EPERM any clone call that contains both of them.
151
+ const uint64_t kImportantCloneVforkFlags = CLONE_VFORK | CLONE_VM;
152
+
153
+ const BoolExpr is_fork_or_clone_vfork =
154
+ AnyOf ((flags & (CLONE_VM | CLONE_THREAD)) == 0 ,
155
+ (flags & kImportantCloneVforkFlags ) == kImportantCloneVforkFlags );
156
+
148
157
return If (IsAndroid () ? android_test : glibc_test, Allow ())
149
- .ElseIf ((flags & (CLONE_VM | CLONE_THREAD)) == 0 , Error (EPERM))
158
+ .ElseIf (is_fork_or_clone_vfork , Error (EPERM))
150
159
.Else (CrashSIGSYSClone ());
151
160
}
152
161
0 commit comments