Skip to content

Commit

Permalink
netfilter: nf_queue: remove rcu_read_lock calls
Browse files Browse the repository at this point in the history
All verdict handlers make use of the nfnetlink .call_rcu callback
so rcu readlock is already held.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Florian Westphal authored and Pablo Neira Ayuso committed Oct 16, 2015
1 parent ed78d09 commit 81b4325
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions net/netfilter/nf_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,20 @@ int nf_queue(struct sk_buff *skb,
const struct nf_queue_handler *qh;

/* QUEUE == DROP if no one is waiting, to be safe. */
rcu_read_lock();

qh = rcu_dereference(queue_handler);
if (!qh) {
status = -ESRCH;
goto err_unlock;
goto err;
}

afinfo = nf_get_afinfo(state->pf);
if (!afinfo)
goto err_unlock;
goto err;

entry = kmalloc(sizeof(*entry) + afinfo->route_key_size, GFP_ATOMIC);
if (!entry) {
status = -ENOMEM;
goto err_unlock;
goto err;
}

*entry = (struct nf_queue_entry) {
Expand All @@ -154,17 +152,13 @@ int nf_queue(struct sk_buff *skb,
afinfo->saveroute(skb, entry);
status = qh->outfn(entry, queuenum);

rcu_read_unlock();

if (status < 0) {
nf_queue_entry_release_refs(entry);
goto err;
}

return 0;

err_unlock:
rcu_read_unlock();
err:
kfree(entry);
return status;
Expand All @@ -177,8 +171,6 @@ void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)
const struct nf_afinfo *afinfo;
int err;

rcu_read_lock();

nf_queue_entry_release_refs(entry);

/* Continue traversal iff userspace said ok... */
Expand Down Expand Up @@ -221,7 +213,7 @@ void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict)
default:
kfree_skb(skb);
}
rcu_read_unlock();

kfree(entry);
}
EXPORT_SYMBOL(nf_reinject);

0 comments on commit 81b4325

Please sign in to comment.