Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-26 Thread Andi Kleen
Ingo Molnar writes: > > Especially on modern x86 CPUs with stack engines (latest Intel and AMD > CPUs) that keeps ESP updates out of the later stages of execution > pipelines, going from RBP framepointers to direct ESP use is > beneficial to performance and compresses I$ footprint as well: Not

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-23 Thread Borislav Petkov
On Fri, May 22, 2015 at 09:32:12AM -0500, Josh Poimboeuf wrote: > If instead the above code were patched into a non-leaf function, we'd > have to change it to restore the frame pointer before returning. Not a problem, I think. One'll need to add the FP restoring before the retq. -- Regards/Gruss

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-22 Thread Josh Poimboeuf
On Fri, May 22, 2015 at 11:18:57PM +0200, Jiri Kosina wrote: > On Fri, 22 May 2015, Josh Poimboeuf wrote: > > > Hm, alternatives do complicate things a bit. It *is* a false positive, > > but not necessarily because its part of an alternative instruction > > block. > > > > The above code would be

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-22 Thread Jiri Kosina
On Fri, 22 May 2015, Josh Poimboeuf wrote: > Hm, alternatives do complicate things a bit. It *is* a false positive, > but not necessarily because its part of an alternative instruction > block. > > The above code would be patched into memmove(), which is a leaf function > because it doesn't call

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-22 Thread Josh Poimboeuf
On Thu, May 21, 2015 at 02:53:07PM -0700, Andy Lutomirski wrote: > On Thu, May 21, 2015 at 1:54 PM, Josh Poimboeuf wrote: > > After removing the frame pointer checks for leaf functions, and adding a > > check for all functions which jump outside of their scope, the number of > > defconfig warnings

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-22 Thread Josh Poimboeuf
On Fri, May 22, 2015 at 12:01:58AM +0200, Borislav Petkov wrote: > On Thu, May 21, 2015 at 03:54:25PM -0500, Josh Poimboeuf wrote: > > stackvalidate: arch/x86/lib/memmove_64.o: return instruction outside of a > > function at .altinstr_replacement+0x5 > > That must be something like this: > > 000

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-21 Thread Borislav Petkov
On Thu, May 21, 2015 at 03:54:25PM -0500, Josh Poimboeuf wrote: > stackvalidate: arch/x86/lib/memmove_64.o: return instruction outside of a > function at .altinstr_replacement+0x5 That must be something like this: <.altinstr_replacement>: 0: 48 89 d1mov%

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-21 Thread Andy Lutomirski
On Thu, May 21, 2015 at 1:54 PM, Josh Poimboeuf wrote: > On Wed, May 20, 2015 at 04:48:10PM +0200, Ingo Molnar wrote: >> Yeah, so many of these seem to be 'leaf only' functions: functions >> that don't ever call functions themselves. >> >> So lets assume we always have CONFIG_FRAME_POINTERS=y. >>

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-21 Thread Josh Poimboeuf
On Wed, May 20, 2015 at 04:48:10PM +0200, Ingo Molnar wrote: > Yeah, so many of these seem to be 'leaf only' functions: functions > that don't ever call functions themselves. > > So lets assume we always have CONFIG_FRAME_POINTERS=y. > > If they don't set up a frame pointer then they in essence

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-21 Thread Ingo Molnar
* Ingo Molnar wrote: > Especially on modern x86 CPUs with stack engines (latest Intel and > AMD CPUs) that keeps ESP updates out of the later stages of > execution pipelines, going from RBP framepointers to direct ESP use > is beneficial to performance and compresses I$ footprint as well: >

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-21 Thread Ingo Molnar
* Borislav Petkov wrote: > On Thu, May 21, 2015 at 12:16:14PM +0200, Ingo Molnar wrote: > > So this is how we are printing backtraces on x86: > > > > This is pretty useful info and the question about the '?' keeps popping > up. > > How about I moved Documentation/x86/x86_64/kernel-stacks to

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-21 Thread Borislav Petkov
On Thu, May 21, 2015 at 12:16:14PM +0200, Ingo Molnar wrote: > So this is how we are printing backtraces on x86: This is pretty useful info and the question about the '?' keeps popping up. How about I moved Documentation/x86/x86_64/kernel-stacks to Documentation/x86/kernel-stacks and added that

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-21 Thread Ingo Molnar
* Josh Poimboeuf wrote: > On Wed, May 20, 2015 at 09:59:18AM -0700, Linus Torvalds wrote: > > On Wed, May 20, 2015 at 9:25 AM, Josh Poimboeuf wrote: > > > On Wed, May 20, 2015 at 09:03:37AM -0700, Andy Lutomirski wrote: > > >> > > >> I've never quite understood what the '?' means. > > > > > > I

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-21 Thread Ingo Molnar
* Borislav Petkov wrote: > On Wed, May 20, 2015 at 11:25:37AM -0500, Josh Poimboeuf wrote: > > > I've never quite understood what the '?' means. > > > > It basically means "here's a function address we found on the stack, > > which may or may not have been called." It's needed because stack >

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-21 Thread Ingo Molnar
* Linus Torvalds wrote: > On Wed, May 20, 2015 at 9:25 AM, Josh Poimboeuf wrote: > > On Wed, May 20, 2015 at 09:03:37AM -0700, Andy Lutomirski wrote: > >> > >> I've never quite understood what the '?' means. > > > > It basically means "here's a function address we found on the > > stack, which

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-20 Thread Jiri Kosina
On Wed, 20 May 2015, Peter Zijlstra wrote: > > I think it would be nice to have full DWARF unwind support for > > everything at some point. Unfortunately, I don't see any easy path to > > getting there. It doesn't help that AFAIK no one has ever proposed a > > usable in-kernel DWARF unwinder. >

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-20 Thread Peter Zijlstra
On Wed, May 20, 2015 at 09:03:37AM -0700, Andy Lutomirski wrote: > I think it would be nice to have full DWARF unwind support for > everything at some point. Unfortunately, I don't see any easy path to > getting there. It doesn't help that AFAIK no one has ever proposed a > usable in-kernel DWARF

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-20 Thread Josh Poimboeuf
On Wed, May 20, 2015 at 09:59:18AM -0700, Linus Torvalds wrote: > On Wed, May 20, 2015 at 9:25 AM, Josh Poimboeuf wrote: > > On Wed, May 20, 2015 at 09:03:37AM -0700, Andy Lutomirski wrote: > >> > >> I've never quite understood what the '?' means. > > > > It basically means "here's a function addr

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-20 Thread Linus Torvalds
On Wed, May 20, 2015 at 9:25 AM, Josh Poimboeuf wrote: > On Wed, May 20, 2015 at 09:03:37AM -0700, Andy Lutomirski wrote: >> >> I've never quite understood what the '?' means. > > It basically means "here's a function address we found on the stack, > which may or may not have been called." It's n

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-20 Thread Borislav Petkov
On Wed, May 20, 2015 at 11:25:37AM -0500, Josh Poimboeuf wrote: > > I've never quite understood what the '?' means. > > It basically means "here's a function address we found on the stack, > which may or may not have been called." It's needed because stack > walking isn't currently 100% reliable.

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-20 Thread Andy Lutomirski
On Wed, May 20, 2015 at 9:25 AM, Josh Poimboeuf wrote: > On Wed, May 20, 2015 at 09:03:37AM -0700, Andy Lutomirski wrote: >> On Wed, May 20, 2015 at 7:48 AM, Ingo Molnar wrote: >> > Yeah, so many of these seem to be 'leaf only' functions: functions >> > that don't ever call functions themselves.

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-20 Thread Josh Poimboeuf
On Wed, May 20, 2015 at 09:03:37AM -0700, Andy Lutomirski wrote: > On Wed, May 20, 2015 at 7:48 AM, Ingo Molnar wrote: > > Yeah, so many of these seem to be 'leaf only' functions: functions > > that don't ever call functions themselves. > > > > So lets assume we always have CONFIG_FRAME_POINTERS=y

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-20 Thread Josh Poimboeuf
On Wed, May 20, 2015 at 10:51:56AM -0500, Josh Poimboeuf wrote: > On Wed, May 20, 2015 at 04:48:10PM +0200, Ingo Molnar wrote: > > Yeah, so many of these seem to be 'leaf only' functions: functions > > that don't ever call functions themselves. > > Yeah, good observation. > > > So lets assume we

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-20 Thread Andy Lutomirski
On Wed, May 20, 2015 at 7:48 AM, Ingo Molnar wrote: > > * Josh Poimboeuf wrote: > >> On Wed, May 20, 2015 at 12:33:39PM +0200, Ingo Molnar wrote: >> > >> > * Josh Poimboeuf wrote: >> > >> > > In discussions around the live kernel patching consistency model RFC >> > > [1], Peter and Ingo correctl

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-20 Thread Josh Poimboeuf
On Wed, May 20, 2015 at 04:48:10PM +0200, Ingo Molnar wrote: > > * Josh Poimboeuf wrote: > > > On Wed, May 20, 2015 at 12:33:39PM +0200, Ingo Molnar wrote: > > > > > > * Josh Poimboeuf wrote: > > > > > > > In discussions around the live kernel patching consistency model RFC > > > > [1], Peter

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-20 Thread Ingo Molnar
* Josh Poimboeuf wrote: > On Wed, May 20, 2015 at 12:33:39PM +0200, Ingo Molnar wrote: > > > > * Josh Poimboeuf wrote: > > > > > In discussions around the live kernel patching consistency model RFC > > > [1], Peter and Ingo correctly pointed out that stack traces aren't > > > reliable. And a

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-20 Thread Josh Poimboeuf
On Wed, May 20, 2015 at 12:33:39PM +0200, Ingo Molnar wrote: > > * Josh Poimboeuf wrote: > > > In discussions around the live kernel patching consistency model RFC > > [1], Peter and Ingo correctly pointed out that stack traces aren't > > reliable. And as Ingo said, there's no "strong force" wh

Re: [PATCH v4 0/3] Compile-time stack frame pointer validation

2015-05-20 Thread Ingo Molnar
* Josh Poimboeuf wrote: > In discussions around the live kernel patching consistency model RFC > [1], Peter and Ingo correctly pointed out that stack traces aren't > reliable. And as Ingo said, there's no "strong force" which ensures we > can rely on them. > > So I've been thinking about how t