linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netfilter: ipset: Pass lockdep expression to RCU lists
@ 2020-02-16 17:26 Amol Grover
  2020-04-06  7:06 ` Amol Grover
  2020-04-06 12:31 ` Pablo Neira Ayuso
  0 siblings, 2 replies; 3+ messages in thread
From: Amol Grover @ 2020-02-16 17:26 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	David S . Miller, Jakub Kicinski, Jeremy Sowden, Florent Fourcot,
	Kate Stewart, Johannes Berg
  Cc: netfilter-devel, coreteam, netdev, linux-kernel,
	linux-kernel-mentees, Joel Fernandes, Madhuparna Bhowmik,
	Paul E . McKenney, Amol Grover

ip_set_type_list is traversed using list_for_each_entry_rcu
outside an RCU read-side critical section but under the protection
of ip_set_type_mutex.

Hence, add corresponding lockdep expression to silence false-positive
warnings, and harden RCU lists.

Signed-off-by: Amol Grover <frextrite@gmail.com>
---
 net/netfilter/ipset/ip_set_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index cf895bc80871..97c851589160 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -86,7 +86,8 @@ find_set_type(const char *name, u8 family, u8 revision)
 {
 	struct ip_set_type *type;
 
-	list_for_each_entry_rcu(type, &ip_set_type_list, list)
+	list_for_each_entry_rcu(type, &ip_set_type_list, list,
+				lockdep_is_held(&ip_set_type_mutex))
 		if (STRNCMP(type->name, name) &&
 		    (type->family == family ||
 		     type->family == NFPROTO_UNSPEC) &&
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] netfilter: ipset: Pass lockdep expression to RCU lists
  2020-02-16 17:26 [PATCH] netfilter: ipset: Pass lockdep expression to RCU lists Amol Grover
@ 2020-04-06  7:06 ` Amol Grover
  2020-04-06 12:31 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 3+ messages in thread
From: Amol Grover @ 2020-04-06  7:06 UTC (permalink / raw)
  To: David S . Miller
  Cc: netfilter-devel, coreteam, netdev, linux-kernel,
	Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	Jakub Kicinski, Jeremy Sowden, Florent Fourcot, Kate Stewart,
	Johannes Berg, linux-kernel-mentees, Joel Fernandes,
	Madhuparna Bhowmik, Paul E . McKenney

On Sun, Feb 16, 2020 at 10:56:54PM +0530, Amol Grover wrote:
> ip_set_type_list is traversed using list_for_each_entry_rcu
> outside an RCU read-side critical section but under the protection
> of ip_set_type_mutex.
> 
> Hence, add corresponding lockdep expression to silence false-positive
> warnings, and harden RCU lists.
> 
> Signed-off-by: Amol Grover <frextrite@gmail.com>
> ---

Hi David

Could you please go through this patch aswell? This patch was directed to 
preemptively fix the _suspicious RCU usage_ warning which is now also
being reported by Kernel Test Robot.

[   11.654186] =============================
[   11.654619] WARNING: suspicious RCU usage
[   11.655022] 5.6.0-rc1-00179-gdb4ead2cd5253 #1 Not tainted
[   11.655583] -----------------------------
[   11.656001] net/netfilter/ipset/ip_set_core.c:89 RCU-list traversed in non-reader section!!

Thanks
Amol

>  net/netfilter/ipset/ip_set_core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
> index cf895bc80871..97c851589160 100644
> --- a/net/netfilter/ipset/ip_set_core.c
> +++ b/net/netfilter/ipset/ip_set_core.c
> @@ -86,7 +86,8 @@ find_set_type(const char *name, u8 family, u8 revision)
>  {
>  	struct ip_set_type *type;
>  
> -	list_for_each_entry_rcu(type, &ip_set_type_list, list)
> +	list_for_each_entry_rcu(type, &ip_set_type_list, list,
> +				lockdep_is_held(&ip_set_type_mutex))
>  		if (STRNCMP(type->name, name) &&
>  		    (type->family == family ||
>  		     type->family == NFPROTO_UNSPEC) &&
> -- 
> 2.24.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] netfilter: ipset: Pass lockdep expression to RCU lists
  2020-02-16 17:26 [PATCH] netfilter: ipset: Pass lockdep expression to RCU lists Amol Grover
  2020-04-06  7:06 ` Amol Grover
@ 2020-04-06 12:31 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2020-04-06 12:31 UTC (permalink / raw)
  To: Amol Grover
  Cc: Jozsef Kadlecsik, Florian Westphal, David S . Miller,
	Jakub Kicinski, Jeremy Sowden, Florent Fourcot, Kate Stewart,
	Johannes Berg, netfilter-devel, coreteam, netdev, linux-kernel,
	linux-kernel-mentees, Joel Fernandes, Madhuparna Bhowmik,
	Paul E . McKenney

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-06 12:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-16 17:26 [PATCH] netfilter: ipset: Pass lockdep expression to RCU lists Amol Grover
2020-04-06  7:06 ` Amol Grover
2020-04-06 12:31 ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).