From: Daniel Borkmann <daniel@iogearbox•net>
To: Cong Wang <xiyou.wangcong@gmail•com>, netdev@vger•kernel.org
Cc: Roi Dayan <roid@mellanox•com>,
John Fastabend <john.fastabend@gmail•com>,
Jamal Hadi Salim <jhs@mojatatu•com>
Subject: Re: [Patch net-next v4 1/2] net_sched: move the empty tp check from ->destroy() to ->delete()
Date: Thu, 20 Apr 2017 11:10:48 +0200 [thread overview]
Message-ID: <58F87B18.7000008@iogearbox.net> (raw)
In-Reply-To: <1492636882-19571-2-git-send-email-xiyou.wangcong@gmail.com>
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@mellanox•com>
> Cc: Daniel Borkmann <daniel@iogearbox•net>
> Cc: John Fastabend <john.fastabend@gmail•com>
> Cc: Jamal Hadi Salim <jhs@mojatatu•com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail•com>
Acked-by: Daniel Borkmann <daniel@iogearbox•net>
Thanks!
next prev parent reply other threads:[~2017-04-20 9:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-19 21:21 [Patch net-next v4 0/2] net_sched: clean up tc filter destroy and delete logic Cong Wang
2017-04-19 21:21 ` [Patch net-next v4 1/2] net_sched: move the empty tp check from ->destroy() to ->delete() Cong Wang
2017-04-20 9:10 ` Daniel Borkmann [this message]
2017-04-19 21:21 ` [Patch net-next v4 2/2] net_sched: remove useless NULL to tp->root Cong Wang
2017-04-21 17:59 ` [Patch net-next v4 0/2] net_sched: clean up tc filter destroy and delete logic David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58F87B18.7000008@iogearbox.net \
--to=daniel@iogearbox$(echo .)net \
--cc=jhs@mojatatu$(echo .)com \
--cc=john.fastabend@gmail$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=roid@mellanox$(echo .)com \
--cc=xiyou.wangcong@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox