linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhang Qiao <zhangqiao22@huawei.com>
To: Tejun Heo <tj@kernel.org>
Cc: <peterz@infradead.org>, <juri.lelli@redhat.com>,
	<linux-kernel@vger.kernel.org>, <mingo@redhat.com>,
	<vincent.guittot@linaro.org>
Subject: Re: [PATCH] kernel/sched: Fix sched_fork() access an invalid sched_task_group
Date: Thu, 2 Sep 2021 15:42:15 +0800	[thread overview]
Message-ID: <3df62791-d123-db9b-ec9c-092c47a941cc@huawei.com> (raw)
In-Reply-To: <YS+uEmQRmQqAbkmG@slm.duckdns.org>



在 2021/9/2 0:45, Tejun Heo 写道:
> Hello,
> 
> On Wed, Sep 01, 2021 at 03:43:00PM +0800, Zhang Qiao wrote:
>> 在 2021/9/1 6:59, Tejun Heo 写道:
>>> On Tue, Aug 31, 2021 at 03:58:42PM +0800, Zhang Qiao wrote:
>>>>> I think this would allow cgroup migrations to take place before
>>>>> sched_post_fork() is run, which likely will break stuff. The right
>>
>> cgroup migrations? Do you mean child process set its cgroups at
>> cgroup_subsys->fork()?
> 
> As soon as cgroup_post_fork() is complete, userspace can try moving the
> process to a different cgroup which can get confusing for sched_post_fork.

hello,tejun

I checked the code again.
I don't quite understand what you said, if the child be moved between
cgroup_post_fork() and sched_post_sched(), what problems might it cause?
Does the child process will use the old sched_task_group at sched_post_fork()-->__set_task_cpu()?
Or there are other problems, Can you talk in more detail?

thanks!

---
Qiao Zhang
> 
>>> Between cgroup_can_fork() and cgroup_post_fork(), the cgroup membership and
>>> thus sched_task_group can't change, so if the child sets it to the parent's
>>> inbetween, the sched_task_group can't go away.
>>
>> so the child just need to update its sched_task_group after cgroup_can_fork(),
>> then call sched_fork(), is it right?
> 
> Yeah, the bug here is that a field which is dependent on cgroup membership
> is being read before the cgroup membership is fixated.
> 
> Thanks.
> 

  reply	other threads:[~2021-09-02  7:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-26 11:26 [PATCH] kernel/sched: Fix sched_fork() access an invalid sched_task_group Zhang Qiao
2021-08-30 11:49 ` Zhang Qiao
2021-08-30 14:39 ` Peter Zijlstra
2021-08-30 17:32   ` Tejun Heo
2021-08-31  7:58     ` Zhang Qiao
2021-08-31 22:59       ` Tejun Heo
2021-09-01  7:43         ` Zhang Qiao
2021-09-01 16:45           ` Tejun Heo
2021-09-02  7:42             ` Zhang Qiao [this message]
2021-09-07 17:01               ` Tejun Heo
2021-09-08 11:32                 ` Zhang Qiao
2021-09-08 16:29                   ` Tejun Heo
2021-09-09  9:45                     ` Zhang Qiao

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=3df62791-d123-db9b-ec9c-092c47a941cc@huawei.com \
    --to=zhangqiao22@huawei.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.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).