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:   Thu, 9 Mar 2017 21:15:21 +0100 (CET)
From:   Julia Lawall <julia.lawall@...6.fr>
To:     Julia Cartwright <julia@...com>
cc:     Gilles Muller <Gilles.Muller@...6.fr>,
        Nicolas Palix <nicolas.palix@...g.fr>,
        Michal Marek <mmarek@...e.com>, linux-kernel@...r.kernel.org,
        Thomas Gleixner <tglx@...utronix.de>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
        Linus Walleij <linus.walleij@...aro.org>, cocci@...teme.lip6.fr
Subject: Re: [PATCH 01/19] Coccinelle: locks: identify callers of
 spin_lock{,_irq,_irqsave}() in irqchip implementations

> +@...ch2 depends on match@
> +identifier match.__irq_mask;
> +identifier data;
> +identifier x;
> +identifier l;
> +type T;
> +position j0;
> +expression flags;
> +@@
> +	static void __irq_mask(struct irq_data *data)
> +	{
> +		...
> +		T *x;
> +		...
> +(
> +		spin_lock_irqsave(&x->l@j0, flags);
> +|
> +		spin_lock_irq(&x->l@j0);
> +|
> +		spin_lock(&x->l@j0);
> +)
> +		...
> +	}

I guess that here you want a match if there is a lock anywhere in the
function?  Currently, the rule requires that the lock appear on every
control-flow path.  If you put exists after depends on match in the rule
header, it will match if there exists a control-flow patch that contains a
local call.

Also, ... matches the shortest path between the pattern before the ... and
the pattern after.  Thus, x would have to be the first variable in the
function of pointer type.  To eliminate this constraint, put when any on
each of the ...s.  This will additionally allow more than one lock call in
the function.

All in all, I would suggest the following for this rule:

@match2 depends on match exists@
identifier match.__irq_mask;
identifier data;
identifier x;
identifier l;
type T;
position j0;
expression flags;
@@
	static void __irq_mask(struct irq_data *data)
        {
                ... when any
                T *x;
                ... when any
(
                spin_lock_irqsave(&x->l@j0, flags);
|
                spin_lock_irq(&x->l@j0);
|
                spin_lock(&x->l@j0);
)
                ... when any
        }

julia

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ