From: Michael Ellerman <patch-notifications@ellerman.id.au>
To: Alan Modra <amodra@gmail.com>, Michael Neuling <mikey@neuling.org>
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: PowerPC/VDSO: Correct call frame information
Date: Thu, 20 Sep 2018 14:21:03 +1000 (AEST) [thread overview]
Message-ID: <42G3Sc0Dw1z9sBv@ozlabs.org> (raw)
In-Reply-To: <20180914034004.GP3174@bubble.grove.modra.org>
On Fri, 2018-09-14 at 03:40:04 UTC, Alan Modra wrote:
> Call Frame Information is used by gdb for back-traces and inserting
> breakpoints on function return for the "finish" command. This failed
> when inside __kernel_clock_gettime. More concerning than difficulty
> debugging is that CFI is also used by stack frame unwinding code to
> implement exceptions. If you have an app that needs to handle
> asynchronous exceptions for some reason, and you are unlucky enough to
> get one inside the VDSO time functions, your app will crash.
>
> What's wrong: There is control flow in __kernel_clock_gettime that
> reaches label 99 without saving lr in r12. CFI info however is
> interpreted by the unwinder without reference to control flow: It's a
> simple matter of "Execute all the CFI opcodes up to the current
> address". That means the unwinder thinks r12 contains the return
> address at label 99. Disabuse it of that notion by resetting CFI for
> the return address at label 99.
>
> Note that the ".cfi_restore lr" could have gone anywhere from the
> "mtlr r12" a few instructions earlier to the instruction at label 99.
> I put the CFI as late as possible, because in general that's best
> practice (and if possible grouped with other CFI in order to reduce
> the number of CFI opcodes executed when unwinding). Using r12 as the
> return address is perfectly fine after the "mtlr r12" since r12 on
> that code path still contains the return address.
>
> __get_datapage also has a CFI error. That function temporarily saves
> lr in r0, and reflects that fact with ".cfi_register lr,r0". A later
> use of r0 means the CFI at that point isn't correct, as r0 no longer
> contains the return address. Fix that too.
>
> Signed-off-by: Alan Modra <amodra@gmail.com>
> Tested-by: Reza Arbab <arbab@linux.ibm.com>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/56d20861c027498b5a1112b4f9f05b
cheers
next prev parent reply other threads:[~2018-09-20 4:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-13 23:27 [PATCH] Correct PowerPC VDSO call frame info Alan Modra
2018-09-14 0:01 ` Michael Neuling
2018-09-14 3:40 ` [PATCH] PowerPC/VDSO: Correct call frame information Alan Modra
2018-09-20 4:21 ` Michael Ellerman [this message]
2018-09-14 2:59 ` [PATCH] Correct PowerPC VDSO call frame info Reza Arbab
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=42G3Sc0Dw1z9sBv@ozlabs.org \
--to=patch-notifications@ellerman.id.au \
--cc=amodra@gmail.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mikey@neuling.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).