From 218438259dd795456f0a48f67cbe5b4e520db88b Mon Sep 17 00:00:00 2001 From: Matthew Denton Date: Thu, 3 Jun 2021 20:06:13 +0000 Subject: [PATCH] Linux sandbox: return ENOSYS for clone3 Because clone3 uses a pointer argument rather than a flags argument, we cannot examine the contents with seccomp, which is essential to preventing sandboxed processes from starting other processes. So, we won't be able to support clone3 in Chromium. This CL modifies the BPF policy to return ENOSYS for clone3 so glibc always uses the fallback to clone. Bug: 1213452 Change-Id: I7c7c585a319e0264eac5b1ebee1a45be2d782303 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2936184 Reviewed-by: Robert Sesek Commit-Queue: Matthew Denton Cr-Commit-Position: refs/heads/master@{#888980} --- .../sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc | 8 ++++++++ diff --git a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc b/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc index 3c67b124786..81cb25e139e 100644 --- a/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc +++ b/src/3rdparty/chromium/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc @@ -165,6 +165,14 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno, return RestrictCloneToThreadsAndEPERMFork(); } + // clone3 takes a pointer argument which we cannot examine, so return ENOSYS + // to force the libc to use clone. See https://crbug.com/1213452. + #if defined(__NR_clone3) + if (sysno == __NR_clone3) { + return Error(ENOSYS); + } + #endif + if (sysno == __NR_fcntl) return RestrictFcntlCommands(); -- 2.32.0