Skip to content

Commit a37cd2a

Browse files
committed
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: 0118b60 ("x86/sev-es: Handle MMIO String Instructions") Reported-by: Tom Dohrmann <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Tested-by: Tom Dohrmann <[email protected]> Cc: <[email protected]>
1 parent 8a749fd commit a37cd2a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/x86/kernel/sev.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,9 @@ static enum es_result vc_handle_mmio(struct ghcb *ghcb, struct es_em_ctxt *ctxt)
15091509
return ES_DECODE_FAILED;
15101510
}
15111511

1512+
if (user_mode(ctxt->regs))
1513+
return ES_UNSUPPORTED;
1514+
15121515
switch (mmio) {
15131516
case INSN_MMIO_WRITE:
15141517
memcpy(ghcb->shared_buffer, reg_data, bytes);

0 commit comments

Comments
 (0)