Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 12ad8ba

Browse files
authored
Glibc's system() function switched to using posix_spawn, which uses CLONE_VFORK
1 parent c88f565 commit 12ad8ba

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc

+11-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ namespace sandbox {
126126
#if !defined(OS_NACL_NONSFI)
127127
// Allow Glibc's and Android pthread creation flags, crash on any other
128128
// 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).
130131
ResultExpr RestrictCloneToThreadsAndEPERMFork() {
131132
const Arg<unsigned long> flags(0);
132133

@@ -145,8 +146,16 @@ ResultExpr RestrictCloneToThreadsAndEPERMFork() {
145146
AnyOf(flags == kAndroidCloneMask, flags == kObsoleteAndroidCloneMask,
146147
flags == kGlibcPthreadFlags);
147148

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+
148157
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))
150159
.Else(CrashSIGSYSClone());
151160
}
152161

0 commit comments

Comments
 (0)