From: Andrew Morton <akpm@linux-foundation.org>
To: Christopher Li <sparse@chrisli.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Linux-Sparse <linux-sparse@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: Suggestion for fixing the variable length array used in the kernel.
Date: Fri, 8 Mar 2013 16:29:22 -0800 [thread overview]
Message-ID: <20130308162922.88ad40997d01099949008452@linux-foundation.org> (raw)
In-Reply-To: <CANeU7Qn-5b5U_64QzFt-beP-PyAJgzz=z1100F0v5WbWqZwZOQ@mail.gmail.com>
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?
next prev parent reply other threads:[~2013-03-09 0:29 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-07 4:46 Christopher Li
2013-03-09 0:29 ` Andrew Morton [this message]
2013-03-09 5:39 ` Dan Carpenter
2013-03-09 18:10 ` Christopher Li
2013-03-09 22:34 ` Dan Carpenter
2013-03-09 23:00 ` Christopher Li
2013-03-10 11:38 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130308162922.88ad40997d01099949008452@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®