Skip to content

Commit

Permalink
x86/sev: Disable MMIO emulation from user mode
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
bp3tk0v committed Oct 9, 2023
1 parent 8a749fd commit a37cd2a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/x86/kernel/sev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit a37cd2a

Please sign in to comment.