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] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 7 Sep 2019 18:05:29 +0200 (CEST)
From:   Julia Lawall <julia.lawall@...6.fr>
To:     Markus Elfring <Markus.Elfring@....de>
cc:     Coccinelle <cocci@...teme.lip6.fr>,
        kernel-janitors@...r.kernel.org,
        LKML <linux-kernel@...r.kernel.org>,
        Allison Randal <allison@...utok.net>,
        Enrico Weigelt <lkml@...ux.net>,
        Gilles Muller <Gilles.Muller@...6.fr>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Kate Stewart <kstewart@...uxfoundation.org>,
        Masahiro Yamada <yamada.masahiro@...ionext.com>,
        Michal Marek <michal.lkml@...kovi.net>,
        Nicolas Palix <nicolas.palix@...g.fr>
Subject: Re: Adjusting SmPL script “ptr_ret.cocci”?



On Sat, 7 Sep 2019, Markus Elfring wrote:

> Hello,
>
> I have taken another look at a known script for the semantic patch language.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/coccinelle/api/ptr_ret.cocci?id=1e3778cb223e861808ae0daccf353536e7573eed#n3
>
> I got the impression that duplicate SmPL code can be reduced here.
> So I tried the following approach out.
>
> …
> @depends on patch@
> expression ptr;
> @@
> (
> (
> - if (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0;
> |
> - if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
> )
> + return PTR_ERR_OR_ZERO(ptr);
> |
> - (IS_ERR(ptr) ? PTR_ERR(ptr) : 0)
> + PTR_ERR_OR_ZERO(ptr)
> )
> …
>
>
> Unfortunately, I got the following information then for a test transformation.
>
> elfring@...ne:~/Projekte/Linux/next-patched> spatch -D patch scripts/coccinelle/api/ptr_ret.cocci drivers/spi/spi-gpio.c
> …
> 29: no available token to attach to
>
>
> It seems that the Coccinelle software “1.0.7-00218-gf284bf36” does not like
> the addition of the shown return statement after a nested SmPL disjunction.
> But the following SmPL code variant seems to work as expected.
>
>
> …
> @depends on patch@
> expression ptr;
> @@
> (
> - if (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0;
> + return PTR_ERR_OR_ZERO(ptr);
> |
> - if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
> + return PTR_ERR_OR_ZERO(ptr);
> |
> - (IS_ERR(ptr) ? PTR_ERR(ptr) : 0)
> + PTR_ERR_OR_ZERO(ptr)
> )
> …
>
>
> How do you think about to reduce subsequent SmPL rules also according to
> a possible recombination of affected implementation details?

There is not going to be any change with respect to this issue.  It's fine
when replacing one statement by another, but introduces complexity when
removing something more complex.  And there's not point to have something
that works in only one special case.

julia

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ