cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-seccomp-fix-killing-of-whole-process-instead-of-thre.patch

8fced6
From 08dc2a4dc481916fae9597220ad0faf3f6ed70c1 Mon Sep 17 00:00:00 2001
8fced6
From: Eduardo Otubo <otubo@redhat.com>
8fced6
Date: Mon, 16 Nov 2020 15:15:38 -0500
8fced6
Subject: [PATCH 1/5] seccomp: fix killing of whole process instead of thread
8fced6
MIME-Version: 1.0
8fced6
Content-Type: text/plain; charset=UTF-8
8fced6
Content-Transfer-Encoding: 8bit
8fced6
8fced6
RH-Author: Eduardo Otubo <otubo@redhat.com>
8fced6
Message-id: <20201116151538.22254-1-otubo@redhat.com>
8fced6
Patchwork-id: 99654
8fced6
O-Subject: [RHEL-8.3.0/RHEL-8.4.0 qemu-kvm PATCH] seccomp: fix killing of whole process instead of thread
8fced6
Bugzilla: 1880546
8fced6
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
8fced6
RH-Acked-by: Danilo de Paula <ddepaula@redhat.com>
8fced6
RH-Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8fced6
8fced6
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1890885
8fced6
BRANCH: rhel-8.3.0
8fced6
UPSTREAM: Merged
8fced6
BREW: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=1890885
8fced6
8fced6
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1880546
8fced6
BRANCH: rhel-8.4.0
8fced6
UPSTREAM: Merged
8fced6
BREW: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=33125023
8fced6
8fced6
From: Daniel P. Berrangé <berrange@redhat.com>
8fced6
8fced6
Back in 2018 we introduced support for killing the whole QEMU process
8fced6
instead of just one thread, when a seccomp rule is violated:
8fced6
8fced6
  commit bda08a5764d470f101fa38635d30b41179a313e1
8fced6
  Author: Marc-André Lureau <marcandre.lureau@redhat.com>
8fced6
  Date:   Wed Aug 22 19:02:48 2018 +0200
8fced6
8fced6
    seccomp: prefer SCMP_ACT_KILL_PROCESS if available
8fced6
8fced6
Fast forward a year and we introduced a patch to avoid killing the
8fced6
process for resource control syscalls tickled by Mesa.
8fced6
8fced6
  commit 9a1565a03b79d80b236bc7cc2dbce52a2ef3a1b8
8fced6
  Author: Daniel P. Berrangé <berrange@redhat.com>
8fced6
  Date:   Wed Mar 13 09:49:03 2019 +0000
8fced6
8fced6
    seccomp: don't kill process for resource control syscalls
8fced6
8fced6
Unfortunately a logic bug effectively reverted the first commit
8fced6
mentioned so that we go back to only killing the thread, not the whole
8fced6
process.
8fced6
8fced6
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
8fced6
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
8fced6
Acked-by: Eduardo Otubo <otubo@redhat.com>
8fced6
(cherry picked from commit e474e3aacf4276eb0781d11c45e2fab996f9dc56)
8fced6
Signed-off-by: Eduardo Otubo <otubo@redhat.com>
8fced6
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
8fced6
---
8fced6
 qemu-seccomp.c | 3 ++-
8fced6
 1 file changed, 2 insertions(+), 1 deletion(-)
8fced6
8fced6
diff --git a/qemu-seccomp.c b/qemu-seccomp.c
8fced6
index e0a1829b3dd..8325ecb766e 100644
8fced6
--- a/qemu-seccomp.c
8fced6
+++ b/qemu-seccomp.c
8fced6
@@ -136,8 +136,9 @@ static uint32_t qemu_seccomp_get_action(int set)
8fced6
 
8fced6
             if (qemu_seccomp(SECCOMP_GET_ACTION_AVAIL, 0, &action) == 0) {
8fced6
                 kill_process = 1;
8fced6
+            } else {
8fced6
+                kill_process = 0;
8fced6
             }
8fced6
-            kill_process = 0;
8fced6
         }
8fced6
         if (kill_process == 1) {
8fced6
             return SCMP_ACT_KILL_PROCESS;
8fced6
-- 
8fced6
2.27.0
8fced6