From: Ido Schimmel <idosch@idosch.org>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org, jiri@resnulli.us, jhs@mojatatu.com,
vladbu@mellanox.com, Jiri Pirko <jiri@mellanox.com>
Subject: Re: [Patch net-next] net_sched: convert idrinfo->lock from spinlock to a mutex
Date: Wed, 3 Oct 2018 08:31:12 +0300 [thread overview]
Message-ID: <20181003053112.GA15357@splinter> (raw)
In-Reply-To: <20181002195019.13522-1-xiyou.wangcong@gmail.com>
On Tue, Oct 02, 2018 at 12:50:19PM -0700, Cong Wang wrote:
> In commit ec3ed293e766 ("net_sched: change tcf_del_walker() to take idrinfo->lock")
> we move fl_hw_destroy_tmplt() to a workqueue to avoid blocking
> with the spinlock held. Unfortunately, this causes a lot of
> troubles here:
>
> 1. tcf_chain_destroy() could be called right after we queue the work
> but before the work runs. This is a use-after-free.
>
> 2. The chain refcnt is already 0, we can't even just hold it again.
> We can check refcnt==1 but it is ugly.
>
> 3. The chain with refcnt 0 is still visible in its block, which means
> it could be still found and used!
>
> 4. The block has a refcnt too, we can't hold it without introducing a
> proper API either.
>
> We can make it working but the end result is ugly. Instead of wasting
> time on reviewing it, let's just convert the troubling spinlock to
> a mutex, which allows us to use non-atomic allocations too.
>
> Fixes: ec3ed293e766 ("net_sched: change tcf_del_walker() to take idrinfo->lock")
> Reported-by: Ido Schimmel <idosch@idosch.org>
> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> Cc: Vlad Buslov <vladbu@mellanox.com>
> Cc: Jiri Pirko <jiri@mellanox.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Tested-by: Ido Schimmel <idosch@mellanox.com>
Thanks a lot!
next prev parent reply other threads:[~2018-10-03 12:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-02 19:50 [Patch net-next] net_sched: convert idrinfo->lock from spinlock to a mutex Cong Wang
2018-10-03 5:31 ` Ido Schimmel [this message]
2018-10-05 7:38 ` 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=20181003053112.GA15357@splinter \
--to=idosch@idosch.org \
--cc=jhs@mojatatu.com \
--cc=jiri@mellanox.com \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
--cc=vladbu@mellanox.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).