Commit a37cd2a5 authored by Borislav Petkov (AMD)'s avatar Borislav Petkov (AMD)

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: 0118b604 ("x86/sev-es: Handle MMIO String Instructions")
Reported-by: default avatarTom Dohrmann <erbse.13@gmx.de>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Tested-by: default avatarTom Dohrmann <erbse.13@gmx.de>
Cc: <stable@kernel.org>
parent 8a749fd1
...@@ -1509,6 +1509,9 @@ static enum es_result vc_handle_mmio(struct ghcb *ghcb, struct es_em_ctxt *ctxt) ...@@ -1509,6 +1509,9 @@ static enum es_result vc_handle_mmio(struct ghcb *ghcb, struct es_em_ctxt *ctxt)
return ES_DECODE_FAILED; return ES_DECODE_FAILED;
} }
if (user_mode(ctxt->regs))
return ES_UNSUPPORTED;
switch (mmio) { switch (mmio) {
case INSN_MMIO_WRITE: case INSN_MMIO_WRITE:
memcpy(ghcb->shared_buffer, reg_data, bytes); memcpy(ghcb->shared_buffer, reg_data, bytes);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment