Skip to content

Commit 27b1fd6

Browse files
sean-jcbp3tk0v
authored andcommitted
x86/umip: Fix decoding of register forms of 0F 01 (SGDT and SIDT aliases)
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 <seanjc@google.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: stable@vger.kernel.org
1 parent 32278c6 commit 27b1fd6

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

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)