[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <58F87B18.7000008@iogearbox.net>
Date: Thu, 20 Apr 2017 11:10:48 +0200
From: Daniel Borkmann <daniel@...earbox.net>
To: Cong Wang <xiyou.wangcong@...il.com>, netdev@...r.kernel.org
CC: Roi Dayan <roid@...lanox.com>,
John Fastabend <john.fastabend@...il.com>,
Jamal Hadi Salim <jhs@...atatu.com>
Subject: Re: [Patch net-next v4 1/2] net_sched: move the empty tp check from
->destroy() to ->delete()
On 04/19/2017 11:21 PM, Cong Wang wrote:
> We could have a race condition where in ->classify() path we
> dereference tp->root and meanwhile a parallel ->destroy() makes it
> a NULL. Daniel cured this bug in commit d936377414fa
> ("net, sched: respect rcu grace period on cls destruction").
>
> This happens when ->destroy() is called for deleting a filter to
> check if we are the last one in tp, this tp is still linked and
> visible at that time. The root cause of this problem is the semantic
> of ->destroy(), it does two things (for non-force case):
>
> 1) check if tp is empty
> 2) if tp is empty we could really destroy it
>
> and its caller, if cares, needs to check its return value to see if it
> is really destroyed. Therefore we can't unlink tp unless we know it is
> empty.
>
> As suggested by Daniel, we could actually move the test logic to ->delete()
> so that we can safely unlink tp after ->delete() tells us the last one is
> just deleted and before ->destroy().
>
> Fixes: 1e052be69d04 ("net_sched: destroy proto tp when all filters are gone")
> Cc: Roi Dayan <roid@...lanox.com>
> Cc: Daniel Borkmann <daniel@...earbox.net>
> Cc: John Fastabend <john.fastabend@...il.com>
> Cc: Jamal Hadi Salim <jhs@...atatu.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@...il.com>
Acked-by: Daniel Borkmann <daniel@...earbox.net>
Thanks!
Powered by blists - more mailing lists