Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1179130
| From | Josh Poimboeuf <jpoimboe@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v6 0/4] Compile-time stack validation |
| Date | 2015-07-08 00:40 +0200 |
| Message-ID | <pJJGW-32H-31@gated-at.bofh.it> (permalink) |
| References | <pJCvM-6Ty-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
Re: [PATCH v6 0/4] Compile-time stack validation Josh Poimboeuf <jpoimboe@redhat.com> - 2015-07-08 00:40 +0200
csiph-web