Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp3208552ybe; Sun, 15 Sep 2019 09:56:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGO40+Fsk9+aFyUdH+vT90VCZ/FvUbbxN8wYb9tJNm6mJwjkKYV0kebVLWuw5DXvON15U1 X-Received: by 2002:aa7:c415:: with SMTP id j21mr50570685edq.282.1568566605028; Sun, 15 Sep 2019 09:56:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568566605; cv=none; d=google.com; s=arc-20160816; b=VS1/WmJjvn4Yr9H/1N/fz1P7sTuM5M03YL6X3wXv6h6hhnoGot/i2FDQ59/m/6EYyH W53ciB93Fvixb1bDQnTLnbe8bBimimRQkW7HXekzr2sVYkvU44oxIbFm9/Ghwmri9t57 eNGCedDdLHBgxA40dZgyT0l11MGzGv/2bR2IcW4leGo11XhL1jvl6Js9jF0yAmOk0atg Vm8vWftrte4LwY8RHYdukF7RO0JZUcrOcfbPdaFzDL4CrJIUAcFlw5+MynvJTnu0uA2v fxYvZf7GysyAJp8XlLhJxAEcke5sqVaF8i3VGonOlEykgeB/Jg8izr2/iHnRhgxGuN09 6PAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=j/vnl91MVg0MglT70GhVh6XadaNS5GZ0MlTJGCoN6+0=; b=qkWwoWL9oqgyly9yTRkvTZSmOS4hohRmT3hiHuqmfYJ0mpQbf7b9ZLgjnzjqpBfluj 34Flgddy/t8vvXfEcWzBVsw5ZdVSto7OLo7+Iq8erGeTKCG9OSAG0WwipsLS3VdY3p4K fiQuEZYWZ1VUCloB9bZTVRhlBv/bcA3HBOA04PJ/oeAVgX5LZcwsil10y+a6RTOf8Os4 pQgJNArzSoABjXemfToy3P5vr2LgD/6UtCKB3PziJo/1INwcQP5zaavr1Gx+fEKJbj5t ds71fOCxfP2edu0i2dPCbqtLvwgb2vvkVrccS37RELuDbYOr3V0ZnOerd5zMr0TMPS32 BAQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b23si18103639eja.297.2019.09.15.09.56.21; Sun, 15 Sep 2019 09:56:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731723AbfIOOdl (ORCPT + 99 others); Sun, 15 Sep 2019 10:33:41 -0400 Received: from foss.arm.com ([217.140.110.172]:35204 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731707AbfIOOdk (ORCPT ); Sun, 15 Sep 2019 10:33:40 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5C08528; Sun, 15 Sep 2019 07:33:40 -0700 (PDT) Received: from [10.0.2.15] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 983603F575; Sun, 15 Sep 2019 07:33:39 -0700 (PDT) Subject: Re: [PATCH] sched: fix migration to invalid cpu in __set_cpus_allowed_ptr To: shikemeng , mingo@redhat.com, peterz@infradead.org Cc: linux-kernel@vger.kernel.org References: <979d57f8-802b-57e5-632a-f94ad0f9d6a1@arm.com> <1568535662-14956-1-git-send-email-shikemeng@huawei.com> From: Valentin Schneider Message-ID: <5dfd4844-6c36-3b8d-203b-564d7ad7103d@arm.com> Date: Sun, 15 Sep 2019 15:33:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <1568535662-14956-1-git-send-email-shikemeng@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15/09/2019 09:21, shikemeng wrote: >> It's more thoughtful to add check in cpumask_test_cpu.It can solve this problem and can prevent other potential bugs.I will test it and resend >> a new patch. >> > > Think again and again. As cpumask_check will fire a warning if cpu >= nr_cpu_ids, it seems that cpumask_check only expects cpu < nr_cpu_ids and it's > caller's responsibility to very cpu is in valid range. Interfaces like cpumask_test_and_set_cpu, cpumask_test_and_clear_cpu and so on are not checking > cpu < nr_cpu_ids either and may cause demage if cpu is out of range. > cpumask operations clearly should never be fed CPU numbers > nr_cpu_ids, but we can get some sneaky mishaps like the one you're fixing. The answer might just be to have more folks turn on DEBUG_PER_CPU_MAPS in their test runs (I don't for instance - will do from now on), since I get the feeling people like to be able to disable these checks for producty kernels. In any case, don't feel like you have to fix this globally - your fix is fine on its own.