Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1214188pxb; Fri, 1 Apr 2022 07:34:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLVPNf4Xeg6paCXH51LtSRWUSq6Yybx5Iils5IiE+qNdp+kOUz4b+x0050sNuDPjzNOBBi X-Received: by 2002:aa7:d543:0:b0:416:13eb:6fec with SMTP id u3-20020aa7d543000000b0041613eb6fecmr21584277edr.348.1648823648374; Fri, 01 Apr 2022 07:34:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648823648; cv=none; d=google.com; s=arc-20160816; b=Qcf4KvYP7ZgSkSX0nGKwutcV8ilpuYilW39usmK85RX+iOFJh5hEUqOa9ouY2P4YNT 4ke1MLYQJWUJxBR2DCJcWTvE/0FYpT6ASNPGlBv3FRys0Ra60ljdENh7h4LY0WnAMpwC HQ8dUcndb80Zk09k8+eHgbTiuUYJz6Vxn1bOmVSJZ35EYVLPC2h2BCE+98U6ird5XTCn B8IDgGsCSIHJM9YVHg97q+016JGJ7hhjAxZGQaJvZD9ItaeNT0vM9yDZQrUydxpQcI2V YMa29urQxUPvnILiwGKr9JWXwDlar0NANvl5xVBgo9jWGow1urXonoWvWqOuLWXJyDta x19w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=KRgIhkmFIontvWMu86WCEAC4jdpxx6aHVwFhivxtK8w=; b=aGt+RAT94xiZCNJh51WajlkVjf+g/+xo8HTCWP05qy+U/EAtMOd68PVQeo7PnlpafI odv+7gU9hScCeGS5ohXCzzzTN2MUtJzuBcZuzalNiWnfZJGCqChLFhCupc65ogCOAdvl EwKqXLc2feWK2BReQl3WMcopWz2/F5Bc7X+IIOFWCme0nM2Ae4KbvrlsTCyhfimagpiv tJletdhCLttgu3OtLnfuC55gbphe2f6C8qPUV1Dpbt0N5zHEuwOj4xz7W9P+K9k3AvuE YWzdf98vD4h2SRL4TfHXwiSH0JpxxCaAy9K2vLkcsz0mGqek+Oz1PNoPK/fGcNd1flkZ eI3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l25-20020a1709062a9900b006df76385c66si1721678eje.262.2022.04.01.07.33.43; Fri, 01 Apr 2022 07:34:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344557AbiDAJaj (ORCPT + 99 others); Fri, 1 Apr 2022 05:30:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344559AbiDAJah (ORCPT ); Fri, 1 Apr 2022 05:30:37 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DC4A91CCACE for ; Fri, 1 Apr 2022 02:28:47 -0700 (PDT) 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 B747A13D5 for ; Fri, 1 Apr 2022 02:28:46 -0700 (PDT) Received: from e110455-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 78D763F66F for ; Fri, 1 Apr 2022 02:28:46 -0700 (PDT) Date: Fri, 1 Apr 2022 10:28:29 +0100 From: Liviu Dudau To: Kees Cook Cc: Sudeep Holla , Lorenzo Pieralisi , Russell King , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH] ARM: vexpress/spc: Avoid negative array index when !SMP Message-ID: References: <20220331190443.851661-1-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220331190443.851661-1-keescook@chromium.org> X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 31, 2022 at 12:04:43PM -0700, Kees Cook wrote: > When building multi_v7_defconfig+CONFIG_SMP=n, -Warray-bounds exposes > a couple negative array index accesses: > > arch/arm/mach-vexpress/spc.c: In function 've_spc_clk_init': > arch/arm/mach-vexpress/spc.c:583:21: warning: array subscript -1 is below array bounds of 'bool[2]' {aka '_Bool[2]'} [-Warray-bounds] > 583 | if (init_opp_table[cluster]) > | ~~~~~~~~~~~~~~^~~~~~~~~ > arch/arm/mach-vexpress/spc.c:556:7: note: while referencing 'init_opp_table' > 556 | bool init_opp_table[MAX_CLUSTERS] = { false }; > | ^~~~~~~~~~~~~~ > arch/arm/mach-vexpress/spc.c:592:18: warning: array subscript -1 is below array bounds of 'bool[2]' {aka '_Bool[2]'} [-Warray-bounds] > 592 | init_opp_table[cluster] = true; > | ~~~~~~~~~~~~~~^~~~~~~~~ > arch/arm/mach-vexpress/spc.c:556:7: note: while referencing 'init_opp_table' > 556 | bool init_opp_table[MAX_CLUSTERS] = { false }; > | ^~~~~~~~~~~~~~ > > Skip this logic when built !SMP. > > Cc: Liviu Dudau > Cc: Sudeep Holla > Cc: Lorenzo Pieralisi > Cc: Russell King > Cc: linux-arm-kernel@lists.infradead.org > Signed-off-by: Kees Cook Acked-by: Liviu Dudau Sudeep, can you please take this through your tree for sending it to arm-soc? Best regards, Liviu > --- > arch/arm/mach-vexpress/spc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c > index 1da11bdb1dfb..1c6500c4e6a1 100644 > --- a/arch/arm/mach-vexpress/spc.c > +++ b/arch/arm/mach-vexpress/spc.c > @@ -580,7 +580,7 @@ static int __init ve_spc_clk_init(void) > } > > cluster = topology_physical_package_id(cpu_dev->id); > - if (init_opp_table[cluster]) > + if (cluster < 0 || init_opp_table[cluster]) > continue; > > if (ve_init_opp_table(cpu_dev)) > -- > 2.32.0 > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯