From: Denis Efremov <efremov@linux.com>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: Denis Efremov <efremov@linux.com>,
cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org,
Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH] coccinelle: api: update kzfree script to kfree_sensitive
Date: Tue, 11 Aug 2020 10:49:53 +0300 [thread overview]
Message-ID: <20200811074953.73994-1-efremov@linux.com> (raw)
In-Reply-To: <20200604140805.111613-1-efremov@linux.com>
Commit 453431a54934 ("mm, treewide: rename kzfree() to kfree_sensitive()")
renames kzfree to kfree_sensitive and uses memzero_explicit(...) instead of
memset(..., 0, ...) internally. Update cocci script to reflect these
changes.
Signed-off-by: Denis Efremov <efremov@linux.com>
---
Julia, I think you can squash this commit with original script, or I can
resend the whole script since it's not merged to the mainline.
.../{kzfree.cocci => kfree_sensitive.cocci} | 29 +++++++++----------
1 file changed, 13 insertions(+), 16 deletions(-)
rename scripts/coccinelle/api/{kzfree.cocci => kfree_sensitive.cocci} (70%)
diff --git a/scripts/coccinelle/api/kzfree.cocci b/scripts/coccinelle/api/kfree_sensitive.cocci
similarity index 70%
rename from scripts/coccinelle/api/kzfree.cocci
rename to scripts/coccinelle/api/kfree_sensitive.cocci
index 33625bd7cec9..e4a066a0b77d 100644
--- a/scripts/coccinelle/api/kzfree.cocci
+++ b/scripts/coccinelle/api/kfree_sensitive.cocci
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: GPL-2.0-only
///
-/// Use kzfree, kvfree_sensitive rather than memset or
-/// memzero_explicit followed by kfree
+/// Use kfree_sensitive, kvfree_sensitive rather than memset or
+/// memzero_explicit followed by kfree.
///
// Confidence: High
// Copyright: (C) 2020 Denis Efremov ISPRAS
// Options: --no-includes --include-headers
//
-// Keywords: kzfree, kvfree_sensitive
+// Keywords: kfree_sensitive, kvfree_sensitive
//
virtual context
@@ -18,7 +18,8 @@ virtual report
@initialize:python@
@@
# kmalloc_oob_in_memset uses memset to explicitly trigger out-of-bounds access
-filter = frozenset(['kmalloc_oob_in_memset', 'kzfree', 'kvfree_sensitive'])
+filter = frozenset(['kmalloc_oob_in_memset',
+ 'kfree_sensitive', 'kvfree_sensitive'])
def relevant(p):
return not (filter & {el.current_element for el in p})
@@ -56,17 +57,13 @@ type T;
- memzero_explicit@m((T)E, size);
... when != E
when strict
-// TODO: uncomment when kfree_sensitive will be merged.
-// Only this case is commented out because developers
-// may not like patches like this since kzfree uses memset
-// internally (not memzero_explicit).
-//(
-//- kfree(E)@p;
-//+ kfree_sensitive(E);
-//|
+(
+- kfree(E)@p;
++ kfree_sensitive(E);
+|
- \(vfree\|kvfree\)(E)@p;
+ kvfree_sensitive(E, size);
-//)
+)
@rp_memset depends on patch@
expression E, size;
@@ -80,7 +77,7 @@ type T;
when strict
(
- kfree(E)@p;
-+ kzfree(E);
++ kfree_sensitive(E);
|
- \(vfree\|kvfree\)(E)@p;
+ kvfree_sensitive(E, size);
@@ -91,11 +88,11 @@ p << r.p;
@@
coccilib.report.print_report(p[0],
- "WARNING: opportunity for kzfree/kvfree_sensitive")
+ "WARNING: opportunity for kfree_sensitive/kvfree_sensitive")
@script:python depends on org@
p << r.p;
@@
coccilib.org.print_todo(p[0],
- "WARNING: opportunity for kzfree/kvfree_sensitive")
+ "WARNING: opportunity for kfree_sensitive/kvfree_sensitive")
--
2.26.2
next prev parent reply other threads:[~2020-08-11 7:50 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-04 14:08 [PATCH] coccinelle: api: add kzfree script Denis Efremov
2020-06-04 14:15 ` Julia Lawall
2020-06-04 15:39 ` Denis Efremov
2020-06-04 15:51 ` Julia Lawall
2020-06-04 17:22 ` Denis Efremov
2020-06-04 17:28 ` Julia Lawall
2020-06-04 16:27 ` Joe Perches
2020-06-04 17:30 ` Denis Efremov
2020-06-04 17:36 ` Joe Perches
2020-06-14 19:42 ` Denis Efremov
2020-06-14 20:01 ` Joe Perches
2020-06-15 12:03 ` Dan Carpenter
2020-06-15 13:51 ` Denis Efremov
2020-06-04 20:48 ` [PATCH v2] " Denis Efremov
2020-06-04 20:57 ` [Cocci] " Julia Lawall
2020-06-04 21:03 ` Denis Efremov
2020-06-04 21:25 ` Denis Efremov
2020-06-06 8:16 ` Julia Lawall
2020-06-14 21:54 ` [PATCH v3] " Denis Efremov
2020-06-17 20:42 ` [Cocci] " Julia Lawall
2020-06-17 21:42 ` Denis Efremov
2020-07-07 21:35 ` Julia Lawall
2020-07-17 11:57 ` [PATCH v4] " Denis Efremov
2020-07-17 20:39 ` Julia Lawall
2020-08-10 23:45 ` Eric Biggers
2020-08-11 7:12 ` Denis Efremov
2020-08-11 7:49 ` Denis Efremov [this message]
2020-08-26 8:12 ` [PATCH] coccinelle: api: update kzfree script to kfree_sensitive Denis Efremov
2020-09-12 15:08 ` 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=20200811074953.73994-1-efremov@linux.com \
--to=efremov@linux.com \
--cc=cocci@systeme.lip6.fr \
--cc=ebiggers@kernel.org \
--cc=julia.lawall@inria.fr \
--cc=linux-kernel@vger.kernel.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).