Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 717812C182 for ; Wed, 28 Feb 2024 08:16:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709108195; cv=none; b=dWZGUfEm+hSGi6we+3iTdqi3QHMnjSL77MkN0+SRVCtYpXp75pgwGhAYJK0O64t9wbCOgw9vN6NE9reP26wrWXuNYJ/motkQCXKefU7umdHbQ8HUz1sUob/47PlsGoxTxEs+zX1wpLVeKASZMMq4XxsvuSvBCmaCGqFKZkCX3Jo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709108195; c=relaxed/simple; bh=kggjLWbhPbym41rk4GTLgjqBdjoAPSLvC1612vSXZGU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=g6cxc4HTjwEvhAJVFv8gJ8Pl5DkiOinOj64hrVlPfOq/rc9OFKEeQ190DSuhRVvMXNLujCORF4CgjMIwVwtYDKnkBsnLvcuDSE808kM2n2KjvqIo36Ri+7785rd7XMR1PVOCRfbSep0jypmLBe66UVXnHXaa0BG4dqWHbWfGvik= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lAdZXmaQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="lAdZXmaQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00E92C433F1; Wed, 28 Feb 2024 08:16:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709108195; bh=kggjLWbhPbym41rk4GTLgjqBdjoAPSLvC1612vSXZGU=; h=From:To:Cc:Subject:Date:Reply-to:From; b=lAdZXmaQWwwv1GMZe/gVyWEaZKs7RyC9GufsMwUac5E37WKTf3CQkle8h6DzA++iA w1saAtB1lM03UINtVDxkMTbVaSivrc7qx189y5nETlJ6ZBWd32yIJyS/ZeonhkvW6+ pctqZ2SHrBOyg7CqX2V0VE7CIHdEids1FACSIvFE= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: gregkh@kernel.org Subject: CVE-2021-46978: KVM: nVMX: Always make an attempt to map eVMCS after migration Date: Wed, 28 Feb 2024 09:14:28 +0100 Message-ID: <2024022822-CVE-2021-46978-3516@gregkh> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=3447; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=ZDVw1CKasME+88esoiwGSawPXjVttog7kOr/z5non3I=; b=owGbwMvMwCRo6H6F97bub03G02pJDKn3Xsfl3HA9r5YTbrUkbuIOplv9z2KNLYR+s3XUb1u7c +7n2Xx5HbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjARdVOGmYxlUR/O+Tv4rYy+ cXxR/6LHOuu2H2ZYcJhB4BmP3NcfZ9weZX8Rs7o5x3lrFgA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: gregkh@kernel.org Description =========== In the Linux kernel, the following vulnerability has been resolved: KVM: nVMX: Always make an attempt to map eVMCS after migration When enlightened VMCS is in use and nested state is migrated with vmx_get_nested_state()/vmx_set_nested_state() KVM can't map evmcs page right away: evmcs gpa is not 'struct kvm_vmx_nested_state_hdr' and we can't read it from VP assist page because userspace may decide to restore HV_X64_MSR_VP_ASSIST_PAGE after restoring nested state (and QEMU, for example, does exactly that). To make sure eVMCS is mapped /vmx_set_nested_state() raises KVM_REQ_GET_NESTED_STATE_PAGES request. Commit f2c7ef3ba955 ("KVM: nSVM: cancel KVM_REQ_GET_NESTED_STATE_PAGES on nested vmexit") added KVM_REQ_GET_NESTED_STATE_PAGES clearing to nested_vmx_vmexit() to make sure MSR permission bitmap is not switched when an immediate exit from L2 to L1 happens right after migration (caused by a pending event, for example). Unfortunately, in the exact same situation we still need to have eVMCS mapped so nested_sync_vmcs12_to_shadow() reflects changes in VMCS12 to eVMCS. As a band-aid, restore nested_get_evmcs_page() when clearing KVM_REQ_GET_NESTED_STATE_PAGES in nested_vmx_vmexit(). The 'fix' is far from being ideal as we can't easily propagate possible failures and even if we could, this is most likely already too late to do so. The whole 'KVM_REQ_GET_NESTED_STATE_PAGES' idea for mapping eVMCS after migration seems to be fragile as we diverge too much from the 'native' path when vmptr loading happens on vmx_set_nested_state(). The Linux kernel CVE team has assigned CVE-2021-46978 to this issue. Affected and fixed versions =========================== Issue introduced in 5.10.13 with commit 0faceb7d6dda and fixed in 5.10.38 with commit c8bf64e3fb77 Issue introduced in 5.11 with commit f2c7ef3ba955 and fixed in 5.11.22 with commit 200a45649ab7 Issue introduced in 5.11 with commit f2c7ef3ba955 and fixed in 5.12.5 with commit bd0e8455b85b Issue introduced in 5.11 with commit f2c7ef3ba955 and fixed in 5.13 with commit f5c7e8425f18 Please see https://www.kernel.org or a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2021-46978 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: arch/x86/kvm/vmx/nested.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/c8bf64e3fb77cc19bad146fbe26651985b117194 https://git.kernel.org/stable/c/200a45649ab7361bc80c70aebf7165b64f9a6c9f https://git.kernel.org/stable/c/bd0e8455b85b651a4c77de9616e307129b15aaa7 https://git.kernel.org/stable/c/f5c7e8425f18fdb9bdb7d13340651d7876890329