Blame SOURCES/kvm-virtiofsd-drop-all-capabilities-in-the-wait-parent-p.patch

902636
From 78152453940967f9ece9fe3ffc5017c669d6ec28 Mon Sep 17 00:00:00 2001
902636
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
902636
Date: Tue, 5 May 2020 16:36:00 +0100
902636
Subject: [PATCH 9/9] virtiofsd: drop all capabilities in the wait parent
902636
 process
902636
MIME-Version: 1.0
902636
Content-Type: text/plain; charset=UTF-8
902636
Content-Transfer-Encoding: 8bit
902636
902636
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
Message-id: <20200505163600.22956-8-dgilbert@redhat.com>
902636
Patchwork-id: 96274
902636
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH 7/7] virtiofsd: drop all capabilities in the wait parent process
902636
Bugzilla: 1817445
902636
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
902636
RH-Acked-by: Max Reitz <mreitz@redhat.com>
902636
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
902636
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
902636
902636
From: Stefan Hajnoczi <stefanha@redhat.com>
902636
902636
All this process does is wait for its child.  No capabilities are
902636
needed.
902636
902636
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
902636
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
902636
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
(cherry picked from commit 66502bbca37ca7a3bfa57e82cfc03b89a7a11eae)
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 tools/virtiofsd/passthrough_ll.c | 13 +++++++++++++
902636
 1 file changed, 13 insertions(+)
902636
902636
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
902636
index 6358874..f41a6b0 100644
902636
--- a/tools/virtiofsd/passthrough_ll.c
902636
+++ b/tools/virtiofsd/passthrough_ll.c
902636
@@ -2535,6 +2535,17 @@ static void print_capabilities(void)
902636
 }
902636
 
902636
 /*
902636
+ * Drop all Linux capabilities because the wait parent process only needs to
902636
+ * sit in waitpid(2) and terminate.
902636
+ */
902636
+static void setup_wait_parent_capabilities(void)
902636
+{
902636
+    capng_setpid(syscall(SYS_gettid));
902636
+    capng_clear(CAPNG_SELECT_BOTH);
902636
+    capng_apply(CAPNG_SELECT_BOTH);
902636
+}
902636
+
902636
+/*
902636
  * Move to a new mount, net, and pid namespaces to isolate this process.
902636
  */
902636
 static void setup_namespaces(struct lo_data *lo, struct fuse_session *se)
902636
@@ -2567,6 +2578,8 @@ static void setup_namespaces(struct lo_data *lo, struct fuse_session *se)
902636
         pid_t waited;
902636
         int wstatus;
902636
 
902636
+        setup_wait_parent_capabilities();
902636
+
902636
         /* The parent waits for the child */
902636
         do {
902636
             waited = waitpid(child, &wstatus, 0);
902636
-- 
902636
1.8.3.1
902636