Skip to content

Commit

Permalink
Merge pull request #45 from github/always-release-rcu-lock
Browse files Browse the repository at this point in the history
[ipt_GLBREDIRECT] Ensure all conntrack paths call rcu_read_unlock.
  • Loading branch information
theojulienne committed Nov 1, 2018
2 parents d5e6f63 + cb0c40b commit aea242e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/glb-redirect/ipt_GLBREDIRECT.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ static unsigned int is_valid_locally(struct net *net, struct sk_buff *skb, int i
goto no_ct_entry;

rcu_read_lock();
/* from now on no_ct_entry_unlock should be used to ensure we release this lock */

thash = nf_conntrack_find_get(net,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
Expand All @@ -437,11 +438,11 @@ static unsigned int is_valid_locally(struct net *net, struct sk_buff *skb, int i
#endif
&tuple);
if (thash == NULL)
goto no_ct_entry;
goto no_ct_entry_unlock;

ct = nf_ct_tuplehash_to_ctrack(thash);
if (ct == NULL)
goto no_ct_entry;
goto no_ct_entry_unlock;

if (!nf_ct_is_dying(ct) && nf_ct_tuple_equal(&tuple, &thash->tuple)) {
nf_ct_put(ct);
Expand All @@ -450,6 +451,7 @@ static unsigned int is_valid_locally(struct net *net, struct sk_buff *skb, int i
}

nf_ct_put(ct);
no_ct_entry_unlock:
rcu_read_unlock();
}

Expand Down

0 comments on commit aea242e

Please sign in to comment.