Skip to content

Commit f0fbf1b

Browse files
sean-jcjfvogel
authored andcommitted
x86/umip: Fix decoding of register forms of 0F 01 (SGDT and SIDT aliases)
commit 27b1fd62012dfe9d3eb8ecde344d7aa673695ecf upstream. Filter out the register forms of 0F 01 when determining whether or not to emulate in response to a potential UMIP violation #GP, as SGDT and SIDT only accept memory operands. The register variants of 0F 01 are used to encode instructions for things like VMX and SGX, i.e. not checking the Mod field would cause the kernel to incorrectly emulate on #GP, e.g. due to a CPL violation on VMLAUNCH. Fixes: 1e5db22 ("x86/umip: Add emulation code for UMIP instructions") Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Cc: [email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 93749fb7f6a4da2835fae06f54212929aa50e698) Signed-off-by: Jack Vogel <[email protected]>
1 parent 0ec8b8b commit f0fbf1b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

arch/x86/kernel/umip.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,19 @@ static int identify_insn(struct insn *insn)
163163
if (insn->opcode.bytes[1] == 0x1) {
164164
switch (X86_MODRM_REG(insn->modrm.value)) {
165165
case 0:
166+
/* The reg form of 0F 01 /0 encodes VMX instructions. */
167+
if (X86_MODRM_MOD(insn->modrm.value) == 3)
168+
return -EINVAL;
169+
166170
return UMIP_INST_SGDT;
167171
case 1:
172+
/*
173+
* The reg form of 0F 01 /1 encodes MONITOR/MWAIT,
174+
* STAC/CLAC, and ENCLS.
175+
*/
176+
if (X86_MODRM_MOD(insn->modrm.value) == 3)
177+
return -EINVAL;
178+
168179
return UMIP_INST_SIDT;
169180
case 4:
170181
return UMIP_INST_SMSW;

0 commit comments

Comments
 (0)