Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5555725imm; Mon, 23 Jul 2018 01:38:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcTBWEcOlvPzU8krUsHKfouEye2wcEZenGHho7k+XXntS1h7KRlQa2MRjgEFW/zO0qj/PPM X-Received: by 2002:a17:902:a40b:: with SMTP id p11-v6mr12080838plq.228.1532335135931; Mon, 23 Jul 2018 01:38:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532335135; cv=none; d=google.com; s=arc-20160816; b=dKWszoPvRGq6UttGIZ2YLK7LtFilB3L/mik0f8b7BkTxtGp08RUK8Ze3RIcdeodfqp 6x1u2thn6MYu4MGLVcJXd/czzNCYp1bTbOam8vV5S0Yt8p1xcyaoQsdNh1VEMBaRL+og 8vPlJ+ModHFC5ka4DKHEdUo6LaJIK0EyV5d1CTuIs1rvEL41+V6BMV5ovrLqrwir4Dpm mlmiNkU/Zbn6MUVq3otB5exxQ2Y6ZZIK6qzWHTUg3txZJ2UMPCfuDa2ZGt0krGnCIaxt HNIxJNqoL8uv4MlgWUiWNJIhrZlxAiMT1UrOb5Ji5qLySrYG+NIo88w2MvZJE15GXDV1 jNHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=3t1ILcP0waxWz0icApDAfgvIFrJ104KU9yTd0GACuM8=; b=m9mtRBzkZfFw4sve5mR3y+Ixq/C7fYo83rI72O5yWI8g4KAk0Psp1HHc4qq6XLojof PWL7589i00ii1/tP7ZwyEfU54mW9JpEF3QbXx4hGpXuiyD7wVKjvS2BaLy4M3Aw3D75K f1vrkNmzJ7y/mLfsWK3uJeD/gT69wsv060JHZaHT/ksSBwz0nAYXp4s8dW7pVPH5kozJ 5rdvjLjl510B+tIncRIrjlvrVCu3P2DA3754WuyClUWMopRmrfr5yZ4zEQzg+yn/7OjP DTpGuPDrp8jH3oqeL6jIROTBH6RlfwI1uKbd0f11C78RkjTx8jccJAslQhvej+elyL2y YNXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=KZOFkwlO; 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 4-v6si8123416pgn.90.2018.07.23.01.38.41; Mon, 23 Jul 2018 01:38:55 -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; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=KZOFkwlO; 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 S2388085AbeGWJhN (ORCPT + 99 others); Mon, 23 Jul 2018 05:37:13 -0400 Received: from merlin.infradead.org ([205.233.59.134]:36824 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387972AbeGWJhN (ORCPT ); Mon, 23 Jul 2018 05:37:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3t1ILcP0waxWz0icApDAfgvIFrJ104KU9yTd0GACuM8=; b=KZOFkwlOqaKkc56wBeb2t7eDb NMWOZOEQ+6SXspuzGO3JL1Q3JWgmkEJD5dNDnPpFb5ck+bynTOK2NcBoQ9jHrr46n0pwrB3+qrR4F jtvza+9+IRpcvvb34fmBw6dY3WsnUZhLsp8XXPglWXK8Wr9z9ocked1eyVuXvwbwW0YtgC+hTqBaO cZTrgcODlmEfD2J32Tc/rOm/hYPJyvUpfn8UpFmV+feHCZJSYLfi/l5NwkZIzfAImfGLyrRL3eCAS o60cV1Vfu9M/LTldn7HIrrvzldk63HryokiVoQY+LiMBGRYREX0lgbswLVfbnD1gO7KYa0MjOvXYG Hu3BgcTMA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fhWL3-0004rC-6y; Mon, 23 Jul 2018 08:37:05 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 2EEE620275F47; Mon, 23 Jul 2018 10:37:02 +0200 (CEST) Date: Mon, 23 Jul 2018 10:37:02 +0200 From: Peter Zijlstra To: Yi Wang Cc: mingo@redhat.com, linux-kernel@vger.kernel.org, jiang.biao2@zte.com.cn, zhong.weidong@zte.com.cn Subject: Re: [PATCH] sched/topology: check variable group before dereferenced Message-ID: <20180723083702.GW2494@hirez.programming.kicks-ass.net> References: <1532319547-33335-1-git-send-email-wang.yi59@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1532319547-33335-1-git-send-email-wang.yi59@zte.com.cn> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 23, 2018 at 12:19:07PM +0800, Yi Wang wrote: > The variable group in sched_domain_debug_one() is not checked > when firstly used in cpumask_test_cpu(cpu, sched_group_span(group)), > but it maybe NULL(checked later in the following while loop) and may > cause NULL pointer dereference without checking. We need to check it > before using to avoid NULL dereference. It being NULL really is a fairly severe error in construction; but sure. This patch won't hurt. > Signed-off-by: Yi Wang > Reviewed-by: Jiang Biao > --- > kernel/sched/topology.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c > index 5ac724b..c7cf87c 100644 > --- a/kernel/sched/topology.c > +++ b/kernel/sched/topology.c > @@ -53,7 +53,7 @@ static int sched_domain_debug_one(struct sched_domain *sd, int cpu, int level, > printk(KERN_ERR "ERROR: domain->span does not contain " > "CPU%d\n", cpu); > } > - if (!cpumask_test_cpu(cpu, sched_group_span(group))) { > + if (group && !cpumask_test_cpu(cpu, sched_group_span(group))) { > printk(KERN_ERR "ERROR: domain->groups does not contain" > " CPU%d\n", cpu); > } > -- > 1.8.3.1 >