All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Eduardo Otubo" <otubo@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH 4/5] seccomp: block use of clone3 syscall
Date: Mon,  2 Aug 2021 14:03:02 +0100	[thread overview]
Message-ID: <20210802130303.3300108-5-berrange@redhat.com> (raw)
In-Reply-To: <20210802130303.3300108-1-berrange@redhat.com>

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.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 softmmu/qemu-seccomp.c | 4 ++++
 1 file changed, 4 insertions(+)

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) },
-- 
2.31.1



  parent reply	other threads:[~2021-08-02 13:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02 13:02 [PATCH 0/5] seccomp: fix hole in blocking forks Daniel P. Berrangé
2021-08-02 13:02 ` [PATCH 1/5] seccomp: allow action to be customized per syscall Daniel P. Berrangé
2021-08-02 13:03 ` [PATCH 2/5] seccomp: add unit test for seccomp filtering Daniel P. Berrangé
2021-08-02 13:03 ` [PATCH 3/5] seccomp: fix blocking of process spawning Daniel P. Berrangé
2021-08-02 13:03 ` Daniel P. Berrangé [this message]
2021-08-02 13:03 ` [PATCH 5/5] seccomp: block setns, unshare and execveat syscalls Daniel P. Berrangé
2021-08-04  8:05 ` [PATCH 0/5] seccomp: fix hole in blocking forks Eduardo Terrell Ferrari Otubo
2022-01-28 15:42   ` Daniel P. Berrangé
2022-01-31  9:07     ` Eduardo Otubo
2022-01-31  9:09       ` Daniel P. Berrangé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210802130303.3300108-5-berrange@redhat.com \
    --to=berrange@redhat.com \
    --cc=otubo@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.