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: <20250305080740.68749058@kernel.org>
Date: Wed, 5 Mar 2025 08:07:40 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Breno Leitao <leitao@...ian.org>
Cc: "David S. Miller" <davem@...emloft.net>, Eric Dumazet
 <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>, Simon Horman
 <horms@...nel.org>, Amerigo Wang <amwang@...hat.com>,
 netdev@...r.kernel.org, linux-kernel@...r.kernel.org, kernel-team@...a.com
Subject: Re: [PATCH net] netpoll: guard __netpoll_send_skb() with RCU read
 lock

On Wed, 5 Mar 2025 01:09:49 -0800 Breno Leitao wrote:
> On Tue, Mar 04, 2025 at 05:47:32PM -0800, Jakub Kicinski wrote:
> > On Mon, 03 Mar 2025 03:44:12 -0800 Breno Leitao wrote:  
> > > +	guard(rcu)();  
> > 
> > Scoped guards if you have to.
> > Preferably just lock/unlock like a normal person..  
> 
> Sure, I thought that we would be moving to scoped guards all across the
> board, at least that was my reading for a similar patch I sent a while
> ago:
> 
> 	https://lore.kernel.org/all/20250224123016.GA17456@noisy.programming.kicks-ass.net/
> 
> Anyway, in which case should I use scoped guard instead 

We are certainly not moving to guards in networking. Too C++-sy.
Just lock / unlock please, correctly around the variable you actually
intend to protect.

Quoting documentation:

  Using device-managed and cleanup.h constructs
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  
  Netdev remains skeptical about promises of all "auto-cleanup" APIs,
  including even ``devm_`` helpers, historically. They are not the preferred
  style of implementation, merely an acceptable one.
  
  Use of ``guard()`` is discouraged within any function longer than 20 lines,
  ``scoped_guard()`` is considered more readable. Using normal lock/unlock is
  still (weakly) preferred.
  
  Low level cleanup constructs (such as ``__free()``) can be used when building
  APIs and helpers, especially scoped iterators. However, direct use of
  ``__free()`` within networking core and drivers is discouraged.
  Similar guidance applies to declaring variables mid-function.
  
See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#using-device-managed-and-cleanup-h-constructs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ