linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "David Rientjes" <rientjes@google.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	"Sasha Levin" <sashal@kernel.org>,
	kvm@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 28/28] kvm: sev: Fail KVM_SEV_INIT if already initialized
Date: Sat,  9 Feb 2019 13:48:36 -0500	[thread overview]
Message-ID: <20190209184840.126418-28-sashal@kernel.org> (raw)
In-Reply-To: <20190209184840.126418-1-sashal@kernel.org>

From: David Rientjes <rientjes@google.com>

[ Upstream commit 3f14a89d1132dcae3c8ce6721c6ef51f6e6d9b5f ]

By code inspection, it was found that multiple calls to KVM_SEV_INIT
could deplete asid bits and overwrite kvm_sev_info's regions_list.

Multiple calls to KVM_SVM_INIT is not likely to occur with QEMU, but this
should likely be fixed anyway.

This code is serialized by kvm->lock.

Fixes: 1654efcbc431 ("KVM: SVM: Add KVM_SEV_INIT command")
Reported-by: Cfir Cohen <cfir@google.com>
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 arch/x86/kvm/svm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index f1d3fe5a0c65..0976853ed723 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -6249,6 +6249,9 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
 	int asid, ret;
 
 	ret = -EBUSY;
+	if (unlikely(sev->active))
+		return ret;
+
 	asid = sev_asid_new();
 	if (asid < 0)
 		return ret;
-- 
2.19.1


      parent reply	other threads:[~2019-02-09 18:53 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-09 18:48 [PATCH AUTOSEL 4.19 01/28] drm/amdgpu/sriov:Correct pfvf exchange logic Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 02/28] ACPI: NUMA: Use correct type for printing addresses on i386-PAE Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 03/28] perf report: Fix wrong iteration count in --branch-history Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 04/28] perf test shell: Use a fallback to get the pathname in vfs_getname Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 05/28] tools uapi: fix RISC-V 64-bit support Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 06/28] riscv: fix trace_sys_exit hook Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 07/28] cpufreq: check if policy is inactive early in __cpufreq_get() Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 08/28] drm/bridge: tc358767: add bus flags Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 09/28] drm/bridge: tc358767: add defines for DP1_SRCCTRL & PHY_2LANE Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 10/28] drm/bridge: tc358767: fix single lane configuration Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 11/28] drm/bridge: tc358767: fix initial DP0/1_SRCCTRL value Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 12/28] drm/bridge: tc358767: reject modes which require too much BW Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 13/28] drm/bridge: tc358767: fix output H/V syncs Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 14/28] nvme-pci: use the same attributes when freeing host_mem_desc_bufs Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 15/28] nvme-pci: fix out of bounds access in nvme_cqe_pending Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 16/28] nvme-multipath: zero out ANA log buffer Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 17/28] nvme: pad fake subsys NQN vid and ssvid with zeros Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 18/28] drm/amdgpu: set WRITE_BURST_LENGTH to 64B to workaround SDMA1 hang Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 19/28] ARM: dts: da850-evm: Correct the audio codec regulators Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 20/28] ARM: dts: da850-evm: Correct the sound card name Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 21/28] ARM: dts: da850-lcdk: Correct the audio codec regulators Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 22/28] ARM: dts: da850-lcdk: Correct the sound card name Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 23/28] ARM: dts: kirkwood: Fix polarity of GPIO fan lines Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 24/28] gpio: pl061: handle failed allocations Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 25/28] drm/nouveau: Don't disable polling in fallback mode Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 26/28] drm/nouveau/falcon: avoid touching registers if engine is off Sasha Levin
2019-02-09 18:48 ` [PATCH AUTOSEL 4.19 27/28] cifs: Limit memory used by lock request calls to a page Sasha Levin
2019-02-09 18:48 ` Sasha Levin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190209184840.126418-28-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rientjes@google.com \
    --cc=rkrcmar@redhat.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).