lkml.org 
[lkml]   [2013]   [Mar]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Suggestion for fixing the variable length array used in the kernel.
On Wed, 6 Mar 2013 20:46:35 -0800 Christopher Li <sparse@chrisli.org> wrote:

> Hi,
>
> I am looking at the current sparse warning on the kernel source.
> One category of those warning are produce by the variable length array.
> We all know that the kernel stack has a limit so we don't want to allocate
> too much stack to the variable size array.
>
> Is there a recommended way to fix those warnings? Is it worth while to
> fix it at all? I am looking forward to some kind of guideline how to handle
> this.

Roughly how many instances of this are there kernel-wide?

I don't think it's good practice in the kernel - it's somewhat
dangerous and the effects of errors will be catastrophic. And as
you've seen, those sites are difficult to review for safety.

We could just outright ban the thing and convert those sites to
kmalloc() or whatever. If people howl about the performance impact
(unlikely) then perhaps we can put something together using
__builtin_alloca() which includes runtime checking for "excessive"
allocations. If an excessive allocation is detected we'd warn and
return NULL.

Anyway, yes, variable-length arrays are problematic so for now, let's
leave the sparse warnings in place?



\
 
 \ /
  Last update: 2013-03-09 02:21    [W:0.051 / U:0.820 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site