From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/4] arm64: unwind: reference pt_regs via embedded stack frame
Date: Tue, 25 Jul 2017 14:58:34 +0100 [thread overview]
Message-ID: <20170725135833.GA8372@leverpostej> (raw)
In-Reply-To: <20170725131303.GA28815@arm.com>
On Tue, Jul 25, 2017 at 02:13:03PM +0100, Will Deacon wrote:
> On Mon, Jul 24, 2017 at 06:54:46PM +0100, Mark Rutland wrote:
> > On Mon, Jul 24, 2017 at 12:26:22PM +0100, Ard Biesheuvel wrote:
> > So here, we're using information from three records (where the last
> > might have been faked from the current FP + LR). We look at the previous
> > frame's LR value to determine whether the current frame's fp points to a
> > next frame that's associated with some regs:
> >
> > +----+----------------+
> > | fp | interrupted PC | /* embedded in pt_regs */
> > +----+----------------+
> > /\
> > ||
> > +----+----------------+
> > where => | fp | < entry PC > |
> > +----+----------------+
> > /\
> > ||
> > +----+----------------+
> > | fp | where | /* "where" is in exception text */
> > +----+----------------+
> >
> > Which (IIUC) has three problems, inherited from the existing approach.
> >
> > 1) Several C functions called from exception entry assembly are missing
> > __exception annotations. e.g. bad_mode.
> >
> > So we can miss exception regs in some cases.
> >
> > 2) Several functions may be called either from the exception entry
> > assembly, or from other C code. e.g. do_undefinstr, and any cascaded
> > irqchip handlers.
> >
> > So we can spuriously decide part of the stack is a pt_regs.
> >
> > 3) The entry assembly can enable exceptions before calling C code, so if
> > an exception is taken at the right time, these will eb in the
> > backtrace without a surrounding frame in the exception text.
> >
> > So we can miss exception regs in some cases (distinct from (1)).
> >
> > ... given that, I don't think we can rely on in_exception_text(). I
> > think we have to look at whether the current frame's PC/LR is in
> > .entry.text.
>
> Looking around, I think most (all?) users of in_exception_text and the
> associated linker script labels suffer from similar problems. AFAICT, these
> are:
>
> kprobes - Used to blacklist probes, but omits entry code
> ftrace - For graph tracer backtracing; attempted to hack around the
> problem in 9a5ad7d0e3e1 but still excludes .entry.text
> kasan - Duplicates ftrace stuff in core code, but also checks
> against softirqentry
>
> So it looks like we should either include the entry text in these sections
> or avoid using these functions altogether (eventually removing them). It
> needn't hold this series up, but worth considering.
>
> What do you think?
Agreed; this is currently a mess, and I don't think it's possible to
make portable inferences based on these sections. This will all need an
audit.
As you say, I think that needn't hold this series up, as those are
orthogonal issues. I'm happy to dig into those in the coming weeks.
The kasan case isn't too problematic. It only affects where an
alloc/free stacktrace gets trimmed for an alloc/free in an IRQ handler,
so in the worst case we just lose a few frames beyond the inner irqchip
handler in the dumped backtrace.
For kprobes/ftrace, I'd need to do some further digging.
I'd looked at cleaning up .irqentry.text in the past (as part of further
arm64/entry-deasm work). It's typically used to find the task->IRQ (or
X->IRQ) transition. That can be cleaned up by having a single
(annotated) arch-specific entry point that invokes (unannotated) irqchip
handlers. This would fix kasan, at least.
Thanks,
Mark.
next prev parent reply other threads:[~2017-07-25 13:58 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-24 11:26 [PATCH 0/4] arm64: unwind: fix broken exception stack dump Ard Biesheuvel
2017-07-24 11:26 ` [PATCH 1/4] arm64: avoid percpu indirection for irq stack ops Ard Biesheuvel
2017-07-24 11:26 ` [PATCH 2/4] arm64: unwind: disregard frame.sp when validating frame pointer Ard Biesheuvel
2017-07-24 11:26 ` [PATCH 3/4] arm64: unwind: reference pt_regs via embedded stack frame Ard Biesheuvel
2017-07-24 17:54 ` Mark Rutland
2017-07-24 18:34 ` Ard Biesheuvel
2017-07-24 19:09 ` Ard Biesheuvel
2017-07-25 9:53 ` Mark Rutland
2017-07-25 10:07 ` Ard Biesheuvel
2017-07-25 13:13 ` Will Deacon
2017-07-25 13:58 ` Mark Rutland [this message]
2017-07-24 11:26 ` [PATCH 4/4] arm64: unwind: remove sp from struct stackframe Ard Biesheuvel
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=20170725135833.GA8372@leverpostej \
--to=mark.rutland@arm.com \
--cc=linux-arm-kernel@lists.infradead.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