From nobody Thu Nov 13 22:11:59 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1582904588; cv=none; d=zohomail.com; s=zohoarc; b=AeUhjRXoAcIAgp+gyGI5lHW+ZUmtt0kZuOa7jYSnfHxx+mthXK9Vwk2PKhLkbtAqX1lOf0cEpA/qEocTfZJ0c6fMoStHO6+hFo1KyRPNEzDbZT143+nWIPbh6skD2UEaaZa8JmYfzuQ+Vujpd9XNuioChKA6tdryskMEIoThcm8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582904588; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9ow6sfNZDFk5APQY1rM3zBt2mEvsDfRz8gsF27ZyME8=; b=fdqjeTOebee5FLUgtYv8hozXj2VIq6VloHYW9E/D1E96/Iw72/JnGowtyZk35/IFUJ7fgsJRz2/2kA4R3tmrXRjGdGxQa1NHbU3wZlpcJ8tJ0Q0FdTBdNEFUhmzQ0WQcBUnZ10fEpYucq4FkKtZhsQmiTBFKi79dmyjdidH4Yvw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1582904588161740.2289432309453; Fri, 28 Feb 2020 07:43:08 -0800 (PST) Received: from localhost ([::1]:48832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7hn8-0004L7-TA for importer@patchew.org; Fri, 28 Feb 2020 10:43:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:46864) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7hh5-0000xy-DN for qemu-devel@nongnu.org; Fri, 28 Feb 2020 10:36:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7hh3-0004xj-Ek for qemu-devel@nongnu.org; Fri, 28 Feb 2020 10:36:51 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:34725) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j7hh3-0004x3-7A for qemu-devel@nongnu.org; Fri, 28 Feb 2020 10:36:49 -0500 Received: by mail-wr1-x42a.google.com with SMTP id z15so3469027wrl.1 for ; Fri, 28 Feb 2020 07:36:49 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id u23sm2659452wmu.14.2020.02.28.07.36.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Feb 2020 07:36:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9ow6sfNZDFk5APQY1rM3zBt2mEvsDfRz8gsF27ZyME8=; b=kr6uPJynkBgDl9BMhs9WNBPPvx4zj3zqrHzkrcVwcODH6ddtHL9p1UgxLX+8NJZBgg lE78GRVAvPKZPz/FWvYy2KrUeRxTXZukth9Us+S4E4oAxU7/0qXiHv+QoTuvp13yoj6B PQ0Xo5Lmo03aVpO5VwZKrbq8oFu90clHbv0HZD2SbTPWIGiZuPOksPxGyLuR2akpL6oc C4+eJ2Rj0TfuhY6/rPtfBOFzY9/m+wKQwR/TmRRqYs5hBv4wXTtRymZPXSNI1UrqPlbv WQGrGYss2f7xqInKYW/YpJmaHjQFerC+KtWMh+A51+sHh+dQ6VtFugayIyMfDPjYA6jh 8/Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9ow6sfNZDFk5APQY1rM3zBt2mEvsDfRz8gsF27ZyME8=; b=BtLJc8vtoNFm6u0i0pOUGox8x5rap0B/Dp45MhCRg6YuQcS7XErRsfEB74IfUw92Ez Gxx+VTyoVhh2jMUvJBwdpKv8mvv/WUd6uGXQajKX//x8SVuc086t0flVfnmePzzcQTZB nVz/BAi+teuMaVmDTiSbBMDd1UUoAjacxm8FYPOsBduiYYpKT6BrHj6N/TN2MYgh649O 3EdXBCfX943hilEGEsLC6EiqTEje+kbGttdn9Tbh2HRzvlLf5keMFM+qotJdg7nf92cN Q79SVuE20U/FfFHI/D6gVEC4jFP6f23hQKvSZ8zmhOSnojntrLknzK7EbVK4+2CFvZIG 1MPA== X-Gm-Message-State: APjAAAUBTSw20KeIB89JNbFX+IsFetkMHbRB2j7+Wlg3tWoEVlo5DER5 rhcxF1B+ZjRb0qTuqRsmzkYrjVonzMsfwg== X-Google-Smtp-Source: APXvYqyQ74EdSdBAcZu3K5a0/yeEYBjJ6JYGsAhipIdZKUeuFTNc/rVEsILqLJaBBbCDQvT+nGYMZg== X-Received: by 2002:adf:f6c1:: with SMTP id y1mr5236473wrp.17.1582904207705; Fri, 28 Feb 2020 07:36:47 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH v3 16/33] docs/system: Convert security.texi to rST format Date: Fri, 28 Feb 2020 15:36:02 +0000 Message-Id: <20200228153619.9906-17-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200228153619.9906-1-peter.maydell@linaro.org> References: <20200228153619.9906-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42a X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Kashyap Chamarthy Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Content-Type: text/plain; charset="utf-8" security.texi is included from qemu-doc.texi but is not used in the qemu.1 manpage. So we can do a straightforward conversion of the contents, which go into the system manual. Signed-off-by: Peter Maydell Signed-off-by: Paolo Bonzini Message-id: 20200226113034.6741-16-pbonzini@redhat.com Reviewed-by: Alex Benn=C3=A9e --- docs/system/index.rst | 1 + docs/system/security.rst | 173 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 docs/system/security.rst diff --git a/docs/system/index.rst b/docs/system/index.rst index fc774a18b54..5034f903407 100644 --- a/docs/system/index.rst +++ b/docs/system/index.rst @@ -14,4 +14,5 @@ Contents: .. toctree:: :maxdepth: 2 =20 + security vfio-ap diff --git a/docs/system/security.rst b/docs/system/security.rst new file mode 100644 index 00000000000..f2092c8768b --- /dev/null +++ b/docs/system/security.rst @@ -0,0 +1,173 @@ +Security +=3D=3D=3D=3D=3D=3D=3D=3D + +Overview +-------- + +This chapter explains the security requirements that QEMU is designed to m= eet +and principles for securely deploying QEMU. + +Security Requirements +--------------------- + +QEMU supports many different use cases, some of which have stricter securi= ty +requirements than others. The community has agreed on the overall security +requirements that users may depend on. These requirements define what is +considered supported from a security perspective. + +Virtualization Use Case +''''''''''''''''''''''' + +The virtualization use case covers cloud and virtual private server (VPS) +hosting, as well as traditional data center and desktop virtualization. T= hese +use cases rely on hardware virtualization extensions to execute guest code +safely on the physical CPU at close-to-native speed. + +The following entities are untrusted, meaning that they may be buggy or +malicious: + +- Guest +- User-facing interfaces (e.g. VNC, SPICE, WebSocket) +- Network protocols (e.g. NBD, live migration) +- User-supplied files (e.g. disk images, kernels, device trees) +- Passthrough devices (e.g. PCI, USB) + +Bugs affecting these entities are evaluated on whether they can cause dama= ge in +real-world use cases and treated as security bugs if this is the case. + +Non-virtualization Use Case +''''''''''''''''''''''''''' + +The non-virtualization use case covers emulation using the Tiny Code Gener= ator +(TCG). In principle the TCG and device emulation code used in conjunction= with +the non-virtualization use case should meet the same security requirements= as +the virtualization use case. However, for historical reasons much of the +non-virtualization use case code was not written with these security +requirements in mind. + +Bugs affecting the non-virtualization use case are not considered security +bugs at this time. Users with non-virtualization use cases must not rely = on +QEMU to provide guest isolation or any security guarantees. + +Architecture +------------ + +This section describes the design principles that ensure the security +requirements are met. + +Guest Isolation +''''''''''''''' + +Guest isolation is the confinement of guest code to the virtual machine. = When +guest code gains control of execution on the host this is called escaping = the +virtual machine. Isolation also includes resource limits such as throttli= ng of +CPU, memory, disk, or network. Guests must be unable to exceed their reso= urce +limits. + +QEMU presents an attack surface to the guest in the form of emulated devic= es. +The guest must not be able to gain control of QEMU. Bugs in emulated devi= ces +could allow malicious guests to gain code execution in QEMU. At this poin= t the +guest has escaped the virtual machine and is able to act in the context of= the +QEMU process on the host. + +Guests often interact with other guests and share resources with them. A +malicious guest must not gain control of other guests or access their data. +Disk image files and network traffic must be protected from other guests u= nless +explicitly shared between them by the user. + +Principle of Least Privilege +'''''''''''''''''''''''''''' + +The principle of least privilege states that each component only has acces= s to +the privileges necessary for its function. In the case of QEMU this means= that +each process only has access to resources belonging to the guest. + +The QEMU process should not have access to any resources that are inaccess= ible +to the guest. This way the guest does not gain anything by escaping into = the +QEMU process since it already has access to those same resources from with= in +the guest. + +Following the principle of least privilege immediately fulfills guest isol= ation +requirements. For example, guest A only has access to its own disk image = file +``a.img`` and not guest B's disk image file ``b.img``. + +In reality certain resources are inaccessible to the guest but must be +available to QEMU to perform its function. For example, host system calls= are +necessary for QEMU but are not exposed to guests. A guest that escapes in= to +the QEMU process can then begin invoking host system calls. + +New features must be designed to follow the principle of least privilege. +Should this not be possible for technical reasons, the security risk must = be +clearly documented so users are aware of the trade-off of enabling the fea= ture. + +Isolation mechanisms +'''''''''''''''''''' + +Several isolation mechanisms are available to realize this architecture of +guest isolation and the principle of least privilege. With the exception = of +Linux seccomp, these mechanisms are all deployed by management tools that +launch QEMU, such as libvirt. They are also platform-specific so they are= only +described briefly for Linux here. + +The fundamental isolation mechanism is that QEMU processes must run as +unprivileged users. Sometimes it seems more convenient to launch QEMU as +root to give it access to host devices (e.g. ``/dev/net/tun``) but this po= ses a +huge security risk. File descriptor passing can be used to give an otherw= ise +unprivileged QEMU process access to host devices without running QEMU as r= oot. +It is also possible to launch QEMU as a non-root user and configure UNIX g= roups +for access to ``/dev/kvm``, ``/dev/net/tun``, and other device nodes. +Some Linux distros already ship with UNIX groups for these devices by defa= ult. + +- SELinux and AppArmor make it possible to confine processes beyond the + traditional UNIX process and file permissions model. They restrict the = QEMU + process from accessing processes and files on the host system that are n= ot + needed by QEMU. + +- Resource limits and cgroup controllers provide throughput and utilization + limits on key resources such as CPU time, memory, and I/O bandwidth. + +- Linux namespaces can be used to make process, file system, and other sys= tem + resources unavailable to QEMU. A namespaced QEMU process is restricted = to only + those resources that were granted to it. + +- Linux seccomp is available via the QEMU ``--sandbox`` option. It disabl= es + system calls that are not needed by QEMU, thereby reducing the host kern= el + attack surface. + +Sensitive configurations +------------------------ + +There are aspects of QEMU that can have security implications which users & +management applications must be aware of. + +Monitor console (QMP and HMP) +''''''''''''''''''''''''''''' + +The monitor console (whether used with QMP or HMP) provides an interface +to dynamically control many aspects of QEMU's runtime operation. Many of t= he +commands exposed will instruct QEMU to access content on the host file sys= tem +and/or trigger spawning of external processes. + +For example, the ``migrate`` command allows for the spawning of arbitrary +processes for the purpose of tunnelling the migration data stream. The +``blockdev-add`` command instructs QEMU to open arbitrary files, exposing +their content to the guest as a virtual disk. + +Unless QEMU is otherwise confined using technologies such as SELinux, AppA= rmor, +or Linux namespaces, the monitor console should be considered to have priv= ileges +equivalent to those of the user account QEMU is running under. + +It is further important to consider the security of the character device b= ackend +over which the monitor console is exposed. It needs to have protection aga= inst +malicious third parties which might try to make unauthorized connections, = or +perform man-in-the-middle attacks. Many of the character device backends d= o not +satisfy this requirement and so must not be used for the monitor console. + +The general recommendation is that the monitor console should be exposed o= ver +a UNIX domain socket backend to the local host only. Use of the TCP based +character device backend is inappropriate unless configured to use both TLS +encryption and authorization control policy on client connections. + +In summary, the monitor console is considered a privileged control interfa= ce to +QEMU and as such should only be made accessible to a trusted management +application or user. --=20 2.20.1