x86, mpx: fix instruction decoder condition
Subsystems (3)
PATCH 1/1 x86, mpx: fix instruction decoder condition
From: Dave Hansen <[email protected]>
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.
---
b/arch/x86/mm/mpx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/mm/mpx.c renamed from arch/x86/mm/mpx.c~mpx-rex +3 -3
@@ -101,19 +101,19 @@ static int get_reg_offset(struct insn *iswitch (type) {case REG_TYPE_RM : 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 ;break ;case REG_TYPE_INDEX : 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 ;break ;case REG_TYPE_BASE : 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 ;break ;
_
tip-bot for Dave Hansen
merge bot[tip:x86/urgent] x86/mpx: Fix instruction decoder condition
x86/mpx: Fix instruction decoder condition
Commit-ID: 8e8efe0379bd93e8219ca0fc6fa80b5dd85b09cb Gitweb: http://git.kernel.org/tip/8e8efe0379bd93e8219ca0fc6fa80b5dd85b09cb Author: Dave Hansen <[email protected]> AuthorDate: Mon, 30 Nov 2015 16:31:13 -0800 Committer: Thomas Gleixner <[email protected]> CommitDate: Sat, 5 Dec 2015 18:52:14 +0100
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.
--- arch/x86/mm/mpx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/mm/mpx.c +3 -3
@@ -101,19 +101,19 @@ static int get_reg_offset(struct insn *insn, struct pt_regs *regs,switch (type) {case REG_TYPE_RM : 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 ;break ;case REG_TYPE_INDEX : 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 ;break ;case REG_TYPE_BASE : 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 ;break ;