summaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorKirill Tkhai <ktkhai@virtuozzo.com>2017-11-14 16:51:56 +0300
committerDavid S. Miller <davem@davemloft.net>2017-11-15 14:01:30 +0900
commit11bf284f81b46f59d5f4a4522c13aa7852cfd560 (patch)
treeef75ac5dfa27442a19b463937088e7f2eeca87fb /net/core
parent094009531612246d9e13f9e0c3ae2205d7f63a0a (diff)
downloadtalos-op-linux-11bf284f81b46f59d5f4a4522c13aa7852cfd560.tar.gz
talos-op-linux-11bf284f81b46f59d5f4a4522c13aa7852cfd560.zip
net: Protect iterations over net::fib_notifier_ops in fib_seq_sum()
There is at least unlocked deletion of net->ipv4.fib_notifier_ops from net::fib_notifier_ops: ip_fib_net_exit() rtnl_unlock() fib4_notifier_exit() fib_notifier_ops_unregister(net->ipv4.notifier_ops) list_del_rcu(&ops->list) So fib_seq_sum() can't use rtnl_lock() only for protection. The possible solution could be to use rtnl_lock() in fib_notifier_ops_unregister(), but this adds a possible delay during net namespace creation, so we better use rcu_read_lock() till someone really needs the mutex (if that happens). Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/fib_notifier.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/core/fib_notifier.c b/net/core/fib_notifier.c
index 6b8cd494574f..0c048bdeb016 100644
--- a/net/core/fib_notifier.c
+++ b/net/core/fib_notifier.c
@@ -34,12 +34,14 @@ static unsigned int fib_seq_sum(void)
rtnl_lock();
for_each_net(net) {
- list_for_each_entry(ops, &net->fib_notifier_ops, list) {
+ rcu_read_lock();
+ list_for_each_entry_rcu(ops, &net->fib_notifier_ops, list) {
if (!try_module_get(ops->owner))
continue;
fib_seq += ops->fib_seq_read(net);
module_put(ops->owner);
}
+ rcu_read_unlock();
}
rtnl_unlock();
OpenPOWER on IntegriCloud