From: Kees Cook <kees@kernel.org>
To: Andy Shevchenko <andy@kernel.org>
Cc: Kees Cook <kees@kernel.org>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Michal Wajdeczko <michal.wajdeczko@intel.com>,
Julia Lawall <Julia.Lawall@inria.fr>,
Nicolas Palix <nicolas.palix@imag.fr>,
linux-hardening@vger.kernel.org, cocci@inria.fr,
linux-kernel@vger.kernel.org
Subject: [PATCH] coccinelle: Add rules to find str_down_up() replacements
Date: Mon, 12 Aug 2024 11:36:38 -0700 [thread overview]
Message-ID: <20240812183637.work.999-kees@kernel.org> (raw)
As done with str_up_down(), add checks for str_down_up() opportunities.
5 cases currently exist in the tree.
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Andy Shevchenko <andy@kernel.org>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Julia Lawall <Julia.Lawall@inria.fr>
Cc: Nicolas Palix <nicolas.palix@imag.fr>
Cc: linux-hardening@vger.kernel.org
Cc: cocci@inria.fr
---
scripts/coccinelle/api/string_choices.cocci | 23 +++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/scripts/coccinelle/api/string_choices.cocci b/scripts/coccinelle/api/string_choices.cocci
index d517f6bc850b..5e729f187f22 100644
--- a/scripts/coccinelle/api/string_choices.cocci
+++ b/scripts/coccinelle/api/string_choices.cocci
@@ -62,3 +62,26 @@ e << str_up_down_r.E;
@@
coccilib.report.print_report(p[0], "opportunity for str_up_down(%s)" % e)
+
+@str_down_up depends on patch@
+expression E;
+@@
+(
+- ((E) ? "down" : "up")
++ str_down_up(E)
+)
+
+@str_down_up_r depends on !patch exists@
+expression E;
+position P;
+@@
+(
+* ((E@P) ? "down" : "up")
+)
+
+@script:python depends on report@
+p << str_down_up_r.P;
+e << str_down_up_r.E;
+@@
+
+coccilib.report.print_report(p[0], "opportunity for str_down_up(%s)" % e)
--
2.34.1
next reply other threads:[~2024-08-12 18:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-12 18:36 Kees Cook [this message]
2024-08-12 19:49 ` [PATCH] coccinelle: Add rules to find str_down_up() replacements Andy Shevchenko
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=20240812183637.work.999-kees@kernel.org \
--to=kees@kernel.org \
--cc=Julia.Lawall@inria.fr \
--cc=andy.shevchenko@gmail.com \
--cc=andy@kernel.org \
--cc=cocci@inria.fr \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.wajdeczko@intel.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.