[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 048/104] virtiofsd: move to an empty network namespace
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PATCH 048/104] virtiofsd: move to an empty network namespace |
Date: |
Thu, 12 Dec 2019 16:38:08 +0000 |
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>
---
tools/virtiofsd/passthrough_ll.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index 606824f002..135a99f2fd 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -1926,6 +1926,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)
{
@@ -2017,6 +2030,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
- [PATCH 040/104] virtiofsd: Pass write iov's all the way through, (continued)
- [PATCH 040/104] virtiofsd: Pass write iov's all the way through, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 039/104] virtiofsd: Plumb fuse_bufvec through to do_write_buf, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 035/104] virtiofsd: passthrough_ll: add dirp_map to hide lo_dirp pointers, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 041/104] virtiofsd: add fuse_mbuf_iter API, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 042/104] virtiofsd: validate input buffer sizes in do_write_buf(), Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 044/104] virtiofsd: prevent ".." escape in lo_do_lookup(), Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 045/104] virtiofsd: prevent ".." escape in lo_do_readdir(), Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 043/104] virtiofsd: check input buffer size in fuse_lowlevel.c ops, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 046/104] virtiofsd: use /proc/self/fd/ O_PATH file descriptor, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 047/104] virtiofsd: sandbox mount namespace, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 048/104] virtiofsd: move to an empty network namespace,
Dr. David Alan Gilbert (git) <=
- [PATCH 049/104] virtiofsd: move to a new pid namespace, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 050/104] virtiofsd: add seccomp whitelist, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 051/104] virtiofsd: Parse flag FUSE_WRITE_KILL_PRIV, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 052/104] virtiofsd: cap-ng helpers, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 053/104] virtiofsd: Drop CAP_FSETID if client asked for it, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 054/104] virtiofsd: set maximum RLIMIT_NOFILE limit, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 057/104] virtiofsd: add --syslog command-line option, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 055/104] virtiofsd: fix libfuse information leaks, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 056/104] virtiofsd: add security guide document, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 059/104] virtiofsd: Add ID to the log with FUSE_LOG_DEBUG level, Dr. David Alan Gilbert (git), 2019/12/12