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

hi, thanks for your reviews.

On 2021/8/31 1:32, Tejun Heo wrote:
> 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,
But it still seems possible that it accessed an invalid sched_task_group?
because the child process does not update its sched_task_group util
cgroup_post_fork().
> 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 think this problem has always existed. I've reproduced it in multiple versions,
including 3.10 and 5.14-rc3.

>
> 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.
>

thandks.

\
 
 \ /
  Last update: 2021-08-31 10:01    [W:0.207 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site