lkml.org 
[lkml]   [2021]   [Aug]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] kernel/sched: Fix sched_fork() access an invalid sched_task_group
Hello,

On Mon, Aug 30, 2021 at 04:39:54PM +0200, Peter Zijlstra wrote:
> > When a new process is forked, cgroup_post_fork() associates it
> > with the cgroup of its parent. Therefore this commit move the
> > __set_task_cpu() and task_fork() that access some cgroup-related
> > fields(sched_task_group and cfs_rq) to sched_post_fork() and
> > call sched_post_fork() after cgroup_post_fork().

I think this would allow cgroup migrations to take place before
sched_post_fork() is run, which likely will break stuff. The right
thing to do likely is taking sched_task_group (and whatever other
fields) after cgroup_can_fork(), which fixates the cgroup memberships,
is run. For other controllers, operations like this would be performed
from cgroup_subsys->fork() callback but it's tricky for sched due to
autogroup.

> > Fixes: 8323f26ce342 ("sched: Fix race in task_group")
> > Signed-off-by: Zhang Qiao <zhangqiao22@huawei.com>
>
> Hmm, I think you're right. Did something recently chagne in cgroup land
> to make this more visible? This code hasn't changed in like 9 years.

I can't think of any remotely recent change either. I guess ppl just
don't try to migrate the parent while fork is in progress.

Thanks.

--
tejun

\
 
 \ /
  Last update: 2021-08-30 19:32    [W:0.131 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site