Skip to contentSkip to conversation

RFC: net: document "-netdev user" explicitly as unsafe

PATCH In review [email protected] 2 participants 2 messages Jun 7, 2021 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RFC: net: document "-netdev user" explicitly as unsafe

From: Marc-André Lureau <[email protected]>

libslirp is known to have several security flaws, we should make it explicit by warning the users and in the documentation.

---
 docs/system/net.rst | 9 +++++++++
 net/slirp.c         | 2 ++
 qemu-options.hx     | 4 +++-
 3 files changed, 14 insertions(+), 1 deletion(-)
docs/system/net.rst +9 -0
index 4b2640c448..1caac062a4 100644
@@ -41,6 +41,13 @@ download OpenVPN from : https://openvpn.net/.
 Using the user mode network stack
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+.. warning::
+   The user mode network stack (`slirp`_) is notoriously unsafe. We strongly
+   discourage its usage in a production environment. It is mostly useful for
+   developers or informed end-users. It is recommended to use other networking
+   solutions, or a dedicated standalone slirp process with the minimum
+   privileges.
+
 By using the option ``-net user`` (default configuration if no ``-net``
 option is specified), QEMU uses a completely user mode network stack
 (you don't need root privilege to use the virtual network). The virtual
@@ -98,3 +105,5 @@ option, it is possible to create emulated networks that span several
 QEMU instances. See the description of the ``-netdev socket`` option in
 :ref:`sec_005finvocation` to have a basic
 example.
+
+.. _slirp: https://gitlab.freedesktop.org/slirp/libslirp
net/slirp.c +2 -0
index ad3a838e0b..80891eefbb 100644
@@ -388,6 +388,8 @@ static int net_slirp_init(NetClientState *peer, const char *model,
     char *end;
     struct slirp_config_str *config;
 
+    warn_report("User mode network stack is unsafe!");
+
     if (!ipv4 && (vnetwork || vhost || vnameserver)) {
         error_setg(errp, "IPv4 disabled but netmask/host/dns provided");
         return -1;
qemu-options.hx +3 -1
index 14258784b3..b46a231ba6 100644
@@ -2652,7 +2652,9 @@ SRST
 
 ``-netdev user,id=id[,option][,option][,...]``
     Configure user mode host network backend which requires no
-    administrator privilege to run. Valid options are:
+    administrator privilege to run, but is notoriously **unsafe**!
+
+    Valid options are:
 
     ``id=id``
         Assign symbolic name for use in monitor commands.
Signature · 1 line
2.29.0
#1 lore raw
Quoted 11 lines · On Mon, 7 Jun 2021 at 12:50, <[email protected]> wrote:

From: Marc-André Lureau <[email protected]>

libslirp is known to have several security flaws, we should make it explicit by warning the users and in the documentation.

net/slirp.c static int net_slirp_init(NetClientState *peer, const char *model, · line 391

Quoted 4 lines
net/slirp.c +1 -0
@@ -388,6 +388,8 @@ static int net_slirp_init(NetClientState *peer, const char *model,
     char *end;
     struct slirp_config_str *config;
 
+    warn_report("User mode network stack is unsafe!");

Not enthusiastic about generating new warnings for a huge range of end-users, especially without detailed information about what they should do about it and suitable new command lines (including ones which will work for everybody, not just "I'm on an x86 PC with pluggable network devices").

Also, -net user is perfectly fine for quite a lot of usecases.

thanks
-- PMM