linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: "Levin, Alexander (Sasha Levin)" <alexander.levin@verizon.com>
Cc: "x86@kernel.org" <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"live-patching@vger.kernel.org" <live-patching@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andy Lutomirski <luto@kernel.org>, Jiri Slaby <jslaby@suse.cz>,
	Ingo Molnar <mingo@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Mike Galbraith <efault@gmx.de>
Subject: Re: [PATCH v4 1/2] x86/unwind: add ORC unwinder
Date: Tue, 8 Aug 2017 13:58:09 -0500	[thread overview]
Message-ID: <20170808185809.qaug762cj7nw3bcd@treble> (raw)
In-Reply-To: <20170729035437.fmnxmeedrq55bpwm@treble>

On Fri, Jul 28, 2017 at 10:54:37PM -0500, Josh Poimboeuf wrote:
> On Fri, Jul 28, 2017 at 07:59:12PM +0000, Levin, Alexander (Sasha Levin) wrote:
> > On Fri, Jul 28, 2017 at 01:57:20PM -0500, Josh Poimboeuf wrote:
> > >Thanks, that's much better.  I'm relieved the unwinder didn't screw that
> > >up, at least.
> > >
> > >This looks like a tricky one.  Is it easily recreatable?
> > 
> > Yeah, I just hit it again with slightly different initial calls:
> 
> Sasha sent me some data privately.  As I suspected, the cause is some
> bad ORC data.  Objtool incorrectly assumes that once the frame pointer
> is set up, it no longer gets touched.

So as it turns out, my pre-vacation self was completely wrong.  The
problem is actually some runtime instruction patching which affects the
accuracy of the ORC data.

Take for example the lock_is_held_type() function.  In vmlinux, it has
the following instruction:

  callq *0xffffffff85a94880 (pv_irq_ops.save_fl)

At runtime, that instruction is patched and replaced with a fast inline
version of arch_local_save_flags() which eliminates the call:

  pushfq
  pop %rax

The problem is when an interrupt hits after the push:

  pushfq
  --- irq ---
  pop %rax

The push offsets the stack pointer by 8 bytes, confusing the ORC
unwinder when it tries to unwind from the IRQ.

The race should be somewhat rare, though Sasha has no problems hitting
it with syzkaller.

I'm not sure what the solution should be.  It will probably need to be
one of the following:

  a) either don't allow runtime "alternative" patches to mess with the
     stack pointer (objtool could enforce this); or

  b) come up with some way to register such patches with the ORC
     unwinder at runtime.

I haven't looked much at either option to see how feasible they would
be.

Any thoughts/opinions?

-- 
Josh

  reply	other threads:[~2017-08-08 18:58 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-24 23:36 [PATCH v4 0/2] ORC unwinder Josh Poimboeuf
2017-07-24 23:36 ` [PATCH v4 1/2] x86/unwind: add " Josh Poimboeuf
2017-07-26 12:10   ` [tip:x86/asm] x86/unwind: Add the " tip-bot for Josh Poimboeuf
2017-07-28 16:48   ` [PATCH v4 1/2] x86/unwind: add " Levin, Alexander (Sasha Levin)
2017-07-28 17:52     ` Josh Poimboeuf
2017-07-28 18:29       ` Levin, Alexander (Sasha Levin)
2017-07-28 18:57         ` Josh Poimboeuf
2017-07-28 19:59           ` Levin, Alexander (Sasha Levin)
2017-07-29  3:54             ` Josh Poimboeuf
2017-08-08 18:58               ` Josh Poimboeuf [this message]
2017-08-08 19:03                 ` Linus Torvalds
2017-08-08 19:13                   ` Josh Poimboeuf
2017-08-08 20:09                     ` Andy Lutomirski
2017-08-08 22:00                       ` Josh Poimboeuf
2017-08-09  8:49                       ` Juergen Gross
2017-08-09  9:16                         ` Peter Zijlstra
2017-08-09  9:24                           ` Juergen Gross
2017-08-09  9:35                             ` Peter Zijlstra
2017-08-09  9:55                               ` Juergen Gross
2017-08-09 20:15                                 ` Josh Poimboeuf
2017-08-10  7:05                                   ` Juergen Gross
2017-08-10 14:09                                     ` Josh Poimboeuf
2017-08-10 14:24                                       ` Juergen Gross
2017-08-10 14:39                                         ` Josh Poimboeuf
2017-08-10 14:59                                           ` Juergen Gross
2017-08-10 15:49                                             ` Josh Poimboeuf
2017-08-10 14:42                                       ` Josh Poimboeuf
2017-08-09 16:11                         ` Andy Lutomirski
2017-08-09 17:52                           ` Juergen Gross
2017-09-27 21:08                       ` Josh Poimboeuf
2017-09-28  6:03                         ` Juergen Gross
2017-09-28 13:55                           ` Josh Poimboeuf
2017-09-28 13:58                             ` Juergen Gross
2017-07-24 23:36 ` [PATCH v4 2/2] x86/kconfig: make it easier to switch to the new " Josh Poimboeuf
2017-07-25  9:10   ` Ingo Molnar
2017-07-25 13:54     ` Josh Poimboeuf
2017-07-26 12:11       ` [tip:x86/asm] x86/kconfig: Consolidate unwinders into multiple choice selection tip-bot for Josh Poimboeuf
2017-07-26 12:10   ` [tip:x86/asm] x86/kconfig: Make it easier to switch to the new ORC unwinder tip-bot for Josh Poimboeuf

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=20170808185809.qaug762cj7nw3bcd@treble \
    --to=jpoimboe@redhat.com \
    --cc=alexander.levin@verizon.com \
    --cc=efault@gmx.de \
    --cc=hpa@zytor.com \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).