* [PATCH] coccinelle: Add rules to find str_down_up() replacements
@ 2024-08-12 18:36 Kees Cook
2024-08-12 19:49 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2024-08-12 18:36 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Kees Cook, Andy Shevchenko, Michal Wajdeczko, Julia Lawall,
Nicolas Palix, linux-hardening, cocci, linux-kernel
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] coccinelle: Add rules to find str_down_up() replacements
2024-08-12 18:36 [PATCH] coccinelle: Add rules to find str_down_up() replacements Kees Cook
@ 2024-08-12 19:49 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2024-08-12 19:49 UTC (permalink / raw)
To: Kees Cook
Cc: Michal Wajdeczko, Julia Lawall, Nicolas Palix, linux-hardening,
cocci, linux-kernel
On Mon, Aug 12, 2024 at 11:36:38AM -0700, Kees Cook wrote:
> As done with str_up_down(), add checks for str_down_up() opportunities.
> 5 cases currently exist in the tree.
Reviewed-by: Andy Shevchenko <andy@kernel.org>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-12 19:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-12 18:36 [PATCH] coccinelle: Add rules to find str_down_up() replacements Kees Cook
2024-08-12 19:49 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox