* [PATCH nf] netfilter: expect: add to hash table after expect init
@ 2017-07-10 13:06 Florian Westphal
2017-07-24 10:20 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2017-07-10 13:06 UTC (permalink / raw)
To: netfilter-devel; +Cc: Florian Westphal
assuming we have lockless readers we should make sure they can only
see expectations that have already been initialized.
hlist_add_head_rcu acts as memory barrier, move it after timer setup.
Theoretically we could crash due to a del_timer() on other cpu
seeing garbage data.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
Not seen in practice, however i think this race
is real. Defer to nf-next if you think its not urgent.
diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c
index e03d16ed550d..c034951597fe 100644
--- a/net/netfilter/nf_conntrack_expect.c
+++ b/net/netfilter/nf_conntrack_expect.c
@@ -368,12 +368,6 @@ static void nf_ct_expect_insert(struct nf_conntrack_expect *exp)
/* two references : one for hash insert, one for the timer */
refcount_add(2, &exp->use);
- hlist_add_head_rcu(&exp->lnode, &master_help->expectations);
- master_help->expecting[exp->class]++;
-
- hlist_add_head_rcu(&exp->hnode, &nf_ct_expect_hash[h]);
- net->ct.expect_count++;
-
setup_timer(&exp->timeout, nf_ct_expectation_timed_out,
(unsigned long)exp);
helper = rcu_dereference_protected(master_help->helper,
@@ -384,6 +378,12 @@ static void nf_ct_expect_insert(struct nf_conntrack_expect *exp)
}
add_timer(&exp->timeout);
+ hlist_add_head_rcu(&exp->lnode, &master_help->expectations);
+ master_help->expecting[exp->class]++;
+
+ hlist_add_head_rcu(&exp->hnode, &nf_ct_expect_hash[h]);
+ net->ct.expect_count++;
+
NF_CT_STAT_INC(net, expect_create);
}
--
2.13.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH nf] netfilter: expect: add to hash table after expect init
2017-07-10 13:06 [PATCH nf] netfilter: expect: add to hash table after expect init Florian Westphal
@ 2017-07-24 10:20 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2017-07-24 10:20 UTC (permalink / raw)
To: Florian Westphal; +Cc: netfilter-devel
On Mon, Jul 10, 2017 at 03:06:39PM +0200, Florian Westphal wrote:
> assuming we have lockless readers we should make sure they can only
> see expectations that have already been initialized.
>
> hlist_add_head_rcu acts as memory barrier, move it after timer setup.
>
> Theoretically we could crash due to a del_timer() on other cpu
> seeing garbage data.
>
> Signed-off-by: Florian Westphal <fw@strlen.de>
> ---
> Not seen in practice, however i think this race
> is real. Defer to nf-next if you think its not urgent.
Applied to nf-next, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-07-24 10:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-10 13:06 [PATCH nf] netfilter: expect: add to hash table after expect init Florian Westphal
2017-07-24 10:20 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).