From: dave.martin@linaro.org (Dave Martin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] ARM: unwind: enable dumping stacks for SMP && ARM_UNWIND
Date: Fri, 12 Oct 2012 11:02:42 +0100 [thread overview]
Message-ID: <20121012100242.GA2126@linaro.org> (raw)
In-Reply-To: <20121012090807.GB21164@n2100.arm.linux.org.uk>
On Fri, Oct 12, 2012 at 10:08:07AM +0100, Russell King - ARM Linux wrote:
> On Sun, Aug 26, 2012 at 03:46:56PM -0700, Colin Cross wrote:
> > Unwinding with CONFIG_ARM_UNWIND is much more complicated than
> > unwinding with CONFIG_FRAME_POINTER, but there are only a few points
> > that require validation in order to avoid faults or infinite loops.
> > Avoiding faults is easy by adding checks to verify that all accesses
> > relative to the frame's stack pointer remain inside the stack.
> >
> > When CONFIG_FRAME_POINTER is not set it is possible for two frames to
> > have the same SP, so there is no way to avoid repeated calls to
> > unwind_frame continuing forever.
>
> So here you admit that this patch can cause the unwinder to loop forever,
> which would provide no way out of that. Why do you think this patch is
> suitable for mainline with such a problem?
With CONFIG_FRAME_POINTER we have a straightforward definition of
progress: the sp must increase per frame, and cannot increase beyond the
limit of the tasks stack. We get this property from the fact that
each frame record consumes actual space on the stack. If we parse a
frame record which does not both increase the sp and provide a frame
address greater than that sp, we know that frame is garbage and we must
stop.
With CONFIG_ARM_UNWIND, we have no straightforward definition of
progress. However, sp must _normally_ still increase, because compiler-
generated non-leaf functions must store the lr somewhere, and the
compiler always uses the stack. Even if lr is stashed in r4, an ABI
compliant would then have needed to save r4 on the stack beforehand.
We can assume that we will never parse a garbage unwind table because of
the way the table lookup works (though we may parse a valid table which
has nothing whatever to do with the code that was executing in the case
of a corrupted stack). So we only need to worry about what the unwind
tables will look like for valid functions.
Nonetheless, tail-call-optimised and manually-annotated functions may
have unusual frames which don't consume any stack. Stackless tail-
call-optimised functions shouldn't be a problem, since their frames
are completely missing from the backtrace and won't dump us into a loop.
Stackless assembler functions are overwhelmingly likely to be leaf
functions, giving us just one stackless frame.
Would it make sense if we place some small sanity limit on the number
of frames the unwinder will process with the same sp before giving up?
Cheers
---Dave
next prev parent reply other threads:[~2012-10-12 10:02 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-26 22:46 [PATCH 0/2] ARM: enable dumping stacks for CONFIG_SMP Colin Cross
2012-08-26 22:46 ` [PATCH 1/2] ARM: stacktrace: enable dumping stacks for SMP && FRAME_POINTER Colin Cross
2012-08-26 22:46 ` [PATCH 2/2] ARM: unwind: enable dumping stacks for SMP && ARM_UNWIND Colin Cross
2012-10-12 0:52 ` Laura Abbott
2012-10-12 9:08 ` Russell King - ARM Linux
2012-10-12 10:02 ` Dave Martin [this message]
2012-10-16 2:15 ` Colin Cross
2012-10-16 10:12 ` Dave Martin
2012-10-16 10:55 ` Russell King - ARM Linux
2012-10-16 12:26 ` Dave Martin
2012-10-16 21:53 ` Colin Cross
2012-10-16 21:30 ` Colin Cross
2012-10-18 6:43 ` Dave Martin
2012-09-23 2:52 ` [PATCH 0/2] ARM: enable dumping stacks for CONFIG_SMP Colin Cross
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=20121012100242.GA2126@linaro.org \
--to=dave.martin@linaro.org \
--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;
as well as URLs for NNTP newsgroup(s).