From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>
Cc: Michal Marek <mmarek@suse.cz>,
Peter Zijlstra <peterz@infradead.org>,
Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@alien8.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andi Kleen <andi@firstfloor.org>, Pedro Alves <palves@redhat.com>,
x86@kernel.org, live-patching@vger.kernel.org,
linux-kernel@vger.kernel.org, Martin Jambor <mjambor@suse.cz>,
Jiri Kosina <jkosina@suse.cz>,
Segher Boessenkool <segher@kernel.crashing.org>
Subject: Re: [PATCH v6 0/4] Compile-time stack validation
Date: Tue, 7 Jul 2015 17:35:19 -0500 [thread overview]
Message-ID: <20150707223519.GA31294@treble.redhat.com> (raw)
In-Reply-To: <cover.1436280380.git.jpoimboe@redhat.com>
On Tue, Jul 07, 2015 at 09:54:09AM -0500, Josh Poimboeuf wrote:
> I did some more looking and it turns out that inline assembly doesn't
> play nicely with frame pointers at all. If the inline asm is at the
> beginning of the function, gcc sometimes emits the inline asm code
> before setting up the frame pointer. That can break stack traces
> when the inline asm has a call instruction.
>
> That turns out to be a very common problem. Stackvalidate found 37 C
> object files which break frame pointer rules, thanks to inline asm.
>
> I don't know of a solution to this problem yet. Basically I think we
> need a way to ensure that gcc emits the frame pointer setup before
> inserting any inline asm (particularly when the inline asm has a call
> instruction).
A solution to this problem was posted by Segher Boessenkool in a related
thread on the gcc mailing list:
https://gcc.gnu.org/ml/gcc/2015-07/msg00080.html
The suggestion is to use something like:
register void *sp asm("%sp");
asm volatile("call func" : "+r"(sp));
I can confirm that it seems to fix the issue. (I had tried something
like this before, but I guess I wasn't able to get the incantation just
right.)
Thanks to Jiri for the pointer to the thread, and Martin for raising the
issue on the gcc list.
--
Josh
prev parent reply other threads:[~2015-07-07 22:35 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-07 14:54 Josh Poimboeuf
2015-07-07 14:54 ` [PATCH v6 1/4] x86/asm: Frame pointer macro cleanup Josh Poimboeuf
2015-07-07 14:54 ` [PATCH v6 2/4] x86/stackvalidate: Compile-time stack validation Josh Poimboeuf
2015-07-07 22:57 ` Andy Lutomirski
2015-07-07 23:29 ` Josh Poimboeuf
2015-07-07 23:35 ` Andy Lutomirski
2015-07-07 23:48 ` Josh Poimboeuf
2015-07-09 21:31 ` Josh Poimboeuf
2015-07-07 14:54 ` [PATCH v6 3/4] x86/stackvalidate: Add file and directory ignores Josh Poimboeuf
2015-07-07 14:54 ` [PATCH v6 4/4] stackvalidate: Add ignore macros Josh Poimboeuf
2015-07-07 22:00 ` Andy Lutomirski
2015-07-07 22:59 ` Josh Poimboeuf
2015-07-07 23:00 ` Andy Lutomirski
2015-07-07 23:38 ` Josh Poimboeuf
2015-07-07 15:06 ` [PATCH v6 0/4] Compile-time stack validation Josh Poimboeuf
2015-07-07 22:35 ` Josh Poimboeuf [this message]
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=20150707223519.GA31294@treble.redhat.com \
--to=jpoimboe@redhat.com \
--cc=andi@firstfloor.org \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=mjambor@suse.cz \
--cc=mmarek@suse.cz \
--cc=palves@redhat.com \
--cc=peterz@infradead.org \
--cc=segher@kernel.crashing.org \
--cc=tglx@linutronix.de \
--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
Powered by JetHome