Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1179130 > unrolled thread

Re: [PATCH v6 0/4] Compile-time stack validation

Started byJosh Poimboeuf <jpoimboe@redhat.com>
First post2015-07-08 00:40 +0200
Last post2015-07-08 00:40 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v6 0/4] Compile-time stack validation Josh Poimboeuf <jpoimboe@redhat.com> - 2015-07-08 00:40 +0200

#1179130 — Re: [PATCH v6 0/4] Compile-time stack validation

FromJosh Poimboeuf <jpoimboe@redhat.com>
Date2015-07-08 00:40 +0200
SubjectRe: [PATCH v6 0/4] Compile-time stack validation
Message-ID<pJJGW-32H-31@gated-at.bofh.it>
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/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web