From: Julia Lawall <julia.lawall@lip6.fr>
To: Nicolas Iooss <nicolas.iooss_linux@m4x.org>
Cc: Joe Perches <joe@perches.com>,
alsa-devel@alsa-project.org, Dan Capenter <error27@gmail.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: Misuses of ** ? (was Re: [PATCH 1/1] ASoC: Intel: Atom: add a missing star in a memcpy call)
Date: Sun, 28 Aug 2016 21:38:09 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.10.1608282137050.3419@hadrien> (raw)
In-Reply-To: <fcac5d87-9f50-b303-f100-4313d7f21907@m4x.org>
On Sun, 28 Aug 2016, Nicolas Iooss wrote:
> On 28/08/16 19:50, Joe Perches wrote:
> > On Sun, 2016-08-28 at 19:39 +0200, Nicolas Iooss wrote:
> >> In sst_prepare_and_post_msg(), when a response is received in "block",
> >> the following code gets executed:
> >>
> >> *data = kzalloc(block->size, GFP_KERNEL);
> >> memcpy(data, (void *) block->data, block->size);
> >
> > Yuck, thanks.
> >
> > Julia, Dan, could cocci or smatch help find any other
> > similar misuses here?
>
> In fact I have found this bug with a GCC plugin I have written after I
> discovered an issue with a printf format string in brcmfmac driver
> (https://lkml.org/lkml/2016/8/23/193 fixes this one). This GCC plugin
> uses an approach which has many false positives but it helped me detect
> real bugs such as the one you replied to, and
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=ae6c33ba6e37eea3012fe2640b22400ef3f2d0f3
> a few days ago.
>
> In case you are curious about what the plugin looks like (it is very
> dirty but might be useful for future work I won't have time to do), I
> published it on
> https://gist.github.com/anonymous/36dd40dcbeeb83964e66b65be7a96136 .
> This huge patch contains the plugin code in
> scripts/gcc-plugins/deref_checker_plugin.c, many dirty work-arounds to
> filter false positive matches, a really-dirty way of handling memcpy
> optimisations done by gcc, and fixes to possible bugs (which can be
> found by searching "/* BUG? */", I have not yet had time to find out
> whether they are real bugs or false positives too).
>
> I hope this will help in the work of eliminating bugs in the kernel :)
I tried the following semantic patch, that is quite general, and the fixed
issue was the only report.
@@
expression x,y,sz;
identifier f,g;
@@
* *x = f(sz,...);
...
* g(x,y,sz);
julia
next prev parent reply other threads:[~2016-08-28 19:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-28 17:39 [PATCH 1/1] ASoC: Intel: Atom: add a missing star in a memcpy call Nicolas Iooss
2016-08-28 17:50 ` Misuses of ** ? (was Re: [PATCH 1/1] ASoC: Intel: Atom: add a missing star in a memcpy call) Joe Perches
2016-08-28 18:52 ` Nicolas Iooss
2016-08-28 19:38 ` Julia Lawall [this message]
2016-08-28 20:34 ` Joe Perches
2016-08-28 21:40 ` Julia Lawall
2016-08-28 21:54 ` Joe Perches
2016-08-28 18:17 ` [PATCH 1/1] ASoC: Intel: Atom: add a missing star in a memcpy call Joe Perches
2016-08-28 18:31 ` Nicolas Iooss
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=alpine.DEB.2.10.1608282137050.3419@hadrien \
--to=julia.lawall@lip6.fr \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=error27@gmail.com \
--cc=joe@perches.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolas.iooss_linux@m4x.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®