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: <20250424230352.69852-1-kuniyu@amazon.com>
Date: Thu, 24 Apr 2025 16:03:44 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <pabeni@...hat.com>
CC: <davem@...emloft.net>, <edumazet@...gle.com>, <horms@...nel.org>,
	<kuba@...nel.org>, <kuni1840@...il.com>, <kuniyu@...zon.com>,
	<netdev@...r.kernel.org>
Subject: Re: [PATCH v2 net-next 6/7] neighbour: Convert RTM_GETNEIGHTBL to RCU.

From: Paolo Abeni <pabeni@...hat.com>
Date: Thu, 24 Apr 2025 10:19:17 +0200
> On 4/18/25 3:26 AM, Kuniyuki Iwashima wrote:
> > neightbl_dump_info() calls neightbl_fill_info() and
> 
> AFAICS neightbl_fill_info() is only invoked from neightbl_dump_info()
> and acquires/releases the RCU internally. Such lock pair should be dropped.

Maybe I got lost, which lock do you mean ??


> 
> > neightbl_fill_param_info() for each neigh_tables[] entry.
> > 
> > Both functions rely on the table lock (read_lock_bh(&tbl->lock)),
> > so RTNL is not needed.
> > 
> > Let's fetch the table under RCU and convert RTM_GETNEIGHTBL to RCU.
> > 
> > Signed-off-by: Kuniyuki Iwashima <kuniyu@...zon.com>
> > ---
> >  net/core/neighbour.c | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/net/core/neighbour.c b/net/core/neighbour.c
> > index ccfef86bb044..38732d8f0ed7 100644
> > --- a/net/core/neighbour.c
> > +++ b/net/core/neighbour.c
> > @@ -2467,10 +2467,12 @@ static int neightbl_dump_info(struct sk_buff *skb, struct netlink_callback *cb)
> >  
> >  	family = ((struct rtgenmsg *)nlmsg_data(nlh))->rtgen_family;
> >  
> > +	rcu_read_lock();
> > +
> >  	for (tidx = 0; tidx < NEIGH_NR_TABLES; tidx++) {
> >  		struct neigh_parms *p;
> >  
> > -		tbl = rcu_dereference_rtnl(neigh_tables[tidx]);
> > +		tbl = rcu_dereference(neigh_tables[tidx]);
> >  		if (!tbl)
> >  			continue;
> 
> Later statements:
> 
> 		p = list_next_entry(&tbl->parms, list);
> 		list_for_each_entry_from(p, &tbl->parms_list, list) {
> 
> are now without any protection, and AFAICS parms_list is write protected
> by tbl->lock. I think it's necessary to move the
> read_lock_bh(&tbl->lock) from neightbl_fill_param_info() to
> neightbl_dump_info() ?!?

Oh, thanks for catching this!

Maybe we should use list_add/del_rcu() instead ?
given neigh_parms_release() frees it after RCU.

> 
> Side note: I guess it would be to follow-up replacing R/W lock with
> plain spinlock/rcu?!?

Yes, it's on my todo list ;)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ