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]
Message-ID: <Z7EEQalDIm1n_XRc@pavilion.home>
Date: Sat, 15 Feb 2025 22:16:49 +0100
From: Frederic Weisbecker <frederic@...nel.org>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Breno Leitao <leitao@...ian.org>, LKML <linux-kernel@...r.kernel.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...hat.com>, Will Deacon <will@...nel.org>,
	Boqun Feng <boqun.feng@...il.com>, Waiman Long <longman@...hat.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>,
	Simon Horman <horms@...nel.org>, Hayes Wang <hayeswang@...ltek.com>,
	linux-usb@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH 1/2] net: Assert proper context while calling
 napi_schedule()

Le Fri, Feb 14, 2025 at 02:00:45PM -0800, Jakub Kicinski a écrit :
> On Thu, 13 Feb 2025 21:38:12 +0100 Frederic Weisbecker wrote:
> > > > Just to make sure I follow the netpoll issue. What would you like to fix
> > > > in netpoll exactly?  
> > > 
> > > Nothing in netpoll, the problem is that netdevsim calls napi_schedule
> > > from the xmit path. That's incompatible with netpoll. We should fix
> > > netdevsim instead (unless more real drivers need napi-from-xmit to
> > > work).  
> > 
> > Let me clarify, because I don't know much this area. If the problem is that xmit
> > can't call napi_schedule() by design, then I defer to you. But if the problem is that
> > napi_schedule() may or may not be called from an interrupt, please note that
> > local_bh_enable() won't run softirqs from a hardirq and will instead defer to
> > IRQ tail. So it's fine to do an unconditional pair of local_bh_disable() / local_bh_enable().
> 
> I don't know where this is in the code TBH, but my understanding is
> that HW IRQs - yes, as you say it'd be safe; the problem is that 
> we have local_irq_save() all over the place. And that is neither
> protected from local_bh_enable(), not does irq_restore execute softirqs.

Yeah actually checking local_bh_enable() again, it's not safe to call within
a hardirq. Ok I've been thinking some more and how about this instead?

diff --git a/net/core/dev.c b/net/core/dev.c
index c0021cbd28fc..2419cc558a64 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4692,7 +4692,7 @@ static inline void ____napi_schedule(struct softnet_data *sd,
 	 * we have to raise NET_RX_SOFTIRQ.
 	 */
 	if (!sd->in_net_rx_action)
-		__raise_softirq_irqoff(NET_RX_SOFTIRQ);
+		raise_softirq_irqoff(NET_RX_SOFTIRQ);
 }
 
 #ifdef CONFIG_RPS


This will simply wake up ksoftirqd if called from a non-IRQ. I expect such
callers to be rare enough to not impact performances and it has the advantage
to work for everyone.

Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ