From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20D2AC432BE for ; Wed, 1 Sep 2021 07:43:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 09FA961056 for ; Wed, 1 Sep 2021 07:43:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242879AbhIAHoI (ORCPT ); Wed, 1 Sep 2021 03:44:08 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:18998 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242845AbhIAHn7 (ORCPT ); Wed, 1 Sep 2021 03:43:59 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Gzwt15BSvzbl6q; Wed, 1 Sep 2021 15:39:05 +0800 (CST) Received: from dggpeml500018.china.huawei.com (7.185.36.186) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 1 Sep 2021 15:43:01 +0800 Received: from [10.67.101.251] (10.67.101.251) by dggpeml500018.china.huawei.com (7.185.36.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 1 Sep 2021 15:43:00 +0800 Subject: Re: [PATCH] kernel/sched: Fix sched_fork() access an invalid sched_task_group To: Tejun Heo CC: , , , , References: <20210826112635.7404-1-zhangqiao22@huawei.com> <1f0cd867-9c6d-4e22-cadd-06af9f852f7a@huawei.com> From: Zhang Qiao Message-ID: <128d52ab-b4ee-65f8-e0a3-2796ef43a98b@huawei.com> Date: Wed, 1 Sep 2021 15:43:00 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.101.251] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500018.china.huawei.com (7.185.36.186) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hello,tejun. ÔÚ 2021/9/1 6:59, Tejun Heo дµÀ: > Hello, > > 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()? >>> 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(). > > 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? thanks. -- Qiao Zhang. > > Thanks. >