From: Dan Carpenter <dan.carpenter@oracle.com>
To: Christopher Li <sparse@chrisli.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
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: Sun, 10 Mar 2013 01:34:03 +0300 [thread overview]
Message-ID: <20130309223403.GZ9138@mwanda> (raw)
In-Reply-To: <CANeU7QnhB566ZJqjcaLkn7o701EeVbJcB=8VHW_33nwK=FZRhg@mail.gmail.com>
On Sat, Mar 09, 2013 at 10:10:08AM -0800, Christopher Li wrote:
> On Fri, Mar 8, 2013 at 9:39 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> > On Fri, Mar 08, 2013 at 04:29:22PM -0800, Andrew Morton wrote:
> >> Roughly how many instances of this are there kernel-wide?
> >>
> >
> > Around 150 on x86 allmodconfig. They are pretty well audited.
>
> I saw 207 on x86-64 allmodconfig. See the list that I attached.
>
Ah. Sorry, I'm on my laptop and my sparse output was old.
> Can you elaborate the well audited part? How it was audited?
>
The problems is if we go over the 8k stack. So big arrays are bad.
Also if the dynamically sized array is inside a loop then normally
GCC frees it after each iteration, but on some arches it didn't free
it until after the last iteration.
Btw, I've Smatch has cross function analysis, and I'd like to use
it here to figure out if the max size for dynamically sized arrays.
I ran into a problem:
The code looks like this:
char buf[a];
The size expression should be an EXPR_SYMBOL, but smatch gets:
char buf[*a];
Where the size expression is an EXPR_PREOP.
In smatch, how I use sparse is that I call sparse_keep_tokens() and
then I parse the resulting symbol list myself. The problem is in
examine_array_type() we call get_expression_value() which changes
the symbols from normal symbols to dereferences. The call tree is:
examine_array_type()
-> get_expression_value()
-> __get_expression_value()
-> evaluate_expression()
-> evaluate_symbol_expression() <- change happens here.
I'm not sure what to do.
regards,
dan carpenter
next prev parent reply other threads:[~2013-03-09 22:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-07 4:46 Suggestion for fixing the variable length array used in the kernel Christopher Li
2013-03-09 0:29 ` Andrew Morton
2013-03-09 5:39 ` Dan Carpenter
2013-03-09 18:10 ` Christopher Li
2013-03-09 22:34 ` Dan Carpenter [this message]
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=20130309223403.GZ9138@mwanda \
--to=dan.carpenter@oracle.com \
--cc=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;
as well as URLs for NNTP newsgroup(s).