All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Qiaowei Ren <qiaowei.ren@intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] x86, mpx: hook #BR exception handler to allocate bound tables
Date: Sun, 12 Jan 2014 10:20:19 +0100	[thread overview]
Message-ID: <20140112092019.GA3664@pd.tnic> (raw)
In-Reply-To: <1389518403-7715-2-git-send-email-qiaowei.ren@intel.com>

On Sun, Jan 12, 2014 at 05:20:00PM +0800, Qiaowei Ren wrote:
> An access to an invalid bound directory entry will cause a #BR
> exception. This patch hook #BR exception handler to allocate
> one bound table and bind it with that buond directory entry.
> 
> This will avoid the need of forwarding the #BR exception
> to the user space when bound directory has invalid entry.
> 
> Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
> ---
>  arch/x86/include/asm/mpx.h |   35 +++++++++++++++++++++++++++++++++
>  arch/x86/kernel/Makefile   |    1 +
>  arch/x86/kernel/mpx.c      |   44 ++++++++++++++++++++++++++++++++++++++++++
>  arch/x86/kernel/traps.c    |   46 +++++++++++++++++++++++++++++++++++++++++++-
>  4 files changed, 125 insertions(+), 1 deletions(-)
>  create mode 100644 arch/x86/include/asm/mpx.h
>  create mode 100644 arch/x86/kernel/mpx.c

...

> diff --git a/arch/x86/kernel/mpx.c b/arch/x86/kernel/mpx.c
> new file mode 100644
> index 0000000..767b3bf
> --- /dev/null
> +++ b/arch/x86/kernel/mpx.c
> @@ -0,0 +1,44 @@
> +#include <linux/kernel.h>
> +#include <linux/syscalls.h>
> +#include <asm/processor.h>
> +#include <asm/mpx.h>
> +#include <asm/mman.h>
> +#include <asm/i387.h>
> +#include <asm/fpu-internal.h>
> +#include <asm/alternative.h>
> +
> +static bool allocate_bt(unsigned long bd_entry)
> +{
> +	unsigned long bt_size = 1UL << (MPX_L2_BITS+MPX_L2_SHIFT);
> +	unsigned long bt_addr, old_val;
> +
> +	bt_addr = sys_mmap_pgoff(0, bt_size, PROT_READ | PROT_WRITE,
> +			MAP_ANONYMOUS | MAP_PRIVATE | MAP_POPULATE, -1, 0);

Are we sure about this? We can do a possible memory allocation in
mmap_region() in this exception handler context. And yes, we do a
conditional_sti(), which makes it all the more susceptible.

Have you run this with lockdep enabled?

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--

  reply	other threads:[~2014-01-12  9:20 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-12  9:19 [PATCH 1/5] x86, mpx: add documentation on Intel MPX Qiaowei Ren
2014-01-12  9:20 ` [PATCH 2/5] x86, mpx: hook #BR exception handler to allocate bound tables Qiaowei Ren
2014-01-12  9:20   ` Borislav Petkov [this message]
2014-01-13  3:17     ` Ren Qiaowei
2014-01-13 10:38       ` Borislav Petkov
2014-01-17 14:47         ` Ren, Qiaowei
2014-01-17 16:47           ` Borislav Petkov
2014-01-17 16:51             ` H. Peter Anvin
2014-01-17 17:14               ` Steven Rostedt
2014-01-17 17:51                 ` H. Peter Anvin
2014-01-19 12:50                 ` Ren, Qiaowei
2014-01-17 17:10             ` Steven Rostedt
2014-01-17 16:31         ` H. Peter Anvin
2014-01-17 16:48           ` Borislav Petkov
2014-01-17 16:51             ` H. Peter Anvin
2014-01-17 16:56               ` Borislav Petkov
2014-01-17 16:58                 ` H. Peter Anvin
2014-01-17 17:04                   ` Borislav Petkov
2014-01-17 17:30                     ` H. Peter Anvin
2014-01-17 18:23                       ` Borislav Petkov
2014-01-17 18:25                         ` H. Peter Anvin
2014-01-12  9:20 ` [PATCH 3/5] x86, mpx: add prctl commands PR_MPX_INIT, PR_MPX_RELEASE Qiaowei Ren
2014-01-12  9:20 ` [PATCH 4/5] x86, mpx: add MPX related opcodes to the x86 opcode map Qiaowei Ren
2014-01-17 19:04   ` H. Peter Anvin
2014-01-17 19:22   ` [tip:x86/mpx] x86, mpx: Add " tip-bot for Qiaowei Ren
2014-01-12  9:20 ` [PATCH 5/5] x86, mpx: extend siginfo structure to include bound violation information Qiaowei Ren
2014-01-12  9:30   ` Borislav Petkov
2014-01-12 16:49     ` H. Peter Anvin
2014-01-12 17:03       ` Borislav Petkov
2014-01-12 17:06         ` H. Peter Anvin
2014-01-13  3:09         ` Ren Qiaowei
2014-01-13  8:22           ` Ren Qiaowei
2014-01-13 10:43             ` Borislav Petkov
2014-01-17 14:55               ` Ren, Qiaowei

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=20140112092019.GA3664@pd.tnic \
    --to=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=qiaowei.ren@intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.