Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-07-18 Thread Florian Weimer
* Jeff Law: > On 06/28/2017 12:45 AM, Florian Weimer wrote: >> * Richard Earnshaw: >> >>> I can't help but feel there's a bit of a goode olde mediaeval witch hunt >>> going on here. As Wilco points out, we can never defend against a >>> function that is built without probe operations but skips t

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-07-13 Thread Jeff Law
On 06/28/2017 12:45 AM, Florian Weimer wrote: > * Richard Earnshaw: > >> I can't help but feel there's a bit of a goode olde mediaeval witch hunt >> going on here. As Wilco points out, we can never defend against a >> function that is built without probe operations but skips the entire >> guard z

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-27 Thread Florian Weimer
* Richard Earnshaw: > I can't help but feel there's a bit of a goode olde mediaeval witch hunt > going on here. As Wilco points out, we can never defend against a > function that is built without probe operations but skips the entire > guard zone. The only defence there is a larger guard zone, b

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-22 Thread Wilco Dijkstra
Jeff Law wrote: > You can be in one of 3 states when you start the callee's prologue. > > 1. You're somewhere in the normal stack. > > 2. You've past the guard and are already in the heap or elsewhere > > 3. You're somewhere in the guard > > State #3 is what we're trying to address.  The attacker h

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-22 Thread Jeff Law
On 06/22/2017 10:07 AM, Szabolcs Nagy wrote: > On 22/06/17 16:30, Jeff Law wrote: >> It just happens to be the case that x86 hits *sp when it stores the >> return pointer and that ppc always stores the backchain into *sp when it >> allocates additional stack space. As a result on those targets we

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-22 Thread Jeff Law
On 06/21/2017 11:47 AM, Wilco Dijkstra wrote: > Jeff Law wrote: > >> I'm a little confused. I'm not defining or changing the ABI. I'm >> working within my understanding of the existing aarch64 ABI used on >> linux systems. My understanding after reading that ABI and the prologue >> code for aar

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-22 Thread Szabolcs Nagy
On 22/06/17 16:30, Jeff Law wrote: > It just happens to be the case that x86 hits *sp when it stores the > return pointer and that ppc always stores the backchain into *sp when it > allocates additional stack space. As a result on those targets we know > the offset between the stack pointer and th

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-22 Thread Jeff Law
On 06/22/2017 03:53 AM, Richard Earnshaw (lists) wrote: > On 21/06/17 18:25, Jeff Law wrote: >> On 06/21/2017 02:41 AM, Richard Earnshaw (lists) wrote: >> But the stack pointer might have already been advanced into the guard page by the caller. For the sake of argument assume the guard

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-22 Thread Richard Earnshaw (lists)
On 21/06/17 18:25, Jeff Law wrote: > On 06/21/2017 02:41 AM, Richard Earnshaw (lists) wrote: > >>> But the stack pointer might have already been advanced into the guard >>> page by the caller. For the sake of argument assume the guard page is >>> 0xf1000 and assume that our stack pointer at entr

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-21 Thread Florian Weimer
On 06/20/2017 11:52 PM, Jeff Law wrote: > I've also wondered if a 2 page guard would solve some of these problems. > In the event of stack overflow, the kernel maps in one of the two pages > for use by the signal handler. But changing things at this point may > not be worth the effort. I think

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-21 Thread Wilco Dijkstra
Jeff Law wrote: > I'm a little confused.  I'm not defining or changing the ABI.  I'm > working within my understanding of the existing aarch64 ABI used on > linux systems.  My understanding after reading that ABI and the prologue > code for aarch64 is there's nothing that can currently be relied u

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-21 Thread Jeff Law
On 06/20/2017 04:20 PM, Eric Botcazou wrote: >> But what you end up depending on is undocumented behavior of a >> particular kernel implementation. That seems rather unwise. > > And it's the single example of such a thing in the entire codebase? > I don't know the code of the sanitizer much, but

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-21 Thread Jeff Law
On 06/21/2017 02:41 AM, Richard Earnshaw (lists) wrote: >> But the stack pointer might have already been advanced into the guard >> page by the caller. For the sake of argument assume the guard page is >> 0xf1000 and assume that our stack pointer at entry is 0xf1010 and that >> the caller hasn't

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-21 Thread Jeff Law
On 06/20/2017 05:22 PM, Wilco Dijkstra wrote: > Jeff Law wrote: >> But the stack pointer might have already been advanced into the guard >> page by the caller. For the sake of argument assume the guard page is >> 0xf1000 and assume that our stack pointer at entry is 0xf1010 and that >> the caller

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-21 Thread Wilco Dijkstra
Richard Earnshaw wrote: > A mere 256 bytes for the caller would permit 32 x 8byte arguments on the > stack which, with at least 8 parameters passed in registers, would allow > for calls with 40 parameters.  There can't be many in that space.  Any > function making calls with more than that might ne

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-21 Thread Richard Earnshaw (lists)
On 21/06/17 09:46, Richard Earnshaw (lists) wrote: > On 21/06/17 09:44, Andreas Schwab wrote: >> On Jun 21 2017, "Richard Earnshaw (lists)" wrote: >> >>> A mere 256 bytes for the caller would permit 32 x 8byte arguments on the >>> stack which, with at least 8 parameters passed in registers, would

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-21 Thread Richard Earnshaw (lists)
On 21/06/17 09:44, Andreas Schwab wrote: > On Jun 21 2017, "Richard Earnshaw (lists)" wrote: > >> A mere 256 bytes for the caller would permit 32 x 8byte arguments on the >> stack which, with at least 8 parameters passed in registers, would allow >> for calls with 40 parameters. There can't be m

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-21 Thread Andreas Schwab
On Jun 21 2017, "Richard Earnshaw (lists)" wrote: > A mere 256 bytes for the caller would permit 32 x 8byte arguments on the > stack which, with at least 8 parameters passed in registers, would allow > for calls with 40 parameters. There can't be many in that space. Any > function making calls

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-21 Thread Richard Earnshaw (lists)
On 20/06/17 22:39, Jeff Law wrote: > On 06/20/2017 03:27 AM, Richard Earnshaw (lists) wrote: >> On 19/06/17 18:07, Jeff Law wrote: >>> As some of you are likely aware, Qualys has just published fairly >>> detailed information on using stack/heap clashes as an attack vector. >>> Eric B, Michael M --

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-21 Thread Richard Earnshaw (lists)
On 21/06/17 00:22, Wilco Dijkstra wrote: > Jeff Law wrote: >> But the stack pointer might have already been advanced into the guard >> page by the caller. For the sake of argument assume the guard page is >> 0xf1000 and assume that our stack pointer at entry is 0xf1010 and that >> the caller hasn

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-21 Thread Andreas Schwab
On Jun 20 2017, Eric Botcazou wrote: > Right, because the Linux kernel for x86/x86-64 is the only OS flavor that > doesn't let you probe the stack ahead of the stack pointer. All other > combinations of OS and architecture we tried (and it's quite a lot) do. Take a look at do_page_fault in ar

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Wilco Dijkstra
Jeff Law wrote: > But the stack pointer might have already been advanced into the guard > page by the caller.   For the sake of argument assume the guard page is > 0xf1000 and assume that our stack pointer at entry is 0xf1010 and that > the caller hasn't touched the 0xf1000 page. > > If FrameSize >

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Eric Botcazou
> But what you end up depending on is undocumented behavior of a > particular kernel implementation. That seems rather unwise. And it's the single example of such a thing in the entire codebase? I don't know the code of the sanitizer much, but from the outside it looks full of similar tricks...

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Jeff Law
On 06/20/2017 06:27 AM, Richard Biener wrote: > On Tue, Jun 20, 2017 at 2:20 PM, Uros Bizjak wrote: >> On Tue, Jun 20, 2017 at 2:17 PM, Uros Bizjak wrote: >>> On Tue, Jun 20, 2017 at 2:13 PM, Florian Weimer wrote: On 06/20/2017 01:10 PM, Uros Bizjak wrote: > 74,99% a.outa.ou

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Jeff Law
On 06/20/2017 02:16 AM, Eric Botcazou wrote: > > Right, because the Linux kernel for x86/x86-64 is the only OS flavor that > doesn't let you probe the stack ahead of the stack pointer. All other > combinations of OS and architecture we tried (and it's quite a lot) do. But what you end up depend

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Jeff Law
On 06/20/2017 03:27 AM, Richard Earnshaw (lists) wrote: > On 19/06/17 18:07, Jeff Law wrote: >> As some of you are likely aware, Qualys has just published fairly >> detailed information on using stack/heap clashes as an attack vector. >> Eric B, Michael M -- sorry I couldn't say more when I contact

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Jeff Law
On 06/20/2017 02:37 PM, Eric Botcazou wrote: >> But then valgrind won't be able to find bugs in the code (storing and later >> reading stuff into the volatile parts of the stack that could be overwritten >> by any asynchronous signal). GCC had various bugs in this area and >> valgrind has been abl

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Eric Botcazou
> But then valgrind won't be able to find bugs in the code (storing and later > reading stuff into the volatile parts of the stack that could be overwritten > by any asynchronous signal). GCC had various bugs in this area and > valgrind has been able to report those. Unless the probe instruction

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Jakub Jelinek
On Tue, Jun 20, 2017 at 10:21:14AM +0200, Eric Botcazou wrote: > > Out of curiousity, does the old Alpha/VMS stack-checking API meet the > > requirements? From what I recall, I think it does. > > No, it's the usual probe-first-and-then-allocate strategy and Jeff rejects it > because of valgrind.

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Jeff Law
On 06/20/2017 06:17 AM, Uros Bizjak wrote: > On Tue, Jun 20, 2017 at 2:13 PM, Florian Weimer wrote: >> On 06/20/2017 01:10 PM, Uros Bizjak wrote: >> >>> 74,99% a.outa.out [.] test_or >>> 12,50% a.outa.out [.] test_movb >>> 12,50% a.outa.out [.] test_

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Jeff Law
On 06/20/2017 02:27 AM, Richard Earnshaw (lists) wrote: > On 19/06/17 20:04, Jeff Law wrote: >> On 06/19/2017 11:50 AM, Joseph Myers wrote: >>> On Mon, 19 Jun 2017, Jeff Law wrote: >>> A key point to remember is that you can never have an allocation (potentially using more than one alloca

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Jeff Law
On 06/20/2017 02:21 AM, Eric Botcazou wrote: >> Out of curiousity, does the old Alpha/VMS stack-checking API meet the >> requirements? From what I recall, I think it does. > > No, it's the usual probe-first-and-then-allocate strategy and Jeff rejects it > because of valgrind. I'd personally rat

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Richard Biener
On Tue, Jun 20, 2017 at 2:20 PM, Uros Bizjak wrote: > On Tue, Jun 20, 2017 at 2:17 PM, Uros Bizjak wrote: >> On Tue, Jun 20, 2017 at 2:13 PM, Florian Weimer wrote: >>> On 06/20/2017 01:10 PM, Uros Bizjak wrote: >>> 74,99% a.outa.out [.] test_or 12,50% a.outa.out

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Uros Bizjak
On Tue, Jun 20, 2017 at 2:17 PM, Uros Bizjak wrote: > On Tue, Jun 20, 2017 at 2:13 PM, Florian Weimer wrote: >> On 06/20/2017 01:10 PM, Uros Bizjak wrote: >> >>> 74,99% a.outa.out [.] test_or >>> 12,50% a.outa.out [.] test_movb >>> 12,50% a.outa.out

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Uros Bizjak
On Tue, Jun 20, 2017 at 2:13 PM, Florian Weimer wrote: > On 06/20/2017 01:10 PM, Uros Bizjak wrote: > >> 74,99% a.outa.out [.] test_or >> 12,50% a.outa.out [.] test_movb >> 12,50% a.outa.out [.] test_movl > > Could you try notl/notb/negl/negb as well

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Florian Weimer
On 06/20/2017 01:10 PM, Uros Bizjak wrote: > 74,99% a.outa.out [.] test_or > 12,50% a.outa.out [.] test_movb > 12,50% a.outa.out [.] test_movl Could you try notl/notb/negl/negb as well, please? Thanks, Florian

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Uros Bizjak
On Tue, Jun 20, 2017 at 12:18 PM, Richard Biener wrote: > On Tue, Jun 20, 2017 at 10:03 AM, Uros Bizjak wrote: >> On Mon, Jun 19, 2017 at 7:51 PM, Jakub Jelinek wrote: >>> On Mon, Jun 19, 2017 at 11:45:13AM -0600, Jeff Law wrote: On 06/19/2017 11:29 AM, Jakub Jelinek wrote: > > Al

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Richard Biener
On Tue, Jun 20, 2017 at 10:03 AM, Uros Bizjak wrote: > On Mon, Jun 19, 2017 at 7:51 PM, Jakub Jelinek wrote: >> On Mon, Jun 19, 2017 at 11:45:13AM -0600, Jeff Law wrote: >>> On 06/19/2017 11:29 AM, Jakub Jelinek wrote: >>> > >>> > Also, on i?86 orq $0, (%rsp) or orl $0, (%esp) is used to probe st

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Richard Earnshaw (lists)
On 19/06/17 18:07, Jeff Law wrote: > As some of you are likely aware, Qualys has just published fairly > detailed information on using stack/heap clashes as an attack vector. > Eric B, Michael M -- sorry I couldn't say more when I contact you about > -fstack-check and some PPC specific stuff. This

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Richard Earnshaw (lists)
On 19/06/17 20:04, Jeff Law wrote: > On 06/19/2017 11:50 AM, Joseph Myers wrote: >> On Mon, 19 Jun 2017, Jeff Law wrote: >> >>> A key point to remember is that you can never have an allocation >>> (potentially using more than one allocation site) which is larger than a >>> page without probing the

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Eric Botcazou
> Out of curiousity, does the old Alpha/VMS stack-checking API meet the > requirements? From what I recall, I think it does. No, it's the usual probe-first-and-then-allocate strategy and Jeff rejects it because of valgrind. I'd personally rather change valgrind but... -- Eric Botcazou

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Eric Botcazou
> As some of you are likely aware, Qualys has just published fairly > detailed information on using stack/heap clashes as an attack vector. > Eric B, Michael M -- sorry I couldn't say more when I contact you about > -fstack-check and some PPC specific stuff. This has been under embargo > for the l

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Uros Bizjak
On Mon, Jun 19, 2017 at 7:51 PM, Jakub Jelinek wrote: > On Mon, Jun 19, 2017 at 11:45:13AM -0600, Jeff Law wrote: >> On 06/19/2017 11:29 AM, Jakub Jelinek wrote: >> > >> > Also, on i?86 orq $0, (%rsp) or orl $0, (%esp) is used to probe stack, >> > while it is shorter, is it actually faster or as s

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-20 Thread Eric Botcazou
> In the patches Jeff is going to post, we have (at least for > -fasynchronous-unwind-tables which is on by default on e.g. x86) > precise unwind info even with the new stack check mode. > ira.c currently has: >/* We need the frame pointer to catch stack overflow exceptions if > t

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Florian Weimer
On 06/20/2017 12:05 AM, Jeff Law wrote: > On 06/19/2017 03:56 PM, Joseph Myers wrote: >> On Mon, 19 Jun 2017, Florian Weimer wrote: >> >>> I think architectures such as aarch64 without implied stack probing as >>> part of the function call sequence would benefit most from an ABI >>> agreement (spli

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Jeff Law
On 06/19/2017 12:02 PM, Richard Biener wrote: > On June 19, 2017 8:00:19 PM GMT+02:00, Richard Biener > wrote: >> On June 19, 2017 7:29:32 PM GMT+02:00, Jakub Jelinek >> wrote: >>> On Mon, Jun 19, 2017 at 11:07:06AM -0600, Jeff Law wrote: After much poking around I concluded that we really

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Richard Kenner
> > Out of curiousity, does the old Alpha/VMS stack-checking API meet the > > requirements? From what I recall, I think it does. > Unsure. Is this documented somewhere? It seems to be in http://h20565.www2.hpe.com/hpsc/doc/public/display?docId=emr_na-c04621389 starting at page 3-54.

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Jeff Law
On 06/19/2017 12:12 PM, Richard Kenner wrote: > Out of curiousity, does the old Alpha/VMS stack-checking API meet the > requirements? From what I recall, I think it does. Unsure. Is this documented somewhere? jeff

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Jeff Law
On 06/19/2017 03:56 PM, Joseph Myers wrote: > On Mon, 19 Jun 2017, Florian Weimer wrote: > >> I think architectures such as aarch64 without implied stack probing as >> part of the function call sequence would benefit most from an ABI >> agreement (splitting the probing responsibility in some way b

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Jeff Law
On 06/19/2017 12:15 PM, Florian Weimer wrote: > On 06/19/2017 08:02 PM, Richard Biener wrote: >> Oh, and using push intelligently with first bumping to SP & 4096-1 + 4095 >> would solve the signal atomicity as well. Might be larger and somewhat >> interfere with CPUs stack engine. Who knows... >

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Joseph Myers
On Mon, 19 Jun 2017, Florian Weimer wrote: > I think architectures such as aarch64 without implied stack probing as > part of the function call sequence would benefit most from an ABI > agreement (splitting the probing responsibility in some way between > caller and callee). For architectures wit

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Jeff Law
On 06/19/2017 11:51 AM, Jakub Jelinek wrote: > On Mon, Jun 19, 2017 at 11:45:13AM -0600, Jeff Law wrote: >> On 06/19/2017 11:29 AM, Jakub Jelinek wrote: >>> >>> Also, on i?86 orq $0, (%rsp) or orl $0, (%esp) is used to probe stack, >>> while it is shorter, is it actually faster or as slow as movq $

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Jeff Law
On 06/19/2017 01:45 PM, Jakub Jelinek wrote: > On Mon, Jun 19, 2017 at 01:04:57PM -0600, Jeff Law wrote: >> On 06/19/2017 11:50 AM, Joseph Myers wrote: >>> On Mon, 19 Jun 2017, Jeff Law wrote: >>> A key point to remember is that you can never have an allocation (potentially using more tha

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Jakub Jelinek
On Mon, Jun 19, 2017 at 01:04:57PM -0600, Jeff Law wrote: > On 06/19/2017 11:50 AM, Joseph Myers wrote: > > On Mon, 19 Jun 2017, Jeff Law wrote: > > > >> A key point to remember is that you can never have an allocation > >> (potentially using more than one allocation site) which is larger than a >

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Jeff Law
On 06/19/2017 11:50 AM, Joseph Myers wrote: > On Mon, 19 Jun 2017, Jeff Law wrote: > >> A key point to remember is that you can never have an allocation >> (potentially using more than one allocation site) which is larger than a >> page without probing the page. > > There's a platform ABI issue h

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Florian Weimer
On 06/19/2017 07:50 PM, Joseph Myers wrote: > There's a platform ABI issue here. At least some kernel fixes for these > stack issues, as I understand it, increase the size of the stack guard to > more than a single page. It would be possible to define the ABI to > require such a larger guard f

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Florian Weimer
On 06/19/2017 08:02 PM, Richard Biener wrote: > Oh, and using push intelligently with first bumping to SP & 4096-1 + 4095 > would solve the signal atomicity as well. Might be larger and somewhat > interfere with CPUs stack engine. Who knows... On x86-64, PUSH REG is just a single byte, so for s

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Richard Kenner
Out of curiousity, does the old Alpha/VMS stack-checking API meet the requirements? From what I recall, I think it does.

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Richard Biener
On June 19, 2017 8:00:19 PM GMT+02:00, Richard Biener wrote: >On June 19, 2017 7:29:32 PM GMT+02:00, Jakub Jelinek >wrote: >>On Mon, Jun 19, 2017 at 11:07:06AM -0600, Jeff Law wrote: >>> After much poking around I concluded that we really need to >implement >>> allocation and probing via a "movi

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Richard Biener
On June 19, 2017 7:29:32 PM GMT+02:00, Jakub Jelinek wrote: >On Mon, Jun 19, 2017 at 11:07:06AM -0600, Jeff Law wrote: >> After much poking around I concluded that we really need to implement >> allocation and probing via a "moving sp" strategy. Probing into >> unallocated areas runs afoul of va

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Jakub Jelinek
On Mon, Jun 19, 2017 at 05:50:56PM +, Joseph Myers wrote: > On Mon, 19 Jun 2017, Jeff Law wrote: > > > A key point to remember is that you can never have an allocation > > (potentially using more than one allocation site) which is larger than a > > page without probing the page. > > There's a

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Jakub Jelinek
On Mon, Jun 19, 2017 at 11:45:13AM -0600, Jeff Law wrote: > On 06/19/2017 11:29 AM, Jakub Jelinek wrote: > > > > Also, on i?86 orq $0, (%rsp) or orl $0, (%esp) is used to probe stack, > > while it is shorter, is it actually faster or as slow as movq $0, (%rsp) > > or movl $0, (%esp) ? > Florian ra

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Joseph Myers
On Mon, 19 Jun 2017, Jeff Law wrote: > A key point to remember is that you can never have an allocation > (potentially using more than one allocation site) which is larger than a > page without probing the page. There's a platform ABI issue here. At least some kernel fixes for these stack issue

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Jeff Law
On 06/19/2017 11:29 AM, Jakub Jelinek wrote: > > Also, on i?86 orq $0, (%rsp) or orl $0, (%esp) is used to probe stack, > while it is shorter, is it actually faster or as slow as movq $0, (%rsp) > or movl $0, (%esp) ? Florian raised this privately to me as well. THere's a couple issues. 1. Is th

Re: RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Jakub Jelinek
On Mon, Jun 19, 2017 at 11:07:06AM -0600, Jeff Law wrote: > After much poking around I concluded that we really need to implement > allocation and probing via a "moving sp" strategy. Probing into > unallocated areas runs afoul of valgrind, so that's a non-starter. > > Allocating stack space, the

RFC: stack/heap collision vulnerability and mitigation with GCC

2017-06-19 Thread Jeff Law
As some of you are likely aware, Qualys has just published fairly detailed information on using stack/heap clashes as an attack vector. Eric B, Michael M -- sorry I couldn't say more when I contact you about -fstack-check and some PPC specific stuff. This has been under embargo for the last month.