When IPV6_MROUTE_MULTIPLE_TABLES is enabled, multicast routing tables
must be read under RCU or RTNL lock.
In case ip6mr_mfc_seq_start() fails with an error (currently not
possible, as RT6_TABLE_DFLT always exists, ip6mr_get_table() cannot fail
in this case), ip6mr_mfc_seq_stop() would be called and release the RCU
lock.
Fixes: d1db275dd3f6 ("ipv6: ip6mr: support multiple tables")
Signed-off-by: Stefan Wiehler <stefan.wiehler@nokia.com>
---
net/ipv6/ip6mr.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 9bf42aafc7f0..90d0f09cdd4e 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -464,10 +464,12 @@ static const struct seq_operations ip6mr_vif_seq_ops = {
};
static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos)
+ __acquires(RCU)
{
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);
@@ -475,6 +477,12 @@ static void *ipmr_mfc_seq_start(struct seq_file *seq, loff_t *pos)
return mr_mfc_seq_start(seq, pos, mrt, &mfc_unres_lock);
}
+static void ipmr_mfc_seq_stop(struct seq_file *seq, void *v)
+ __releases(RCU)
+{
+ rcu_read_unlock();
+}
+
static int ipmr_mfc_seq_show(struct seq_file *seq, void *v)
{
int n;
@@ -520,7 +528,7 @@ static int ipmr_mfc_seq_show(struct seq_file *seq, void *v)
static const struct seq_operations ipmr_mfc_seq_ops = {
.start = ipmr_mfc_seq_start,
.next = mr_mfc_seq_next,
- .stop = mr_mfc_seq_stop,
+ .stop = ipmr_mfc_seq_stop,
.show = ipmr_mfc_seq_show,
};
#endif
--
2.42.0