[llvmlinux] Can alloca() be used in the kernel instead of VLAIS or VLA?

David Woodhouse dwmw2 at infradead.org
Mon Feb 2 20:04:15 UTC 2015


On Mon, 2015-02-02 at 20:28 +0100, Behan Webster wrote:
> 
> > The real reason we don't use alloca() in the kernel is because the
> > kernel has very limited stack space.
> That makes sense.
> 
> Though for a similarly sized piece of memory you would allocate as an
> automatic variable, wouldn't alloca then also be okay?

You might possibly think that. It might even seem logical.

But alloc() screams "HAHA I AM ALLOCATING VARIABLY-SIZED STUFF ON THE
STACK. LOOK AT ME. WHAT BOUNDS ARE THERE ON THE SIZE OF THIS OBJECT?" in
a way that VLAIS does not.

So if you're "fixing" the VLAIS, sometimes you might get prodded to fix
it *differently* rather than just changing it to alloca().

Might be worth a try though.

-- 
dwmw2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5745 bytes
Desc: not available
URL: <http://lists.linuxfoundation.org/pipermail/llvmlinux/attachments/20150202/aee88f0c/attachment.bin>


More information about the LLVMLinux mailing list