[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240812183637.work.999-kees@kernel.org>
Date: Mon, 12 Aug 2024 11:36:38 -0700
From: Kees Cook <kees@...nel.org>
To: Andy Shevchenko <andy@...nel.org>
Cc: Kees Cook <kees@...nel.org>,
Andy Shevchenko <andy.shevchenko@...il.com>,
Michal Wajdeczko <michal.wajdeczko@...el.com>,
Julia Lawall <Julia.Lawall@...ia.fr>,
Nicolas Palix <nicolas.palix@...g.fr>,
linux-hardening@...r.kernel.org,
cocci@...ia.fr,
linux-kernel@...r.kernel.org
Subject: [PATCH] coccinelle: Add rules to find str_down_up() replacements
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@...il.com>
Signed-off-by: Kees Cook <kees@...nel.org>
---
Cc: Andy Shevchenko <andy@...nel.org>
Cc: Michal Wajdeczko <michal.wajdeczko@...el.com>
Cc: Julia Lawall <Julia.Lawall@...ia.fr>
Cc: Nicolas Palix <nicolas.palix@...g.fr>
Cc: linux-hardening@...r.kernel.org
Cc: cocci@...ia.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)
+
+@..._down_up depends on patch@
+expression E;
+@@
+(
+- ((E) ? "down" : "up")
++ str_down_up(E)
+)
+
+@..._down_up_r depends on !patch exists@
+expression E;
+position P;
+@@
+(
+* ((E@P) ? "down" : "up")
+)
+
+@...ipt: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
Powered by blists - more mailing lists