Re: random malloc junk

2016-09-18 Thread Otto Moerbeek
On Wed, Sep 14, 2016 at 05:41:55AM +0200, Theo Buehler wrote: > On Tue, Sep 13, 2016 at 01:29:17PM +0200, Otto Moerbeek wrote: > > As often, real life came in between. Did anybody do measurements? I > > really would like to to see hard data. > > It seems that the price is relatively modest. > >

Re: random malloc junk

2016-09-16 Thread Otto Moerbeek
On Fri, Sep 16, 2016 at 09:30:15PM +0200, Otto Moerbeek wrote: > On Thu, Sep 15, 2016 at 10:08:26AM -0400, Ted Unangst wrote: > > > Otto Moerbeek wrote: > > > On Wed, Sep 14, 2016 at 12:53:05PM -0400, Ted Unangst wrote: > > > > > > > Daniel Micay wrote: > > > > > > > > > > The current OpenBSD c

Re: random malloc junk

2016-09-16 Thread Otto Moerbeek
On Thu, Sep 15, 2016 at 10:08:26AM -0400, Ted Unangst wrote: > Otto Moerbeek wrote: > > On Wed, Sep 14, 2016 at 12:53:05PM -0400, Ted Unangst wrote: > > > > > Daniel Micay wrote: > > > > > > > > The current OpenBSD code only wipes up to MALLOC_MAXCHUNK with junk @ 1, > > > > and it similarly doe

Re: random malloc junk

2016-09-15 Thread Ted Unangst
Otto Moerbeek wrote: > On Wed, Sep 14, 2016 at 12:53:05PM -0400, Ted Unangst wrote: > > > Daniel Micay wrote: > > > > > > The current OpenBSD code only wipes up to MALLOC_MAXCHUNK with junk @ 1, > > > and it similarly doesn't wipe at all with 'U' (even though junk-on-free > > > also serves the pu

Re: random malloc junk

2016-09-14 Thread Otto Moerbeek
On Wed, Sep 14, 2016 at 12:53:05PM -0400, Ted Unangst wrote: > Daniel Micay wrote: > > > > The current OpenBSD code only wipes up to MALLOC_MAXCHUNK with junk @ 1, > > and it similarly doesn't wipe at all with 'U' (even though junk-on-free > > also serves the purpose of preventing information lea

Re: random malloc junk

2016-09-14 Thread Theo de Raadt
> Daniel Micay wrote: > > > > The current OpenBSD code only wipes up to MALLOC_MAXCHUNK with junk @ 1, > > and it similarly doesn't wipe at all with 'U' (even though junk-on-free > > also serves the purpose of preventing information leaks, not just > > mitigating use-after-free). IMO, optimizing l

Re: random malloc junk

2016-09-14 Thread Ted Unangst
Daniel Micay wrote: > > The current OpenBSD code only wipes up to MALLOC_MAXCHUNK with junk @ 1, > and it similarly doesn't wipe at all with 'U' (even though junk-on-free > also serves the purpose of preventing information leaks, not just > mitigating use-after-free). IMO, optimizing large allocat

Re: random malloc junk

2016-09-14 Thread Daniel Micay
On Tue, 2016-09-13 at 13:27 +0200, Otto Moerbeek wrote: > On Thu, Sep 08, 2016 at 06:42:33PM -0400, Daniel Micay wrote: > > > A bit off-topic: 'J' enables junk-on-init which is for debugging, > > but it > > also currently has security improvements for large allocations. > > There's > > only partia

Re: random malloc junk

2016-09-13 Thread Theo Buehler
On Tue, Sep 13, 2016 at 01:29:17PM +0200, Otto Moerbeek wrote: > As often, real life came in between. Did anybody do measurements? I > really would like to to see hard data. It seems that the price is relatively modest. I ran several 'make build's: 3rd gen X1, i7 5500U, 2.4GHz (amd64):

Re: random malloc junk

2016-09-13 Thread Theo Buehler
On Wed, Sep 07, 2016 at 06:29:07PM -0400, Ted Unangst wrote: > There's some overlap here with canaries, but nothing wrong with that. :) The diff breaks canaries since random_junk() overwrites them before they are validated. The following straightforward modification fixes that: > Index: malloc.c

Re: random malloc junk

2016-09-13 Thread Otto Moerbeek
On Thu, Sep 08, 2016 at 08:15:42AM +0200, Otto Moerbeek wrote: > On Wed, Sep 07, 2016 at 06:29:07PM -0400, Ted Unangst wrote: > > > Instead of always using a fixed byte pattern, I think malloc should use a > > random pattern. Now, this sometimes means it's harder to identify exactly > > what's us

Re: random malloc junk

2016-09-13 Thread Otto Moerbeek
On Thu, Sep 08, 2016 at 06:42:33PM -0400, Daniel Micay wrote: > On Wed, 2016-09-07 at 18:29 -0400, Ted Unangst wrote: > > Instead of always using a fixed byte pattern, I think malloc should > > use a > > random pattern. Now, this sometimes means it's harder to identify > > exactly > > what's used

Re: random malloc junk

2016-09-10 Thread Theo de Raadt
> On Thu, Sep 08, 2016 at 07:47:58PM -0400, Daniel Micay wrote: > > > A nice security property of 0xdf filling is that a use-after-free of a > > pointer is guaranteed to fault in a typical environment since it ends up > > pointing outside userspace (I assume that's the case on OpenBSD). A heap > >

Re: random malloc junk

2016-09-10 Thread Otto Moerbeek
On Thu, Sep 08, 2016 at 07:47:58PM -0400, Daniel Micay wrote: > A nice security property of 0xdf filling is that a use-after-free of a > pointer is guaranteed to fault in a typical environment since it ends up > pointing outside userspace (I assume that's the case on OpenBSD). A heap > spray could

Re: random malloc junk

2016-09-08 Thread Daniel Micay
A nice security property of 0xdf filling is that a use-after-free of a pointer is guaranteed to fault in a typical environment since it ends up pointing outside userspace (I assume that's the case on OpenBSD). A heap spray could potentially allow exploiting a random pointer. Perhaps it would be bet

Re: random malloc junk

2016-09-08 Thread Daniel Micay
> BTW, we should revisit canaries and work further on moving them > closer to requested size. There's a chance this diff wil complicate > that. Can switch the canary code to memcpy/memcmp (to handle unaligned canaries) and could then use the last byte as an index to the start of the canary. For la

Re: random malloc junk

2016-09-08 Thread Daniel Micay
On Wed, 2016-09-07 at 18:29 -0400, Ted Unangst wrote: > Instead of always using a fixed byte pattern, I think malloc should > use a > random pattern. Now, this sometimes means it's harder to identify > exactly > what's used after free, so we should provide a means to get the old > 0xdf > pattern ba

Re: random malloc junk

2016-09-07 Thread Otto Moerbeek
On Wed, Sep 07, 2016 at 06:29:07PM -0400, Ted Unangst wrote: > Instead of always using a fixed byte pattern, I think malloc should use a > random pattern. Now, this sometimes means it's harder to identify exactly > what's used after free, so we should provide a means to get the old 0xdf > pattern

random malloc junk

2016-09-07 Thread Ted Unangst
Instead of always using a fixed byte pattern, I think malloc should use a random pattern. Now, this sometimes means it's harder to identify exactly what's used after free, so we should provide a means to get the old 0xdf pattern back. Since we already have two junk modes, I thought I'd carry on al