Subject: Re: [PATCH] ip6mr: Fix lockdep and sparse RCU warnings

From: Jakub Kicinski <[email-masked]>
Date: Thu, 6 Jun 2024 17:44:27 -0700

On Wed,  5 Jun 2024 21:53:55 +0200 Petr Malat wrote:
> ip6mr_vif_seq_start() must lock RCU even in a case of error, because
> stop callback is called unconditionally.
> 
> When IPV6_MROUTE_MULTIPLE_TABLES is enabled, calls to ip6mr_get_table
> should be done under RCU or RTNL lock. Lock RCU before the call unless
> it's done already or RTNL lock is held.

Patch does not apply, please rebase on:
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git
if its still legit.

And please add a Fixes tag, since its a fix.

> Signed-off-by: Petr Malat <[email-masked]>
> ---
>  net/ipv6/ip6mr.c | 52 +++++++++++++++++++++++++++++++-----------------
>  1 file changed, 34 insertions(+), 18 deletions(-)
> 
> diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
> index cb0ee81a068a..bf6932535d6d 100644
> --- a/net/ipv6/ip6mr.c
> +++ b/net/ipv6/ip6mr.c
> @@ -411,13 +411,14 @@ static void *ip6mr_vif_seq_start(struct seq_file *seq, loff_t *pos)
>  	struct net *net = seq_file_net(seq);
>  	struct mr_table *mrt;
>  
> +	rcu_read_lock();
> +
>  	mrt = ip6mr_get_table(net, RT6_TABLE_DFLT);
>  	if (!mrt)
>  		return ERR_PTR(-ENOENT);

Double check for bugs like missing unlock, too...