* [PATCH nf 1/1] netfilter: cttimeout: Fix one possible use-after-free issue
@ 2017-04-06 11:09 gfree.wind
2017-04-13 21:47 ` Pablo Neira Ayuso
0 siblings, 1 reply; 4+ messages in thread
From: gfree.wind @ 2017-04-06 11:09 UTC (permalink / raw)
To: pablo, netfilter-devel; +Cc: Gao Feng
From: Gao Feng <fgao@ikuai8.com>
The function ctnl_untimeout is used to untimeout every conntrack
which is using the timeout. But it is necessary to add one barrier
synchronize_rcu because of racing. Maybe one conntrack has already
owned this timeout, but it is not inserted into unconfirmed list or
the hash list, when ctnl_untimeout untimeout the conntracks
Signed-off-by: Gao Feng <fgao@ikuai8.com>
---
net/netfilter/nfnetlink_cttimeout.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c
index 47d6656..af0cc87 100644
--- a/net/netfilter/nfnetlink_cttimeout.c
+++ b/net/netfilter/nfnetlink_cttimeout.c
@@ -304,6 +304,11 @@ static void ctnl_untimeout(struct net *net, struct ctnl_timeout *timeout)
spinlock_t *lock;
int i, cpu;
+ /* Make sure the conntrack using the timeout already in the unconfirmed
+ * list or in the hash table.
+ */
+ synchronize_rcu();
+
for_each_possible_cpu(cpu) {
struct ct_pcpu *pcpu = per_cpu_ptr(net->ct.pcpu_lists, cpu);
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH nf 1/1] netfilter: cttimeout: Fix one possible use-after-free issue
2017-04-06 11:09 [PATCH nf 1/1] netfilter: cttimeout: Fix one possible use-after-free issue gfree.wind
@ 2017-04-13 21:47 ` Pablo Neira Ayuso
2017-04-13 22:35 ` Gao Feng
0 siblings, 1 reply; 4+ messages in thread
From: Pablo Neira Ayuso @ 2017-04-13 21:47 UTC (permalink / raw)
To: gfree.wind; +Cc: netfilter-devel, Gao Feng
On Thu, Apr 06, 2017 at 07:09:09PM +0800, gfree.wind@foxmail.com wrote:
> From: Gao Feng <fgao@ikuai8.com>
>
> The function ctnl_untimeout is used to untimeout every conntrack
> which is using the timeout. But it is necessary to add one barrier
> synchronize_rcu because of racing. Maybe one conntrack has already
> owned this timeout, but it is not inserted into unconfirmed list or
> the hash list, when ctnl_untimeout untimeout the conntracks
This object is released via kfree_rcu().
You have to describe better the race scenario.
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH nf 1/1] netfilter: cttimeout: Fix one possible use-after-free issue
2017-04-13 21:47 ` Pablo Neira Ayuso
@ 2017-04-13 22:35 ` Gao Feng
2017-04-13 22:44 ` Pablo Neira Ayuso
0 siblings, 1 reply; 4+ messages in thread
From: Gao Feng @ 2017-04-13 22:35 UTC (permalink / raw)
To: 'Pablo Neira Ayuso', gfree.wind; +Cc: netfilter-devel
> -----Original Message-----
> From: Pablo Neira Ayuso [mailto:pablo@netfilter.org]
> On Thu, Apr 06, 2017 at 07:09:09PM +0800, gfree.wind@foxmail.com wrote:
> >
> > The function ctnl_untimeout is used to untimeout every conntrack which
> > is using the timeout. But it is necessary to add one barrier
> > synchronize_rcu because of racing. Maybe one conntrack has already
> > owned this timeout, but it is not inserted into unconfirmed list or
> > the hash list, when ctnl_untimeout untimeout the conntracks
>
> This object is released via kfree_rcu().
>
> You have to describe better the race scenario.
Let me describe it with a call path
CPU1 CPU2
alloc new conn
add timeout ext
ctnl_timeout_try_del
untimeout all conns in list
kfree_rcu.
conn is confirmed.
As the show above, when cpu2 untimeout all conns in list, the new conn of
cpu1
is not confirmed. The new conn still owns the timeout pointer. After the
timeout
mem is freed really, it points to one invalid mem.
Regards
Feng
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH nf 1/1] netfilter: cttimeout: Fix one possible use-after-free issue
2017-04-13 22:35 ` Gao Feng
@ 2017-04-13 22:44 ` Pablo Neira Ayuso
0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2017-04-13 22:44 UTC (permalink / raw)
To: Gao Feng; +Cc: netfilter-devel
On Fri, Apr 14, 2017 at 06:35:13AM +0800, Gao Feng wrote:
> > -----Original Message-----
> > From: Pablo Neira Ayuso [mailto:pablo@netfilter.org]
> > On Thu, Apr 06, 2017 at 07:09:09PM +0800, gfree.wind@foxmail.com wrote:
> > >
> > > The function ctnl_untimeout is used to untimeout every conntrack which
> > > is using the timeout. But it is necessary to add one barrier
> > > synchronize_rcu because of racing. Maybe one conntrack has already
> > > owned this timeout, but it is not inserted into unconfirmed list or
> > > the hash list, when ctnl_untimeout untimeout the conntracks
> >
> > This object is released via kfree_rcu().
> >
> > You have to describe better the race scenario.
>
> Let me describe it with a call path
> CPU1 CPU2
> alloc new conn
> add timeout ext
>
> ctnl_timeout_try_del
> untimeout all conns in list
>
> kfree_rcu.
> conn is confirmed.
>
> As the show above, when cpu2 untimeout all conns in list, the new conn of
> cpu1
> is not confirmed. The new conn still owns the timeout pointer. After the
> timeout
> mem is freed really, it points to one invalid mem.
You add this to your patch description and resubmit.
Please, send me one patch or two maximum at a time. Until I don't
apply one, you don't send me a new one.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-04-13 22:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-06 11:09 [PATCH nf 1/1] netfilter: cttimeout: Fix one possible use-after-free issue gfree.wind
2017-04-13 21:47 ` Pablo Neira Ayuso
2017-04-13 22:35 ` Gao Feng
2017-04-13 22:44 ` 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).