qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 17/25] virtiofsd: move to an empty network namespace


From: Dr. David Alan Gilbert (git)
Subject: [PATCH 17/25] virtiofsd: move to an empty network namespace
Date: Thu, 24 Oct 2019 12:27:10 +0100

From: Stefan Hajnoczi <address@hidden>

If the process is compromised there should be no network access.  Use an
empty network namespace to sandbox networking.

Signed-off-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Dr. David Alan Gilbert <address@hidden>
---
 contrib/virtiofsd/passthrough_ll.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/contrib/virtiofsd/passthrough_ll.c 
b/contrib/virtiofsd/passthrough_ll.c
index 20a34d4d83..58cf82a89f 100644
--- a/contrib/virtiofsd/passthrough_ll.c
+++ b/contrib/virtiofsd/passthrough_ll.c
@@ -1822,6 +1822,19 @@ static void print_capabilities(void)
        printf("}\n");
 }
 
+/*
+ * Called after our UNIX domain sockets have been created, now we can move to
+ * an empty network namespace to prevent TCP/IP and other network activity in
+ * case this process is compromised.
+ */
+static void setup_net_namespace(void)
+{
+       if (unshare(CLONE_NEWNET) != 0) {
+               fuse_log(FUSE_LOG_ERR, "unshare(CLONE_NEWNET): %m\n");
+               exit(1);
+       }
+}
+
 /* This magic is based on lxc's lxc_pivot_root() */
 static void setup_pivot_root(const char *source)
 {
@@ -1913,6 +1926,7 @@ static void setup_mount_namespace(const char *source)
  */
 static void setup_sandbox(struct lo_data *lo)
 {
+       setup_net_namespace();
        setup_mount_namespace(lo->source);
 }
 
-- 
2.23.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]