2020-05-16 07:47:18

by Madhuparna Bhowmik

[permalink] [raw]
Subject: [PATCH net v2] ipv6: Fix suspicious RCU usage warning in ip6mr

From: Madhuparna Bhowmik <[email protected]>

This patch fixes the following warning:

=============================
WARNING: suspicious RCU usage
5.7.0-rc4-next-20200507-syzkaller #0 Not tainted
-----------------------------
net/ipv6/ip6mr.c:124 RCU-list traversed in non-reader section!!

ipmr_new_table() returns an existing table, but there is no table at
init. Therefore the condition: either holding rtnl or the list is empty
is used.

Fixes: d1db275dd3f6e ("ipv6: ip6mr: support multiple tables")
Reported-by: kernel test robot <[email protected]>
Suggested-by: Jakub Kicinski <[email protected]>
Signed-off-by: Madhuparna Bhowmik <[email protected]>
---
v2:
- Add correct fixes tag
- Fix line over 80 chars

net/ipv6/ip6mr.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 65a54d74acc1..1e223e26f079 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -98,7 +98,8 @@ static void ipmr_expire_process(struct timer_list *t);
#ifdef CONFIG_IPV6_MROUTE_MULTIPLE_TABLES
#define ip6mr_for_each_table(mrt, net) \
list_for_each_entry_rcu(mrt, &net->ipv6.mr6_tables, list, \
- lockdep_rtnl_is_held())
+ lockdep_rtnl_is_held() || \
+ list_empty(&net->ipv6.mr6_tables))

static struct mr_table *ip6mr_mr_table_iter(struct net *net,
struct mr_table *mrt)
--
2.17.1


2020-05-16 20:44:53

by David Miller

[permalink] [raw]
Subject: Re: [PATCH net v2] ipv6: Fix suspicious RCU usage warning in ip6mr

From: [email protected]
Date: Sat, 16 May 2020 13:15:15 +0530

> From: Madhuparna Bhowmik <[email protected]>
>
> This patch fixes the following warning:
>
> =============================
> WARNING: suspicious RCU usage
> 5.7.0-rc4-next-20200507-syzkaller #0 Not tainted
> -----------------------------
> net/ipv6/ip6mr.c:124 RCU-list traversed in non-reader section!!
>
> ipmr_new_table() returns an existing table, but there is no table at
> init. Therefore the condition: either holding rtnl or the list is empty
> is used.
>
> Fixes: d1db275dd3f6e ("ipv6: ip6mr: support multiple tables")
> Reported-by: kernel test robot <[email protected]>
> Suggested-by: Jakub Kicinski <[email protected]>
> Signed-off-by: Madhuparna Bhowmik <[email protected]>

Applied and queued up for -stable, thanks.