From: Tejun Heo <tj@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Kazuki Yamaguchi <k@rhe.jp>,
Niklas Cassel <niklas.cassel@axis.com>,
linux-kernel@vger.kernel.org
Subject: Re: [BUG] sched: leaf_cfs_rq_list use after free
Date: Wed, 16 Mar 2016 09:50:06 -0700 [thread overview]
Message-ID: <20160316165006.GL6980@mtj.duckdns.org> (raw)
In-Reply-To: <20160316152245.GY6344@twins.programming.kicks-ass.net>
Hello, Peter.
On Wed, Mar 16, 2016 at 04:22:45PM +0100, Peter Zijlstra wrote:
> > css_online()
> >
> > The css is now guaranteed to be visible for css_for_each*()
> > iterations. This distinction exists because some controllers
> > need to propagate state changes downwards requiring a new css
> > to become visible before it inherits the current state from
> > the parent. Conversely, there's no reason to use this
> > callback if there's no such requirement.
> >
> > Ex: Freezer which propagates the target state downwards and
> > needs a new child to inherit the current state while
> > iteratable.
>
> So it looks like sched uses css_online() for no particular reason
> either, I've moved all that into css_alloc().
The parings are alloc <-> free, and online <-> offline,released, so if
you do some part of shutdown in either offline or released, it
probably makes sense to the counterpart of init in online.
> None of that speaks of where Zombies live, am I to infer that Zombies
> pass css_offline() but stall css_released() ?
Yeap, zombies may remain attached to the css before css_released().
> I don't particularly care about iterating css bits, but I do need my
> parent group to still exist, this is now also guaranteed for
> css_release(), right? The above documentation also doesn't mention this;
Yeah, if you do your custom rcu protected data structures which needs
to be accessible after offline, the rules would be the same as
requiring css iteration in the same way, so css_released() would be
the right callback to use.
> in particular I require that css_release() for any group is not called
> before the css_release() of any child group.
That is guaranteed now.
> static void cpu_cgroup_css_free(struct cgroup_subsys_state *css)
> {
> struct task_group *tg = css_tg(css);
>
> - sched_destroy_group(tg);
> -}
> -
> -static void cpu_cgroup_css_offline(struct cgroup_subsys_state *css)
> -{
> - struct task_group *tg = css_tg(css);
> -
> - sched_offline_group(tg);
> + /*
> + * Relies on the RCU grace period between css_released() and this.
> + */
> + sched_free_group(tg);
> }
Hmmm... I don't think it'd be safe to merge the two ops. Nothing
guarantees that the RCU callback of cpu controller is called after the
cgroup core one and cgroup core one would do use-after-free. Just
changing offline to released should do.
Thanks.
--
tejun
next prev parent reply other threads:[~2016-03-16 16:50 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-12 9:42 Kazuki Yamaguchi
2016-03-12 13:59 ` Peter Zijlstra
2016-03-14 11:20 ` Peter Zijlstra
2016-03-14 12:09 ` Peter Zijlstra
2016-03-16 14:24 ` Tejun Heo
2016-03-16 14:44 ` Tejun Heo
2016-03-16 15:22 ` Peter Zijlstra
2016-03-16 16:50 ` Tejun Heo [this message]
2016-03-16 17:04 ` Peter Zijlstra
2016-03-16 17:49 ` Tejun Heo
2016-03-17 8:29 ` Niklas Cassel
2016-03-21 11:15 ` [tip:sched/urgent] sched/cgroup: Fix/cleanup cgroup teardown/init tip-bot for Peter Zijlstra
2016-04-28 18:40 ` Peter Zijlstra
2016-04-28 18:51 ` Greg Kroah-Hartman
2016-04-28 21:36 ` Peter Zijlstra
2016-05-02 3:06 ` Greg Kroah-Hartman
-- strict thread matches above, loose matches on Subject: below --
2016-03-04 10:41 [BUG] sched: leaf_cfs_rq_list use after free Niklas Cassel
2016-03-10 12:54 ` Peter Zijlstra
2016-03-11 17:02 ` Niklas Cassel
2016-03-11 17:28 ` Peter Zijlstra
2016-03-11 18:20 ` Tejun Heo
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=20160316165006.GL6980@mtj.duckdns.org \
--to=tj@kernel.org \
--cc=k@rhe.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=niklas.cassel@axis.com \
--cc=peterz@infradead.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
Powered by JetHome