From: Dave Hansen <dave@sr71.net>
To: linux-kernel@vger.kernel.org
Cc: Dave Hansen <dave@sr71.net>,
dave.hansen@linux.intel.com, dan.carpenter@oracle.com,
stable@vger.kernel.org, x86@kernel.org
Subject: [PATCH] x86, mpx: fix instruction decoder condition
Date: Mon, 30 Nov 2015 16:31:13 -0800 [thread overview]
Message-ID: <20151201003113.D800C1E0@viggo.jf.intel.com> (raw)
From: Dave Hansen <dave.hansen@linux.intel.com>
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.
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: stable@vger.kernel.org
Cc: x86@kernel.org
---
b/arch/x86/mm/mpx.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff -puN arch/x86/mm/mpx.c~mpx-rex arch/x86/mm/mpx.c
--- a/arch/x86/mm/mpx.c~mpx-rex 2015-11-30 15:33:32.393469377 -0800
+++ b/arch/x86/mm/mpx.c 2015-11-30 16:12:14.805379908 -0800
@@ -101,19 +101,19 @@ static int get_reg_offset(struct insn *i
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;
_
next reply other threads:[~2015-12-01 0:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-01 0:31 Dave Hansen [this message]
2015-12-05 17:54 ` [tip:x86/urgent] x86/mpx: Fix " tip-bot for Dave Hansen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151201003113.D800C1E0@viggo.jf.intel.com \
--to=dave@sr71.net \
--cc=dan.carpenter@oracle.com \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome