mld: respect RCU rules in ip6_mc_source() and ip6_mc_msfilter()
authorEric Dumazet <edumazet@google.com>
Fri, 29 Apr 2022 16:20:36 +0000 (09:20 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 May 2022 10:30:18 +0000 (12:30 +0200)
commit9bcb779ba80b96de4d3f2fe444ca490adf7d02b6
tree4dec3490b684f57d8fdb63a24b4cb6fdcae2cc14
parent299c189f4778267740026feffded245ce96ae65c
mld: respect RCU rules in ip6_mc_source() and ip6_mc_msfilter()

commit a9384a4c1d250cb40cebf50e41459426d160b08e upstream.

Whenever RCU protected list replaces an object,
the pointer to the new object needs to be updated
_before_ the call to kfree_rcu() or call_rcu()

Also ip6_mc_msfilter() needs to update the pointer
before releasing the mc_lock mutex.

Note that linux-5.13 was supporting kfree_rcu(NULL, rcu),
so this fix does not need the conditional test I was
forced to use in the equivalent patch for IPv4.

Fixes: 882ba1f73c06 ("mld: convert ipv6_mc_socklist->sflist to RCU")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ipv6/mcast.c