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: <f2cb7502-4fe7-4803-a6e6-674280120235@roeck-us.net>
Date: Wed, 27 Nov 2024 17:34:14 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: Joe Damato <jdamato@...tly.com>, netdev@...r.kernel.org,
	mkarsten@...terloo.ca, skhawaja@...gle.com, sdf@...ichev.me,
	bjorn@...osinc.com, amritha.nambiar@...el.com,
	sridhar.samudrala@...el.com, willemdebruijn.kernel@...il.com,
	edumazet@...gle.com, Jakub Kicinski <kuba@...nel.org>,
	"David S. Miller" <davem@...emloft.net>,
	Paolo Abeni <pabeni@...hat.com>, Jonathan Corbet <corbet@....net>,
	Jiri Pirko <jiri@...nulli.us>,
	Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
	Lorenzo Bianconi <lorenzo@...nel.org>,
	Johannes Berg <johannes.berg@...el.com>,
	"open list:DOCUMENTATION" <linux-doc@...r.kernel.org>,
	open list <linux-kernel@...r.kernel.org>, pcnet32@...ntier.com
Subject: Re: [net-next v6 5/9] net: napi: Add napi_config

On Wed, Nov 27, 2024 at 05:17:15PM -0800, Joe Damato wrote:
> 
> Guenter: would you mind sending me your cocci script? Mostly for
> selfish reasons; I'd like to see how you did it so I can learn more
> :) Feel free to do so off list if you prefer.
> 
You mean because it is so clumsy ? :-). No worries, I attached
it below. It is way too complicated, but it was good enough
for a quick hack.

> I tried to write my first coccinelle script (which you can find
> below) that is probably wrong, but it attempts to detect:
>   - interrupt routines that hold locks
>   - in drivers that call napi_enable between a lock/unlock
> 
> I couldn't figure out how to get regexps to work in my script, so I
> made a couple variants of the script for each of the spin_lock_*
> variants and ran them all.

I pretty much did the same, only in one script.

> 
> Only one offender was detected: pcnet32.
> 

Your script doesn't take into account that the spinlock may have been
released before the call to napi_enable(). Other than that it should
work just fine. I didn't try to track the interrupt handler because
tracking that through multiple functions can be difficult.

Thanks,
Guenter

---
virtual report

@f1@
identifier flags;
position p;
expression e;
@@

<...
    spin_lock_irqsave@p(e, flags);
    ... when != spin_unlock_irqrestore(e, flags);
    napi_enable(...);
    ... when any
    spin_unlock_irqrestore(e, flags);
...>

@f2@
position p;
expression e;
@@

<...
    spin_lock_irq@p(e);
    ... when != spin_unlock_irq(e);
    napi_enable(...);
    ... when any
    spin_unlock_irq(e);
...>

@f3@
position p;
expression e;
@@

<...
    spin_lock@p(e);
    ... when != spin_unlock(e);
    napi_enable(...);
    ... when any
    spin_unlock(e);
...>

@script:python@
p << f1.p;
@@

print("napi_enable called under spin_lock_irqsave from %s:%s" % (p[0].file, p[0].line))

@script:python@
p << f2.p;
@@

print("napi_enable called under spin_lock_irq from %s:%s" % (p[0].file, p[0].line))

@script:python@
p << f3.p;
@@

print("napi_enable called under spin_lock from %s:%s" % (p[0].file, p[0].line))

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ