From: Cong Wang <xiyou.wangcong@gmail.com>
To: Alexander Aring <aring@mojatatu.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
Jiri Pirko <jiri@resnulli.us>,
Linux Kernel Network Developers <netdev@vger.kernel.org>,
kurup.manish@gmail.com, Brenda Butler <bjb@mojatatu.com>
Subject: Re: [RFC net 1/1] net: sched: act: fix rcu race in dump
Date: Tue, 10 Oct 2017 09:40:12 -0700 [thread overview]
Message-ID: <CAM_iQpVVqFUpeYc-b4bzc2=L-O7h0z3bbSLOaAoQ17h1jcrdCw@mail.gmail.com> (raw)
In-Reply-To: <20171010123218.5251-2-aring@mojatatu.com>
On Tue, Oct 10, 2017 at 5:32 AM, Alexander Aring <aring@mojatatu.com> wrote:
> This patch fixes an issue with kfree_rcu which is not protected by RTNL
> lock. It could be that the current assigned rcu pointer will be freed by
> kfree_rcu while dump callback is running.
Why? kfree_rcu() respects existing readers, so why this could happen?
>
> To prevent this, we call rcu_synchronize at first. Then we are sure all
> latest rcu functions e.g. rcu_assign_pointer and kfree_rcu in init are
> done. After rcu_synchronize we dereference under RTNL lock which is also
> held in init function, which means no other rcu_assign_pointer or
> kfree_rcu will occur.
If you really want to wait for kfree_rcu(), rcu_barrier() is the one
instead of rcu_synchronize(). Just FYI.
>
> To call rcu_synchronize will also prevent weird behaviours by doing over
> netlink:
>
> - set params A
> - set params B
> - dump params
> \--> will dump params A
What's wrong with this? Existing readers could still read old data,
which is _perfectly_ fine as long as we don't free the old data before
they are gone.
prev parent reply other threads:[~2017-10-10 16:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-10 12:32 [RFC net 0/1] net: sched: act: fix rcu race Alexander Aring
2017-10-10 12:32 ` [RFC net 1/1] net: sched: act: fix rcu race in dump Alexander Aring
2017-10-10 12:39 ` Alexander Aring
2017-10-10 14:12 ` Eric Dumazet
2017-10-10 18:09 ` Alexander Aring
2017-10-10 16:40 ` Cong Wang [this message]
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='CAM_iQpVVqFUpeYc-b4bzc2=L-O7h0z3bbSLOaAoQ17h1jcrdCw@mail.gmail.com' \
--to=xiyou.wangcong@gmail.com \
--cc=aring@mojatatu.com \
--cc=bjb@mojatatu.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kurup.manish@gmail.com \
--cc=netdev@vger.kernel.org \
/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).