netfilter: ipt_CLUSTERIP: Pass lockdep expression to RCU lists
Subsystems (3)
PATCH 1/1 netfilter: ipt_CLUSTERIP: Pass lockdep expression to RCU lists
cn->configs is traversed using list_for_each_entry_rcu outside an RCU read-side critical section but under the protection of cn->lock.
Hence, add corresponding lockdep expression to silence false-positive warnings, and harden RCU lists.
--- net/ipv4/netfilter/ipt_CLUSTERIP.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/ipv4/netfilter/ipt_CLUSTERIP.c +4 -2
@@ -139,7 +139,8 @@ __clusterip_config_find(struct net *net, __be32 clusterip)struct clusterip_config *c;struct clusterip_net *cn =clusterip_pernet (net); -list_for_each_entry_rcu (c, &cn->configs, list) { +list_for_each_entry_rcu (c, &cn->configs, list, +lockdep_is_held (&cn->lock)) {if (c->clusterip == clusterip)return c; }
@@ -194,7 +195,8 @@ clusterip_netdev_event(struct notifier_block *this, unsigned long event,struct clusterip_config *c;spin_lock_bh (&cn->lock); -list_for_each_entry_rcu (c, &cn->configs, list) { +list_for_each_entry_rcu (c, &cn->configs, list, +lockdep_is_held (&cn->lock)) {switch (event) {case NETDEV_REGISTER :if (!strcmp (dev->name, c->ifname)) {
Signature · 1 line
2.24.1
Pablo Neira Ayuso
maintainerQuoted 17 lines · Amol Grover
cn->configsis traversed usinglist_for_each_entry_rcuoutside an RCU read-side critical section but under the protection ofcn->lock.Hence, add corresponding lockdep expression to silence false-positive warnings, and harden RCU lists.
Signed-off-by Amol Grover <[email protected]>--- net/ipv4/netfilter/ipt_CLUSTERIP.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)net/ipv4/netfilter/ipt_CLUSTERIP.c +0
-0
net/ipv4/netfilter/ipt_CLUSTERIP.c __clusterip_config_find(struct net *net, __be32 clusterip) · line 143
Quoted 6 lines
net/ipv4/netfilter/ipt_CLUSTERIP.c +2
-1@@ -139,7 +139,8 @@ __clusterip_config_find(struct net *net, __be32 clusterip)struct clusterip_config *c;struct clusterip_net *cn =clusterip_pernet (net); -list_for_each_entry_rcu (c, &cn->configs, list) { +list_for_each_entry_rcu (c, &cn->configs, list, +lockdep_is_held (&cn->lock)) {
bh is disabled before calling __clusterip_config_find(), then rcu_read_lock_any_held() evaluates true.
Are you sure this really results in a WARN_ON splat?