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: <20241016091152.3504685-1-gnaaman@drivenets.com>
Date: Wed, 16 Oct 2024 09:11:52 +0000
From: Gilad Naaman <gnaaman@...venets.com>
To: kuniyu@...zon.com
Cc: davem@...emloft.net,
	edumazet@...gle.com,
	gnaaman@...venets.com,
	kuba@...nel.org,
	netdev@...r.kernel.org,
	pabeni@...hat.com
Subject: Re: [PATCH net-next v4 3/6] Convert neigh_* seq_file functions to use hlist

> > -		if (++state->bucket >= (1 << nht->hash_shift))
> > -			break;
> 
> Let's keep this,
> 
> 
> > +		while (!n && ++state->bucket < (1 << nht->hash_shift))
> > +			n = neigh_first_rcu(&nht->hash_heads[state->bucket]);
> >  
> > -		n = rcu_dereference(nht->hash_buckets[state->bucket]);
> 
> and simply fetch neigh_first_entry().
> 
> Then, we can let the next loop handle the termination condition
> and keep the code simple.

Unfortunately `hlist_for_each_entry_continue_rcu` dereferences `n`
first thing using `hlist_next_rcu`, before checking for NULL:

    #define hlist_for_each_entry_continue_rcu(pos, member)			\
    	for (pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \
    			&(pos)->member)), typeof(*(pos)), member);	\
    	     pos;							\
    	     pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu(	\
    			&(pos)->member)), typeof(*(pos)), member))

If I'm using it, I have to add a null-check after calling `neigh_first_entry`.

Another alternative is to use `hlist_for_each_entry_from_rcu`,
but it'll require calling `next` one time before the loop.

Is this preferable?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ