Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp466179pxb; Tue, 14 Sep 2021 01:23:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDuMiXRoZhidWpis5gWB694STkE9L7itjkdxjVPVOqV66vMRcfYAiRDp8U8NAaCo6V5cmB X-Received: by 2002:aa7:ca0a:: with SMTP id y10mr14653164eds.329.1631607835576; Tue, 14 Sep 2021 01:23:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631607835; cv=none; d=google.com; s=arc-20160816; b=y77sbXARiVJDbT08+KD0u/s1h++vAUckcpFuiduswHtwL+XAxYft06X65JUAwcUwio hpZga7jPTSZuEow6IavmsWcD4DZPNduIGeD7tKcIeDJapl6AnNSjczzvZvrNNu1s3Io9 /OwvIfwRjg22XJ36vKCGnGhGEVKH3pgaQujonSaFFVfPkPhhdaZz1B44IdmoPST0gsVf BXaUXChbm1O3lxwThG2Et/lhzUWJXi0giM1v9IU0yvF2+uxIlaq0riwH66OjSn1qPnvD 0wx/g1EzPtMkCi/KEz7fO8XaYrC9kaUg7gqrPgYq83T5H0Jf1oTXjWnU9tE503Wp39wT K4ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:date:message-id:in-reply-to:from:references:cc:to :subject; bh=r6x8nWUfCQh29rmuWs5CO6KEHYzaSjEz4l6s7BrUmOE=; b=PFVNahUdI2TFXSg/eylOlyNdDqQVDHZYm2MwDWdz0BzXOwg0nlNBjfJy6Tb1GszGz6 BBtRu2HE2P6ZP8llqYjI1M0ZxdBJpQFG0uTM63+89djfCyk0lZOvCiMXREkn8N+/62M6 +E8cJtRRPSdZwdQvLWSBOXwRS+G9/NjiEr7AJdTVSP5oyZYxsZLamL+GtloNqS+AHYVZ fRv3ArAe7KOClKyXvn/4urE7even2Q2QDUgBaO9bJLzQ/VHlWsnupj4qNepKwQ6w7wRT gpjvUt7MCMkXwFqCgPnTs5D3iHQevOTwhaOywctKN20mXEeht4OVkbsv4foBnfOiZ/5m GwCg== 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 q23si9860469ejj.178.2021.09.14.01.23.30; Tue, 14 Sep 2021 01:23:55 -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 S230071AbhINIVZ (ORCPT + 99 others); Tue, 14 Sep 2021 04:21:25 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:16252 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229699AbhINIVY (ORCPT ); Tue, 14 Sep 2021 04:21:24 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4H7x8d073Lz8t7f; Tue, 14 Sep 2021 16:19:29 +0800 (CST) Received: from dggpeml500018.china.huawei.com (7.185.36.186) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Tue, 14 Sep 2021 16:20:04 +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.2308.8; Tue, 14 Sep 2021 16:20:03 +0800 Subject: Re: [PATCH v2] kernel/sched: Fix sched_fork() access an invalid sched_task_group To: Tejun Heo CC: , , , , , , , , , References: <20210911075054.6358-1-zhangqiao22@huawei.com> From: Zhang Qiao In-Reply-To: Message-ID: Date: Tue, 14 Sep 2021 16:20:02 +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 Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.101.251] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) 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/14 2:01, Tejun Heo ะด??: > Hello, > > On Sat, Sep 11, 2021 at 03:50:54PM +0800, Zhang Qiao wrote: >> Between cgroup_can_fork() and cgroup_post_fork(), the cgroup >> membership is fixed and thus sched_task_group can't change. So >> call sched_fork() after cgroup_can_fork() and update the child's >> sched_task_group before it is used. > > The part being fixed looks correct to me but it's difficult to for me to > assess whether the whole relocation of the sched_fork() hook doesn't change Indeed is this, although I checked and tested it many times. > anything else. Besides, even if we decide to relocate the sched_fork hook, I > think it'd be better to separate the two changes - one is a relatively safe > bug fix, the other is a code reorganization with possibly subtle side > effects. So, I think it'd be better to produce a patch which just fixes the > bug even if that ends up introducing another function in the flow. Perhaps we can fix this bug at sched_post_fork(), which is executed between cgroup_can_fork() and cgroup_post_fork(). Relocate the fectching of task_group and access it at sched_post_fork(). thanks. > > Thanks. >