From: Julia Lawall <julia.lawall@lip6.fr>
To: Konstantin Khlebnikov <k.khlebnikov@samsung.com>
Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org,
Eric Biederman <ebiederm@xmission.com>,
Michal Marek <mmarek@suse.cz>,
Herbert Xu <herbert@gondor.apana.org.au>,
Gilles Muller <Gilles.Muller@lip6.fr>,
Nicolas Palix <nicolas.palix@imag.fr>,
Julia Lawall <Julia.Lawall@lip6.fr>,
linux-crypto@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH 1/2 v2] scripts/coccinelle: catch freeing cryptographic structures via kfree
Date: Wed, 19 Nov 2014 10:41:37 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.10.1411191040020.2363@hadrien> (raw)
In-Reply-To: <20141118114920.13498.73584.stgit@buzz>
> +// Comments: There are false positives in crypto/ where they are
> actually freed.
I didn't really understand this comment. I ran the semantic patch and got
around 10 results, but it wasn't clear to me how to see which were false
positives.
I would suggest to extend the rule a little bit to include information
about where the allocation call is:
///
/// Structures allocated by crypto_alloc_* must be freed using crypto_free_*.
/// This finds freeing them by kfree.
///
// Confidence: Moderate
// Copyright: (C) 2014 Konstantin Khlebnikov, GPLv2.
// Comments: There are false positives in crypto/ where they are actually freed.
// Keywords: crypto, kfree
// Options: --no-includes --include-headers
virtual org
virtual report
virtual context
@r depends on context || org || report@
expression x;
position p1;
@@
(
x = crypto_alloc_base@p1(...)
|
x = crypto_alloc_cipher@p1(...)
|
x = crypto_alloc_ablkcipher@p1(...)
|
x = crypto_alloc_aead@p1(...)
|
x = crypto_alloc_instance@p1(...)
|
x = crypto_alloc_instance2@p1(...)
|
x = crypto_alloc_comp@p1(...)
|
x = crypto_alloc_pcomp@p1(...)
|
x = crypto_alloc_hash@p1(...)
|
x = crypto_alloc_ahash@p1(...)
|
x = crypto_alloc_shash@p1(...)
|
x = crypto_alloc_rng@p1(...)
)
@pb@
expression r.x;
position p;
@@
* kfree@p(x)
@script:python depends on org@
p << pb.p;
p1 << r.p1;
@@
msg="WARNING: invalid free of crypto_alloc_* allocated data"
coccilib.org.print_todo(p[0], msg)
coccilib.org.print_link(p1[0], "allocation")
@script:python depends on report@
p << pb.p;
p1 << r.p1;
@@
msg="WARNING: invalid free of crypto_alloc_* allocated data, allocated on line %s" % (p1[0].line)
coccilib.report.print_report(p[0], msg)
next prev parent reply other threads:[~2014-11-19 9:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-17 14:14 [PATCH 1/2] scripts/coccinelle: catch freeing cryptographic structures via kfree Konstantin Khlebnikov
2014-11-17 14:14 ` [PATCH 2/2] kernel/kexec: free crypto_shash using crypto_free_shash Konstantin Khlebnikov
2014-11-17 15:30 ` [PATCH 1/2] scripts/coccinelle: catch freeing cryptographic structures via kfree Julia Lawall
2014-11-17 15:40 ` Konstantin Khlebnikov
2014-11-18 10:50 ` [PATCH 1/2 v2] " Konstantin Khlebnikov
2014-11-19 9:41 ` Julia Lawall [this message]
2014-11-19 15:06 ` Konstantin Khlebnikov
2014-11-23 16:45 ` Julia Lawall
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.1411191040020.2363@hadrien \
--to=julia.lawall@lip6.fr \
--cc=Gilles.Muller@lip6.fr \
--cc=davem@davemloft.net \
--cc=ebiederm@xmission.com \
--cc=herbert@gondor.apana.org.au \
--cc=k.khlebnikov@samsung.com \
--cc=kexec@lists.infradead.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mmarek@suse.cz \
--cc=nicolas.palix@imag.fr \
/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).