summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel P. Berrangé2021-07-29 17:43:01 +0200
committerDaniel P. Berrangé2022-02-16 19:52:40 +0100
commitc542b302707628609f2a33bcbd3e442282806b8e (patch)
treeb13b0a396f4a7cc8d7ed5e05cbfb0b6dfc115927
parentseccomp: fix blocking of process spawning (diff)
downloadqemu-c542b302707628609f2a33bcbd3e442282806b8e.tar.gz
qemu-c542b302707628609f2a33bcbd3e442282806b8e.tar.xz
qemu-c542b302707628609f2a33bcbd3e442282806b8e.zip
seccomp: block use of clone3 syscall
Modern glibc will use clone3 instead of clone, when it detects that it is available. We need to compare flags in order to decide whether to allow clone (thread create vs process fork), but in clone3 the flags are hidden inside a struct. Seccomp can't currently match on data inside a struct, so our only option is to block clone3 entirely. If we use ENOSYS to block it, then glibc transparently falls back to clone. This may need to be revisited if Linux adds a new architecture in future and only provides clone3, without clone. Acked-by: Eduardo Otubo <otubo@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
-rw-r--r--softmmu/qemu-seccomp.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/softmmu/qemu-seccomp.c b/softmmu/qemu-seccomp.c
index 57139cc9ce..a7bb5c350f 100644
--- a/softmmu/qemu-seccomp.c
+++ b/softmmu/qemu-seccomp.c
@@ -244,6 +244,10 @@ static const struct QemuSeccompSyscall denylist[] = {
RULE_CLONE_FLAG(CLONE_NEWPID),
RULE_CLONE_FLAG(CLONE_NEWNET),
RULE_CLONE_FLAG(CLONE_IO),
+#ifdef __SNR_clone3
+ { SCMP_SYS(clone3), QEMU_SECCOMP_SET_SPAWN,
+ 0, NULL, SCMP_ACT_ERRNO(ENOSYS) },
+#endif
/* resource control */
{ SCMP_SYS(setpriority), QEMU_SECCOMP_SET_RESOURCECTL,
0, NULL, SCMP_ACT_ERRNO(EPERM) },