lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <300b5d1a-ab88-4548-91d2-0792bc15e15e@web.de>
Date: Sat, 14 Sep 2024 16:40:49 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: cocci@...ia.fr, kernel-janitors@...r.kernel.org
Cc: LKML <linux-kernel@...r.kernel.org>, Heiko Stübner
 <heiko@...ech.de>, Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
 Ulf Hansson <ulf.hansson@...aro.org>
Subject: Re: Generalising a transformation with SmPL?

…
> I found it easy to convert it also into the following small script variant
> for the semantic patch language (Coccinelle software).
>
>
> @adjustment@
> expression e, x;
> @@
> +of_node_put(e);
>  if (...)
>  {
>  <+... when != e = x
> -   of_node_put(e);
>  ...+>
>  }
> -of_node_put(e);
>
>
> 58 patches were accordingly generated for source files of the software “Linux next-20240913”.
…

This SmPL script references a known function name.
https://elixir.bootlin.com/linux/v6.11-rc7/source/drivers/of/dynamic.c#L43

I imagine that it can become helpful to avoid duplicate function calls
also in combination with other functions.
But there are development challenges to consider for functions like mutex_unlock()
which get addresses passed for data structure members.
Thus I hoped that something can be achieved with the following script variant.


@extended_adjustment@
expression e, f, x, y;
@@
+f(e);
 if (...)
 {
 <+... when != \( e = x \| y(..., &e, ...) \)
(   f(&e);
|
-   f(e);
)
 ...+>
 }
(f(&e);
|
-f(e);
)


But the software combination “Coccinelle 1.2-00038-g2297fc0f” points details out
for further development considerations.

Markus_Elfring@...ne:…/Projekte/Linux/next-analyses> spatch drivers/pmdomain/rockchip/pm-domains.c …/Projekte/Coccinelle/janitor/avoid_duplicate_function_call.cocci
…
previous modification:

  <<< f(e);
CONTEXT

According to environment 2:
   extended_adjustment.e -> pmu->mutex

   extended_adjustment.f -> mutex_unlock


current modification:

  <<< f(e);
CONTEXT

According to environment 2:
   extended_adjustment.e -> &pmu->mutex

   extended_adjustment.f -> mutex_unlock


exn while in timeout_function
extended_adjustment: already tagged token:
C code context
File "drivers/pmdomain/rockchip/pm-domains.c", line 538, column 1, charpos = 14292
  around = 'if',
  whole content =       if (rockchip_pmu_domain_is_on(pd) != power_on) {



How can such a software situation be improved?

Regards,
Markus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ