Skip to content

Commit 8e8efe0

Browse files
hansendcKAGA-KOKO
authored andcommitted
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: fcc7ffd "x86, mpx: Decode MPX instruction to get bound violation information" Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Dave 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.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 70f1528 commit 8e8efe0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/x86/mm/mpx.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,19 @@ static int get_reg_offset(struct insn *insn, struct pt_regs *regs,
101101
switch (type) {
102102
case REG_TYPE_RM:
103103
regno = X86_MODRM_RM(insn->modrm.value);
104-
if (X86_REX_B(insn->rex_prefix.value) == 1)
104+
if (X86_REX_B(insn->rex_prefix.value))
105105
regno += 8;
106106
break;
107107

108108
case REG_TYPE_INDEX:
109109
regno = X86_SIB_INDEX(insn->sib.value);
110-
if (X86_REX_X(insn->rex_prefix.value) == 1)
110+
if (X86_REX_X(insn->rex_prefix.value))
111111
regno += 8;
112112
break;
113113

114114
case REG_TYPE_BASE:
115115
regno = X86_SIB_BASE(insn->sib.value);
116-
if (X86_REX_B(insn->rex_prefix.value) == 1)
116+
if (X86_REX_B(insn->rex_prefix.value))
117117
regno += 8;
118118
break;
119119

0 commit comments

Comments
 (0)