|
|
1d442b |
From: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
1d442b |
Date: Mon, 27 Jan 2020 19:01:28 +0000
|
|
|
1d442b |
Subject: [PATCH] virtiofsd: move to an empty network namespace
|
|
|
1d442b |
MIME-Version: 1.0
|
|
|
1d442b |
Content-Type: text/plain; charset=UTF-8
|
|
|
1d442b |
Content-Transfer-Encoding: 8bit
|
|
|
1d442b |
|
|
|
1d442b |
If the process is compromised there should be no network access. Use an
|
|
|
1d442b |
empty network namespace to sandbox networking.
|
|
|
1d442b |
|
|
|
1d442b |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
1d442b |
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
1d442b |
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
|
|
|
1d442b |
(cherry picked from commit d74830d12ae233186ff74ddf64c552d26bb39e50)
|
|
|
1d442b |
---
|
|
|
1d442b |
tools/virtiofsd/passthrough_ll.c | 14 ++++++++++++++
|
|
|
1d442b |
1 file changed, 14 insertions(+)
|
|
|
1d442b |
|
|
|
1d442b |
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
|
|
|
1d442b |
index 0570453eef..27ab328722 100644
|
|
|
1d442b |
--- a/tools/virtiofsd/passthrough_ll.c
|
|
|
1d442b |
+++ b/tools/virtiofsd/passthrough_ll.c
|
|
|
1d442b |
@@ -1944,6 +1944,19 @@ static void print_capabilities(void)
|
|
|
1d442b |
printf("}\n");
|
|
|
1d442b |
}
|
|
|
1d442b |
|
|
|
1d442b |
+/*
|
|
|
1d442b |
+ * Called after our UNIX domain sockets have been created, now we can move to
|
|
|
1d442b |
+ * an empty network namespace to prevent TCP/IP and other network activity in
|
|
|
1d442b |
+ * case this process is compromised.
|
|
|
1d442b |
+ */
|
|
|
1d442b |
+static void setup_net_namespace(void)
|
|
|
1d442b |
+{
|
|
|
1d442b |
+ if (unshare(CLONE_NEWNET) != 0) {
|
|
|
1d442b |
+ fuse_log(FUSE_LOG_ERR, "unshare(CLONE_NEWNET): %m\n");
|
|
|
1d442b |
+ exit(1);
|
|
|
1d442b |
+ }
|
|
|
1d442b |
+}
|
|
|
1d442b |
+
|
|
|
1d442b |
/* This magic is based on lxc's lxc_pivot_root() */
|
|
|
1d442b |
static void setup_pivot_root(const char *source)
|
|
|
1d442b |
{
|
|
|
1d442b |
@@ -2035,6 +2048,7 @@ static void setup_mount_namespace(const char *source)
|
|
|
1d442b |
*/
|
|
|
1d442b |
static void setup_sandbox(struct lo_data *lo)
|
|
|
1d442b |
{
|
|
|
1d442b |
+ setup_net_namespace();
|
|
|
1d442b |
setup_mount_namespace(lo->source);
|
|
|
1d442b |
}
|
|
|
1d442b |
|