[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 6/6] virtiofsd: drop all capabilities in the wait parent process
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PULL 6/6] virtiofsd: drop all capabilities in the wait parent process |
Date: |
Fri, 1 May 2020 20:15:00 +0100 |
From: Stefan Hajnoczi <address@hidden>
All this process does is wait for its child. No capabilities are
needed.
Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
tools/virtiofsd/passthrough_ll.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index e49650b63d..3ba1d90984 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -2530,6 +2530,17 @@ static void print_capabilities(void)
printf("}\n");
}
+/*
+ * Drop all Linux capabilities because the wait parent process only needs to
+ * sit in waitpid(2) and terminate.
+ */
+static void setup_wait_parent_capabilities(void)
+{
+ capng_setpid(syscall(SYS_gettid));
+ capng_clear(CAPNG_SELECT_BOTH);
+ capng_apply(CAPNG_SELECT_BOTH);
+}
+
/*
* Move to a new mount, net, and pid namespaces to isolate this process.
*/
@@ -2563,6 +2574,8 @@ static void setup_namespaces(struct lo_data *lo, struct
fuse_session *se)
pid_t waited;
int wstatus;
+ setup_wait_parent_capabilities();
+
/* The parent waits for the child */
do {
waited = waitpid(child, &wstatus, 0);
--
2.26.2
- [PULL 0/6] virtiofs queue, Dr. David Alan Gilbert (git), 2020/05/01
- [PULL 1/6] virtiofsd: add --rlimit-nofile=NUM option, Dr. David Alan Gilbert (git), 2020/05/01
- [PULL 3/6] virtiofsd: jail lo->proc_self_fd, Dr. David Alan Gilbert (git), 2020/05/01
- [PULL 2/6] virtiofsd: stay below fs.file-max sysctl value (CVE-2020-10717), Dr. David Alan Gilbert (git), 2020/05/01
- [PULL 4/6] virtiofsd: Show submounts, Dr. David Alan Gilbert (git), 2020/05/01
- [PULL 6/6] virtiofsd: drop all capabilities in the wait parent process,
Dr. David Alan Gilbert (git) <=
- [PULL 5/6] virtiofsd: only retain file system capabilities, Dr. David Alan Gilbert (git), 2020/05/01
- Re: [PULL 0/6] virtiofs queue, Dr. David Alan Gilbert, 2020/05/01
- Re: [PULL 0/6] virtiofs queue, Peter Maydell, 2020/05/03