summaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorBorislav Petkov (AMD) <bp@alien8.de>2023-10-05 11:06:36 +0200
committerBorislav Petkov (AMD) <bp@alien8.de>2023-10-09 15:45:34 +0200
commita37cd2a59d0cb270b1bba568fd3a3b8668b9d3ba (patch)
treef2fad70f971938567b377eb14b5c3e69247a2e82 /arch/x86
parent8a749fd1a8720d4619c91c8b6e7528c0a355c0aa (diff)
downloadlinux-stable-a37cd2a59d0cb270b1bba568fd3a3b8668b9d3ba.tar.gz
linux-stable-a37cd2a59d0cb270b1bba568fd3a3b8668b9d3ba.tar.bz2
linux-stable-a37cd2a59d0cb270b1bba568fd3a3b8668b9d3ba.zip
x86/sev: Disable MMIO emulation from user mode
A virt scenario can be constructed where MMIO memory can be user memory. When that happens, a race condition opens between when the hardware raises the #VC and when the #VC handler gets to emulate the instruction. If the MOVS is replaced with a MOVS accessing kernel memory in that small race window, then write to kernel memory happens as the access checks are not done at emulation time. Disable MMIO emulation in user mode temporarily until a sensible use case appears and justifies properly handling the race window. Fixes: 0118b604c2c9 ("x86/sev-es: Handle MMIO String Instructions") Reported-by: Tom Dohrmann <erbse.13@gmx.de> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Tested-by: Tom Dohrmann <erbse.13@gmx.de> Cc: <stable@kernel.org>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kernel/sev.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/x86/kernel/sev.c b/arch/x86/kernel/sev.c
index 2787826d9f60..4ee14e647ae6 100644
--- a/arch/x86/kernel/sev.c
+++ b/arch/x86/kernel/sev.c
@@ -1509,6 +1509,9 @@ static enum es_result vc_handle_mmio(struct ghcb *ghcb, struct es_em_ctxt *ctxt)
return ES_DECODE_FAILED;
}
+ if (user_mode(ctxt->regs))
+ return ES_UNSUPPORTED;
+
switch (mmio) {
case INSN_MMIO_WRITE:
memcpy(ghcb->shared_buffer, reg_data, bytes);