Commit 46155377 authored by Marios Pomonis's avatar Marios Pomonis Committed by Greg Kroah-Hartman

KVM: x86: Protect x86_decode_insn from Spectre-v1/L1TF attacks

commit 3c9053a2 upstream.

This fixes a Spectre-v1/L1TF vulnerability in x86_decode_insn().
kvm_emulate_instruction() (an ancestor of x86_decode_insn()) is an exported
symbol, so KVM should treat it conservatively from a security perspective.

Fixes: 045a282c ("KVM: emulator: implement fninit, fnstsw, fnstcw")
Signed-off-by: default avatarNick Finco <nifi@google.com>
Signed-off-by: default avatarMarios Pomonis <pomonis@google.com>
Reviewed-by: default avatarAndrew Honig <ahonig@google.com>
Cc: stable@vger.kernel.org
Reviewed-by: default avatarJim Mattson <jmattson@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4599b98c
...@@ -5269,10 +5269,15 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len) ...@@ -5269,10 +5269,15 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len)
} }
break; break;
case Escape: case Escape:
if (ctxt->modrm > 0xbf) if (ctxt->modrm > 0xbf) {
opcode = opcode.u.esc->high[ctxt->modrm - 0xc0]; size_t size = ARRAY_SIZE(opcode.u.esc->high);
else u32 index = array_index_nospec(
ctxt->modrm - 0xc0, size);
opcode = opcode.u.esc->high[index];
} else {
opcode = opcode.u.esc->op[(ctxt->modrm >> 3) & 7]; opcode = opcode.u.esc->op[(ctxt->modrm >> 3) & 7];
}
break; break;
case InstrDual: case InstrDual:
if ((ctxt->modrm >> 6) == 3) if ((ctxt->modrm >> 6) == 3)
......
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