linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@linux.intel.com>
To: Andy Lutomirski <luto@amacapital.net>,
	linux-kernel@vger.kernel.org, x86@kernel.org,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 3.19 1/3] x86, mpx: Check user mode bitness correctly when decoding instructions
Date: Wed, 07 Jan 2015 09:22:50 -0800	[thread overview]
Message-ID: <54AD6B6A.4000701@linux.intel.com> (raw)
In-Reply-To: <8207ea76edd142f4a118ad3093b28ec422d92e53.1419900414.git.luto@amacapital.net>

On 12/29/2014 04:52 PM, Andy Lutomirski wrote:
> --- a/arch/x86/mm/mpx.c
> +++ b/arch/x86/mm/mpx.c
> @@ -217,7 +217,7 @@ static int mpx_insn_decode(struct insn *insn,
>  			   struct pt_regs *regs)
>  {
>  	unsigned char buf[MAX_INSN_SIZE];
> -	int x86_64 = !test_thread_flag(TIF_IA32);
> +	int x86_64 = user_64bit_mode(regs);
>  	int not_copied;
>  	int nr_copied;

There are (at least) 3 other uses of the instruction decoder that use
some form of a check on TIF_IA32:

> perf_event_intel_ds.c  intel_pmu_pebs_fixup_ip 785 insn_init(&insn, kaddr, size, is_64bit);
> perf_event_intel_lbr.c branch_type             532 insn_init(&insn, addr, bytes_read, is64);
> uprobes.c              uprobe_init_insn        222 insn_init(insn, auprobe->insn, sizeof(auprobe->insn), x86_64);

Basically doing this:

                is_64bit = kernel_ip(to) || !test_thread_flag(TIF_IA32);

So this method *must* work, at least in practice.

If userspace has MPX on and switches between 32 and 64-bit itself, the
kernel *and* the hardware will suddenly be trying to walk the bounds
tables in the wrong format.  I just don't see an application surviving
very long in that situation.

So I don't have a problem with doing this, long term, as long as we do
it for all of these locations and we do it in a consistent way.  For
MPX, we may even want to enforce that:

	!test_thread_flag(TIF_IA32) == user_64bit_mode(regs)

and freak out if that fails.

But I don't think it's 3.19 material.

  reply	other threads:[~2015-01-07 17:22 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-30  0:52 [PATCH 3.19 0/3] Possible MPX improvements for 3.19 Andy Lutomirski
2014-12-30  0:52 ` [PATCH 3.19 1/3] x86, mpx: Check user mode bitness correctly when decoding instructions Andy Lutomirski
2015-01-07 17:22   ` Dave Hansen [this message]
2015-01-12 22:48     ` Andy Lutomirski
2014-12-30  0:52 ` [PATCH 3.19 2/3] x86, mpx: Short-circuit the instruction decoder for unexpected opcodes Andy Lutomirski
2014-12-30  0:58   ` Andy Lutomirski
2014-12-30  0:52 ` [PATCH 3.19 3/3] x86, mpx: Change the MPX enable/disable API to arch_prctl Andy Lutomirski
2015-01-02  7:53   ` Dave Hansen
2015-01-05 20:42     ` Andi Kleen
2015-01-05 21:18       ` Dave Hansen
2015-01-05 23:04         ` Andy Lutomirski
2015-01-05 23:10           ` Dave Hansen
2015-01-05 23:22             ` Andy Lutomirski
2015-01-06  4:04           ` Andi Kleen
2015-01-06  5:59             ` Andy Lutomirski
2015-01-06 17:48               ` Dave Hansen
2015-01-06 18:06                 ` Andy Lutomirski
2015-01-06 18:30                   ` Dave Hansen
2015-01-06 18:41                     ` Andy Lutomirski
2015-01-06 18:54                       ` Dave Hansen
2015-01-06 19:16                         ` Andi Kleen
2015-01-06 19:51                           ` Andy Lutomirski
2015-01-06 21:22                             ` Andi Kleen
2015-01-06 21:34                               ` Andy Lutomirski
2015-01-06 21:39                                 ` Andi Kleen
2015-01-12 10:34                     ` Enkovich, Ilya
2015-01-07 23:18           ` Dave Hansen
2015-01-07 23:24             ` Andy Lutomirski

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=54AD6B6A.4000701@linux.intel.com \
    --to=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=tglx@linutronix.de \
    --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;
as well as URLs for NNTP newsgroup(s).