Skip to content

Commit

Permalink
[NETFILTER]: nf_conntrack: fix the race on assign helper to new connt…
Browse files Browse the repository at this point in the history
…rack

The found helper cannot be assigned to conntrack after unlocking
nf_conntrack_lock. This tries to find helper to assign again.

Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Yasuyuki Kozakai authored and David S. Miller committed Nov 29, 2006
1 parent dafc741 commit 22e7410
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions net/netfilter/nf_conntrack_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,12 +893,6 @@ __nf_conntrack_alloc(const struct nf_conntrack_tuple *orig,

memset(conntrack, 0, nf_ct_cache[features].size);
conntrack->features = features;
if (helper) {
struct nf_conn_help *help = nfct_help(conntrack);
NF_CT_ASSERT(help);
help->helper = helper;
}

atomic_set(&conntrack->ct_general.use, 1);
conntrack->ct_general.destroy = destroy_conntrack;
conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple = *orig;
Expand Down Expand Up @@ -982,8 +976,13 @@ init_conntrack(const struct nf_conntrack_tuple *tuple,
#endif
nf_conntrack_get(&conntrack->master->ct_general);
NF_CT_STAT_INC(expect_new);
} else
} else {
struct nf_conn_help *help = nfct_help(conntrack);

if (help)
help->helper = __nf_ct_helper_find(&repl_tuple);
NF_CT_STAT_INC(new);
}

/* Overload tuple linked list to put us in unconfirmed list. */
list_add(&conntrack->tuplehash[IP_CT_DIR_ORIGINAL].list, &unconfirmed);
Expand Down

0 comments on commit 22e7410

Please sign in to comment.