[19212] in Kerberos_V5_Development
Re: C99 Features
daemon@ATHENA.MIT.EDU (Nathaniel McCallum)
Thu Jun 18 00:29:57 2015
Message-ID: <1434601779.15953.12.camel@redhat.com>
From: Nathaniel McCallum <npmccallum@redhat.com>
To: Nico Williams <nico@cryptonector.com>
Date: Thu, 18 Jun 2015 00:29:39 -0400
In-Reply-To: <20150617230626.GH6117@localhost>
Mime-Version: 1.0
Cc: Danilo Almeida <dalmeida@mit.edu>, "'krbdev@mit.edu'" <krbdev@mit.edu>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: krbdev-bounces@mit.edu
On Wed, 2015-06-17 at 18:06 -0500, Nico Williams wrote:
> On Wed, Jun 17, 2015 at 02:32:15PM -0400, Nathaniel McCallum wrote:
> > On Wed, 2015-06-17 at 00:02 +0000, Danilo Almeida wrote:
> > > Nathaniel wrote:
> > > > I think VLAs buys a lot.
> > >
> > > It seems that VLA could introduce new issues or invariants since
> > > you
> > > can no longer check for allocation failure.
> >
> > You can't check for allocation failure on most operating systems'
> > heap
> > allocation these days. Now, the failure in the heap vs stack cases
> > is
> > somewhat different; and you have to be cautious to avoid some
> > security
> > issues. But with careful use, there is a lot of benefit.
>
> Heap allocation failures are rather different than alloca() or VLA
> allocation failures. alloca(), for example, has undefined behavior
> on
> failure for obvious reasons: sp + size might land in a mapped page
> for a
> different mapping, going well past the stack's guard page.
>
> In practice, if the stack grows down and the elements of the VLA are
> accessed from higher to lower (or the reverse if the stack grows up)
> then the guard page should still work, but this isn't defined
> behavior.
>
> Both are fine when the sizes are naturally limited to small sizes,
> but
> this requires more review effort. Alternatively one could have a
> macro
> to guard against unsafe array sizes. I'd rather VLAs and alloca()
> were
> frowned upon (though not forbidden).
Most of this is greatly diminished by the various stack protection
techniques found in modern compilers. It is getting harder and harder
to even trigger these kinds of errors.
Nathaniel
_______________________________________________
krbdev mailing list krbdev@mit.edu
https://mailman.mit.edu/mailman/listinfo/krbdev