Commit 8e8efe03 authored by Dave Hansen's avatar Dave Hansen Committed by Thomas Gleixner

x86/mpx: Fix instruction decoder condition

MPX decodes instructions in order to tell which bounds register
was violated.  Part of this decoding involves looking at the "REX
prefix" which is a special instrucion prefix used to retrofit
support for new registers in to old instructions.

The X86_REX_*() macros are defined to return actual bit values:

	#define X86_REX_R(rex) ((rex) & 4)

*not* boolean values.  However, the MPX code was checking for
them like they were booleans.  This might have led to us
mis-decoding the "REX prefix" and giving false information out to
userspace about bounds violations.  X86_REX_B() actually is bit 1,
so this is really only broken for the X86_REX_X() case.

Fix the conditionals up to tolerate the non-boolean values.

Fixes: fcc7ffd6 "x86, mpx: Decode MPX instruction to get bound violation information"
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarDave Hansen <dave.hansen@linux.intel.com>
Cc: x86@kernel.org
Cc: Dave Hansen <dave@sr71.net>
Cc: stable@vger.kernel.org
Link: http://lkml.kernel.org/r/20151201003113.D800C1E0@viggo.jf.intel.comSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 70f15287
...@@ -101,19 +101,19 @@ static int get_reg_offset(struct insn *insn, struct pt_regs *regs, ...@@ -101,19 +101,19 @@ static int get_reg_offset(struct insn *insn, struct pt_regs *regs,
switch (type) { switch (type) {
case REG_TYPE_RM: case REG_TYPE_RM:
regno = X86_MODRM_RM(insn->modrm.value); regno = X86_MODRM_RM(insn->modrm.value);
if (X86_REX_B(insn->rex_prefix.value) == 1) if (X86_REX_B(insn->rex_prefix.value))
regno += 8; regno += 8;
break; break;
case REG_TYPE_INDEX: case REG_TYPE_INDEX:
regno = X86_SIB_INDEX(insn->sib.value); regno = X86_SIB_INDEX(insn->sib.value);
if (X86_REX_X(insn->rex_prefix.value) == 1) if (X86_REX_X(insn->rex_prefix.value))
regno += 8; regno += 8;
break; break;
case REG_TYPE_BASE: case REG_TYPE_BASE:
regno = X86_SIB_BASE(insn->sib.value); regno = X86_SIB_BASE(insn->sib.value);
if (X86_REX_B(insn->rex_prefix.value) == 1) if (X86_REX_B(insn->rex_prefix.value))
regno += 8; regno += 8;
break; break;
......
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