aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorAaron Conole <aconole@bytheb.org>2016-09-21 11:35:04 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2016-09-24 15:29:53 -0400
commite2361cb90a0327bdab34d01d1a7b9dbd67c31e60 (patch)
treed7f8b55fd607e5cb1c0018fa8f1f79d6038d17b3 /net
parent2c1e2703ff812ccaa42a4bc8a25803955e342b85 (diff)
netfilter: Remove explicit rcu_read_lock in nf_hook_slow
All of the callers of nf_hook_slow already hold the rcu_read_lock, so this cleanup removes the recursive call. This is just a cleanup, as the locking code gracefully handles this situation. Signed-off-by: Aaron Conole <aconole@bytheb.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net')
-rw-r--r--net/bridge/netfilter/ebt_redirect.c2
-rw-r--r--net/bridge/netfilter/ebtables.c2
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c2
-rw-r--r--net/ipv4/netfilter/nf_conntrack_proto_icmp.c2
-rw-r--r--net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c2
-rw-r--r--net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c2
-rw-r--r--net/netfilter/core.c6
-rw-r--r--net/netfilter/nf_conntrack_core.c2
-rw-r--r--net/netfilter/nf_conntrack_h323_main.c2
-rw-r--r--net/netfilter/nf_conntrack_helper.c2
-rw-r--r--net/netfilter/nfnetlink_cthelper.c2
-rw-r--r--net/netfilter/nfnetlink_log.c8
-rw-r--r--net/netfilter/nfnetlink_queue.c2
-rw-r--r--net/netfilter/xt_helper.c2
14 files changed, 19 insertions, 19 deletions
diff --git a/net/bridge/netfilter/ebt_redirect.c b/net/bridge/netfilter/ebt_redirect.c
index 203964997a51..2e7c4f974340 100644
--- a/net/bridge/netfilter/ebt_redirect.c
+++ b/net/bridge/netfilter/ebt_redirect.c
@@ -24,7 +24,7 @@ ebt_redirect_tg(struct sk_buff *skb, const struct xt_action_param *par)
24 return EBT_DROP; 24 return EBT_DROP;
25 25
26 if (par->hooknum != NF_BR_BROUTING) 26 if (par->hooknum != NF_BR_BROUTING)
27 /* rcu_read_lock()ed by nf_hook_slow */ 27 /* rcu_read_lock()ed by nf_hook_thresh */
28 ether_addr_copy(eth_hdr(skb)->h_dest, 28 ether_addr_copy(eth_hdr(skb)->h_dest,
29 br_port_get_rcu(par->in)->br->dev->dev_addr); 29 br_port_get_rcu(par->in)->br->dev->dev_addr);
30 else 30 else
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index cceac5bb658f..dd7133216c9c 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -146,7 +146,7 @@ ebt_basic_match(const struct ebt_entry *e, const struct sk_buff *skb,
146 return 1; 146 return 1;
147 if (NF_INVF(e, EBT_IOUT, ebt_dev_check(e->out, out))) 147 if (NF_INVF(e, EBT_IOUT, ebt_dev_check(e->out, out)))
148 return 1; 148 return 1;
149 /* rcu_read_lock()ed by nf_hook_slow */ 149 /* rcu_read_lock()ed by nf_hook_thresh */
150 if (in && (p = br_port_get_rcu(in)) != NULL && 150 if (in && (p = br_port_get_rcu(in)) != NULL &&
151 NF_INVF(e, EBT_ILOGICALIN, 151 NF_INVF(e, EBT_ILOGICALIN,
152 ebt_dev_check(e->logical_in, p->br->dev))) 152 ebt_dev_check(e->logical_in, p->br->dev)))
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index 870aebda2932..713c09a74b90 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -110,7 +110,7 @@ static unsigned int ipv4_helper(void *priv,
110 if (!help) 110 if (!help)
111 return NF_ACCEPT; 111 return NF_ACCEPT;
112 112
113 /* rcu_read_lock()ed by nf_hook_slow */ 113 /* rcu_read_lock()ed by nf_hook_thresh */
114 helper = rcu_dereference(help->helper); 114 helper = rcu_dereference(help->helper);
115 if (!helper) 115 if (!helper)
116 return NF_ACCEPT; 116 return NF_ACCEPT;
diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
index 4b5904bc2614..d075b3cf2400 100644
--- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
+++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
@@ -149,7 +149,7 @@ icmp_error_message(struct net *net, struct nf_conn *tmpl, struct sk_buff *skb,
149 return -NF_ACCEPT; 149 return -NF_ACCEPT;
150 } 150 }
151 151
152 /* rcu_read_lock()ed by nf_hook_slow */ 152 /* rcu_read_lock()ed by nf_hook_thresh */
153 innerproto = __nf_ct_l4proto_find(PF_INET, origtuple.dst.protonum); 153 innerproto = __nf_ct_l4proto_find(PF_INET, origtuple.dst.protonum);
154 154
155 /* Ordinarily, we'd expect the inverted tupleproto, but it's 155 /* Ordinarily, we'd expect the inverted tupleproto, but it's
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index 1aa5848764a7..963ee3848675 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -115,7 +115,7 @@ static unsigned int ipv6_helper(void *priv,
115 help = nfct_help(ct); 115 help = nfct_help(ct);
116 if (!help) 116 if (!help)
117 return NF_ACCEPT; 117 return NF_ACCEPT;
118 /* rcu_read_lock()ed by nf_hook_slow */ 118 /* rcu_read_lock()ed by nf_hook_thresh */
119 helper = rcu_dereference(help->helper); 119 helper = rcu_dereference(help->helper);
120 if (!helper) 120 if (!helper)
121 return NF_ACCEPT; 121 return NF_ACCEPT;
diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
index 660bc10c7a9c..f5a61bc3ec2b 100644
--- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
@@ -165,7 +165,7 @@ icmpv6_error_message(struct net *net, struct nf_conn *tmpl,
165 return -NF_ACCEPT; 165 return -NF_ACCEPT;
166 } 166 }
167 167
168 /* rcu_read_lock()ed by nf_hook_slow */ 168 /* rcu_read_lock()ed by nf_hook_thresh */
169 inproto = __nf_ct_l4proto_find(PF_INET6, origtuple.dst.protonum); 169 inproto = __nf_ct_l4proto_find(PF_INET6, origtuple.dst.protonum);
170 170
171 /* Ordinarily, we'd expect the inverted tupleproto, but it's 171 /* Ordinarily, we'd expect the inverted tupleproto, but it's
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index f39276d1c2d7..c8faf8102394 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -291,16 +291,13 @@ repeat:
291 291
292 292
293/* Returns 1 if okfn() needs to be executed by the caller, 293/* Returns 1 if okfn() needs to be executed by the caller,
294 * -EPERM for NF_DROP, 0 otherwise. */ 294 * -EPERM for NF_DROP, 0 otherwise. Caller must hold rcu_read_lock. */
295int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state) 295int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state)
296{ 296{
297 struct nf_hook_ops *elem; 297 struct nf_hook_ops *elem;
298 unsigned int verdict; 298 unsigned int verdict;
299 int ret = 0; 299 int ret = 0;
300 300
301 /* We may already have this, but read-locks nest anyway */
302 rcu_read_lock();
303
304 elem = list_entry_rcu(state->hook_list, struct nf_hook_ops, list); 301 elem = list_entry_rcu(state->hook_list, struct nf_hook_ops, list);
305next_hook: 302next_hook:
306 verdict = nf_iterate(state->hook_list, skb, state, &elem); 303 verdict = nf_iterate(state->hook_list, skb, state, &elem);
@@ -321,7 +318,6 @@ next_hook:
321 kfree_skb(skb); 318 kfree_skb(skb);
322 } 319 }
323 } 320 }
324 rcu_read_unlock();
325 return ret; 321 return ret;
326} 322}
327EXPORT_SYMBOL(nf_hook_slow); 323EXPORT_SYMBOL(nf_hook_slow);
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 8d1ddb9b63ed..c94ec197845c 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -1275,7 +1275,7 @@ nf_conntrack_in(struct net *net, u_int8_t pf, unsigned int hooknum,
1275 skb->nfct = NULL; 1275 skb->nfct = NULL;
1276 } 1276 }
1277 1277
1278 /* rcu_read_lock()ed by nf_hook_slow */ 1278 /* rcu_read_lock()ed by nf_hook_thresh */
1279 l3proto = __nf_ct_l3proto_find(pf); 1279 l3proto = __nf_ct_l3proto_find(pf);
1280 ret = l3proto->get_l4proto(skb, skb_network_offset(skb), 1280 ret = l3proto->get_l4proto(skb, skb_network_offset(skb),
1281 &dataoff, &protonum); 1281 &dataoff, &protonum);
diff --git a/net/netfilter/nf_conntrack_h323_main.c b/net/netfilter/nf_conntrack_h323_main.c
index 5c0db5c64734..f65d93639d12 100644
--- a/net/netfilter/nf_conntrack_h323_main.c
+++ b/net/netfilter/nf_conntrack_h323_main.c
@@ -736,7 +736,7 @@ static int callforward_do_filter(struct net *net,
736 const struct nf_afinfo *afinfo; 736 const struct nf_afinfo *afinfo;
737 int ret = 0; 737 int ret = 0;
738 738
739 /* rcu_read_lock()ed by nf_hook_slow() */ 739 /* rcu_read_lock()ed by nf_hook_thresh */
740 afinfo = nf_get_afinfo(family); 740 afinfo = nf_get_afinfo(family);
741 if (!afinfo) 741 if (!afinfo)
742 return 0; 742 return 0;
diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
index 4ffe388a9a1e..336e21559e01 100644
--- a/net/netfilter/nf_conntrack_helper.c
+++ b/net/netfilter/nf_conntrack_helper.c
@@ -346,7 +346,7 @@ void nf_ct_helper_log(struct sk_buff *skb, const struct nf_conn *ct,
346 /* Called from the helper function, this call never fails */ 346 /* Called from the helper function, this call never fails */
347 help = nfct_help(ct); 347 help = nfct_help(ct);
348 348
349 /* rcu_read_lock()ed by nf_hook_slow */ 349 /* rcu_read_lock()ed by nf_hook_thresh */
350 helper = rcu_dereference(help->helper); 350 helper = rcu_dereference(help->helper);
351 351
352 nf_log_packet(nf_ct_net(ct), nf_ct_l3num(ct), 0, skb, NULL, NULL, NULL, 352 nf_log_packet(nf_ct_net(ct), nf_ct_l3num(ct), 0, skb, NULL, NULL, NULL,
diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c
index e924e95fcc7f..3b79f34b5095 100644
--- a/net/netfilter/nfnetlink_cthelper.c
+++ b/net/netfilter/nfnetlink_cthelper.c
@@ -43,7 +43,7 @@ nfnl_userspace_cthelper(struct sk_buff *skb, unsigned int protoff,
43 if (help == NULL) 43 if (help == NULL)
44 return NF_DROP; 44 return NF_DROP;
45 45
46 /* rcu_read_lock()ed by nf_hook_slow */ 46 /* rcu_read_lock()ed by nf_hook_thresh */
47 helper = rcu_dereference(help->helper); 47 helper = rcu_dereference(help->helper);
48 if (helper == NULL) 48 if (helper == NULL)
49 return NF_DROP; 49 return NF_DROP;
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index 6577db524ef6..eb086a192c5a 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -442,7 +442,9 @@ __build_packet_message(struct nfnl_log_net *log,
442 if (nla_put_be32(inst->skb, NFULA_IFINDEX_PHYSINDEV, 442 if (nla_put_be32(inst->skb, NFULA_IFINDEX_PHYSINDEV,
443 htonl(indev->ifindex)) || 443 htonl(indev->ifindex)) ||
444 /* this is the bridge group "brX" */ 444 /* this is the bridge group "brX" */
445 /* rcu_read_lock()ed by nf_hook_slow or nf_log_packet */ 445 /* rcu_read_lock()ed by nf_hook_thresh or
446 * nf_log_packet.
447 */
446 nla_put_be32(inst->skb, NFULA_IFINDEX_INDEV, 448 nla_put_be32(inst->skb, NFULA_IFINDEX_INDEV,
447 htonl(br_port_get_rcu(indev)->br->dev->ifindex))) 449 htonl(br_port_get_rcu(indev)->br->dev->ifindex)))
448 goto nla_put_failure; 450 goto nla_put_failure;
@@ -477,7 +479,9 @@ __build_packet_message(struct nfnl_log_net *log,
477 if (nla_put_be32(inst->skb, NFULA_IFINDEX_PHYSOUTDEV, 479 if (nla_put_be32(inst->skb, NFULA_IFINDEX_PHYSOUTDEV,
478 htonl(outdev->ifindex)) || 480 htonl(outdev->ifindex)) ||
479 /* this is the bridge group "brX" */ 481 /* this is the bridge group "brX" */
480 /* rcu_read_lock()ed by nf_hook_slow or nf_log_packet */ 482 /* rcu_read_lock()ed by nf_hook_thresh or
483 * nf_log_packet.
484 */
481 nla_put_be32(inst->skb, NFULA_IFINDEX_OUTDEV, 485 nla_put_be32(inst->skb, NFULA_IFINDEX_OUTDEV,
482 htonl(br_port_get_rcu(outdev)->br->dev->ifindex))) 486 htonl(br_port_get_rcu(outdev)->br->dev->ifindex)))
483 goto nla_put_failure; 487 goto nla_put_failure;
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index 808da34f94cd..7caa8b082c41 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -740,7 +740,7 @@ nfqnl_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum)
740 struct net *net = entry->state.net; 740 struct net *net = entry->state.net;
741 struct nfnl_queue_net *q = nfnl_queue_pernet(net); 741 struct nfnl_queue_net *q = nfnl_queue_pernet(net);
742 742
743 /* rcu_read_lock()ed by nf_hook_slow() */ 743 /* rcu_read_lock()ed by nf_hook_thresh */
744 queue = instance_lookup(q, queuenum); 744 queue = instance_lookup(q, queuenum);
745 if (!queue) 745 if (!queue)
746 return -ESRCH; 746 return -ESRCH;
diff --git a/net/netfilter/xt_helper.c b/net/netfilter/xt_helper.c
index 805c9f64a04c..f679dd4c272a 100644
--- a/net/netfilter/xt_helper.c
+++ b/net/netfilter/xt_helper.c
@@ -41,7 +41,7 @@ helper_mt(const struct sk_buff *skb, struct xt_action_param *par)
41 if (!master_help) 41 if (!master_help)
42 return ret; 42 return ret;
43 43
44 /* rcu_read_lock()ed by nf_hook_slow */ 44 /* rcu_read_lock()ed by nf_hook_thresh */
45 helper = rcu_dereference(master_help->helper); 45 helper = rcu_dereference(master_help->helper);
46 if (!helper) 46 if (!helper)
47 return ret; 47 return ret;