linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Kees Cook <keescook@chromium.org>,
	"Reshetova, Elena" <elena.reshetova@intel.com>,
	Greg KH <gregkh@linuxfoundation.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>,
	"H. Peter Anvin" <h.peter.anvin@intel.com>,
	Will Deacon <will.deacon@arm.com>,
	David Windsor <dwindsor@gmail.com>,
	Hans Liljestrand <ishkamiel@gmail.com>,
	David Howells <dhowells@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"kernel-hardening@lists.openwall.com" 
	<kernel-hardening@lists.openwall.com>
Subject: Re: [kernel-hardening] Re: [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION
Date: Tue, 7 Feb 2017 11:10:12 +0000	[thread overview]
Message-ID: <20170207111011.GB28790@leverpostej> (raw)
In-Reply-To: <20170207083405.GV6500@twins.programming.kicks-ass.net>

On Tue, Feb 07, 2017 at 09:34:05AM +0100, Peter Zijlstra wrote:
> On Mon, Feb 06, 2017 at 08:54:38AM -0800, Kees Cook wrote:
> > >
> > > Like I wrote, ideally we'd end up using something like the x86 exception
> > > table with a custom handler. Just no idea how to pull that off without
> > > doing a full blown arch specific implementation, so I didn't go there
> > > quite yet.
> > 
> > I haven't spent much time looking at the extable stuff. (Though
> > coincidentally, I was poking at it for x86's test_nx stuff...) I
> > thought there was a way to build arch-agnostic extables already?
> > kernel/extable.c is unconditionally built-in, for example.
> 
> That doesn't seem to be of much use. It only contains section sort and
> search functions.
> 
> Another problem for generic code would be to figure out what register
> the relevant variable would live in at the time of exception. Here its
> 'obviously' EAX because that's what cmpxchg requires, but in generic
> you'd need a means of querying GCC's register allocator at the exception
> point and somehow using that information for the generation of the
> exception handler.

I think we only need two arch-specific primitives:
(a) mangle a GCC assigned register into an idx stored in the extable
(b) take said index, and grab the relevant register from pt_regs

Then you can have a BUG_VALUE(v, ...), where we use an input "r" (val),
and mangle that into the idx in the extable. In the common case, I'd
hope GCC would leave the register in-place from the cmpxchg.

... or have I misundertood? :)

Thanks,
Mark.

  reply	other threads:[~2017-02-07 11:11 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-03 23:26 [PATCH 0/4] refcount_t followups Kees Cook
2017-02-03 23:26 ` [PATCH 1/4] refcount_t: fix Kconfig help Kees Cook
2017-02-03 23:26 ` [PATCH 2/4] lkdtm: convert to refcount_t testing Kees Cook
2017-02-10  8:32   ` [tip:locking/core] lkdtm: Convert " tip-bot for Kees Cook
2017-02-03 23:26 ` [PATCH 3/4] bug: Switch data corruption check to __must_check Kees Cook
2017-02-03 23:26 ` [PATCH 4/4] refcount: Report failures through CHECK_DATA_CORRUPTION Kees Cook
2017-02-05 15:40   ` Peter Zijlstra
2017-02-05 23:33     ` Kees Cook
2017-02-06  8:57       ` Peter Zijlstra
2017-02-06 16:54         ` Kees Cook
2017-02-07  8:34           ` Peter Zijlstra
2017-02-07 11:10             ` Mark Rutland [this message]
2017-02-07 12:36               ` [kernel-hardening] " Peter Zijlstra
2017-02-07 13:50                 ` Mark Rutland
2017-02-07 15:07                   ` Peter Zijlstra
2017-02-07 16:03                     ` Mark Rutland
2017-02-07 17:30                       ` Peter Zijlstra
2017-02-07 17:55                         ` Mark Rutland
2017-02-08  9:12                           ` Peter Zijlstra
2017-02-08  9:43                             ` Peter Zijlstra
2017-02-08 14:10                             ` Mark Rutland
2017-02-08 21:20                             ` Kees Cook
2017-02-09 10:27                               ` Peter Zijlstra
2017-02-10 23:39                                 ` Kees Cook

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=20170207111011.GB28790@leverpostej \
    --to=mark.rutland@arm.com \
    --cc=arnd@arndb.de \
    --cc=dhowells@redhat.com \
    --cc=dwindsor@gmail.com \
    --cc=elena.reshetova@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=h.peter.anvin@intel.com \
    --cc=ishkamiel@gmail.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.com \
    /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).