Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp232742pxb; Thu, 2 Sep 2021 02:59:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzIO4hnuC5XNj9SltkWifl5ilf0eYt7bsikG4ePlxZGYN+Pe22N5/ps5Is9BOj631q3ewSJ X-Received: by 2002:a05:6602:3404:: with SMTP id n4mr2050097ioz.45.1630576772464; Thu, 02 Sep 2021 02:59:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630576772; cv=none; d=google.com; s=arc-20160816; b=R+P8bgBCOCB2450qJXp5K7u6wJMqUy8Lq0eOrODxmYu6KoHWFkgOiQcW5+mxsjg8R/ 9eAaNkDCm5sUVMh7JjP83m3wjATlNuZxS2cGfIiOzISwz6QecV+WtWEktGJhnIFiMyoj kF8JbLL2AUr69UIsdRvOWUh4zl84bRoi1qr4lP1g/1u7vfoQP94S/pRA+uYx57BEgM9f NVnmxO87yN3h6zI1RQwET6NF0F6zqjgOcfLus4gp4uqVfCna5Rzsm94AqWu9YFICrZ/l iYDm1QTbquDjcAEGhr8FTPdqns+uzP1kSp/IK+VoYZJQOEnuMmeAMkp3y0kVftqHzgxY fQAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=5SkgcpyiJ6YjvlkKxIpBDAtLkd2DWf6DKGEPKQb/cM4=; b=DBlVXNr16WArIrdMzkwpAqhSnnr1NSvN8yNOziyAPRsn9Zq66KauegE/j7EOu2SFwb 1FAWsoWXSwFANEBfTkcdJI+UAmlfqhrGQbvyWsFHv1sMThxKPNBiBoyPxiCCu1gPCc1n D9On3xMS2DVzbbw7xrQ8daRE4Fmtb1om7//B+W860gPwIGXukFZbIrscRnw0mlx/4u1D fm6EpT/lr/U2EU5P+Ni1mPNF0s7YZnQGq6PI0c1nvsxeRcWyZ2uxUYiW8SNR26f3mCwU kWNdG0oDcqHvcOPm1iEDrZbMzKRgB5r8QMc3HVqfW4aZdKYSWhYevNhYid4yMBan63Zq MJLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q23si1542944jav.89.2021.09.02.02.59.21; Thu, 02 Sep 2021 02:59:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233589AbhIBHnY (ORCPT + 99 others); Thu, 2 Sep 2021 03:43:24 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:9394 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233360AbhIBHnX (ORCPT ); Thu, 2 Sep 2021 03:43:23 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4H0XpS0G41z8xfg; Thu, 2 Sep 2021 15:38:08 +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; Thu, 2 Sep 2021 15:42:15 +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; Thu, 2 Sep 2021 15:42:15 +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> <128d52ab-b4ee-65f8-e0a3-2796ef43a98b@huawei.com> From: Zhang Qiao Message-ID: <3df62791-d123-db9b-ec9c-092c47a941cc@huawei.com> Date: Thu, 2 Sep 2021 15:42:15 +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="utf-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.101.251] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) 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 在 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. >