Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp384856pxb; Wed, 1 Sep 2021 00:46:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl/yH2Ul2NlPlq2FfgNsWBo+FJN6iH2QqWFNHA0Km0P2vGIHrxjQAZ7I1BR+4UHlCfxuGk X-Received: by 2002:a17:906:a08a:: with SMTP id q10mr33907761ejy.100.1630482367692; Wed, 01 Sep 2021 00:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630482367; cv=none; d=google.com; s=arc-20160816; b=odVt0dxWzjt4z6WByI8qOx1jKPw3E4p/XG5F0eSElmwUTzPjDyDuifrnlP7nGj9oet en9a379UeyENjpntv/NidRZoZyU6aWGKdWx2DNaU9OxoZki4v6/ak8mvEWShBQHrqI5O mXdD0yY+6eb9T8c8gXsyHjC0nryTToVudO4KJ1QEfg0g7/+k+z0BVKt7dJu4DVk0nW5V o3Jgvr3uNPfg3tNZ8gQzw/m1lf/oaDTJR1xfI9erW+B21TdaxVhSWkYONKoZmoLHYMSd YAHZTCaG6pDJrJJd8f3CWM80NEOTyRMlxwnOeC3nzartZhc6emtxl47dQeQa7NTvj0DP 32rA== 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=YTBdXQPslVJwKVTQb6Po6gMLpVszEWieeRiqpl5MyfA=; b=H2CCkVWDE2W9EO0ZgEZQGx69mrvwsYKW0rs0j0xwFzWccRYNYVkoAUOW4+auRIs9JH wI4gBQWug1vjGIyASIsbU5HJBm2n7nKY0Bc4mvkIylOuHeAa+p0USOJGOQf6iuo3z/1I mdkJ+O392B66DWDk+a8JnE8pM9udNhehuS+HPq4GyjQVaZaijfHWUmEuzrrwXhJotoQa VPScCLEldf0n+4w0A5GVtB752YJVIHEgVsoI54U65KMcV174tHC2LpK1Jh8/SjhKWwBC dyGjTrk2mJi2j1qvLaZ2tzNSLSh1MAN0MPariaK82v+nck4hqHO3Ia4yumpsgAJRHjpk Zr7w== 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 gb36si4887202ejc.675.2021.09.01.00.45.30; Wed, 01 Sep 2021 00:46:07 -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 S242839AbhIAHoC (ORCPT + 99 others); Wed, 1 Sep 2021 03:44:02 -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. >