Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1845372rwo; Thu, 3 Aug 2023 00:03:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlG4V1milxbHLKVZzvGwgKzgwR3QZBZgnNxW342Pjd80S8YoiXJKk84CdufQycwUlxJSW2zn X-Received: by 2002:a05:6358:9894:b0:139:d0bc:acfa with SMTP id q20-20020a056358989400b00139d0bcacfamr7394200rwa.23.1691046231745; Thu, 03 Aug 2023 00:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691046231; cv=none; d=google.com; s=arc-20160816; b=SXwwe+RuvzX2YztS1dUln72KZgCm3uYWSSHbqS4Y9IGCHdW8Ae+02XK9MnTY4ZKAr/ 9PjWqF8UVJoNOiM3gIVQu97FDTq+qtp0v3RM40pSs0px3bVC+5RZOo0HX23tfQ6r9XN0 dVZh6b+UDbTd7MRIG7iX+HC2ROMzRZkR+U5IDm1Luzl+KD/f0S2dqcBchH7UVlVF+x2O LcHeKWSCcKVsOXoZ1jmYL8mdCRkP3NBwjw3AWQaqYeRcpiMk9Dw0HAhK902rSF6aCAXO PqSp+Ko2v3QIZmbioqmQUZqOksS05IVwE+OH6xFfdyYhZC9avuMZuTimXXecfNTWO3p6 f/Zw== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=C7WsYV/x7lyB/wTNGCIcHVMNipm/cU1Q7w5THwIRrSU=; fh=7e/pKFADWD5ZiH5VAJlJRsrb/GWs8aKXkfVw5R7FF2A=; b=EwEZmBSrygBimSbrO8ZD7CpsedcRZNghCUyyz+joe6T/GviQU/j6LNzhWh8cKhFc4J ehUL1Qb2TG6aPx5imz/taGANRvee0k2dUnJe+EhO161cQeco8QAx4pPanPOjL0NEVxhJ OuXcXGEG5/l/S4A5dp7FSdLpVFN6t9hsI6Dw65LUaK9TWT5EU9JK12iWDiw2RqBdZ02q skmqavehhYtpugHvhfleBy1gEoJvD8iVj/5VE4BgfLtdTNf3BtdEiWQP+zFRDAXzAlp8 I+BI2JVRrU+S6XZ6q9mHWLXh64M9dpiNDA6zemqFGgJVuDPhTRR3uaMQSVHsyIGr8Tn2 H5ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zAgoVRmj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s19-20020a63af53000000b0055afc8a301asi3487564pgo.177.2023.08.03.00.03.32; Thu, 03 Aug 2023 00:03:51 -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; dkim=pass header.i=@linaro.org header.s=google header.b=zAgoVRmj; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232544AbjHCF4N (ORCPT + 99 others); Thu, 3 Aug 2023 01:56:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbjHCF4L (ORCPT ); Thu, 3 Aug 2023 01:56:11 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC9F92D4A for ; Wed, 2 Aug 2023 22:56:10 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id 41be03b00d2f7-563e860df0fso360206a12.2 for ; Wed, 02 Aug 2023 22:56:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691042170; x=1691646970; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=C7WsYV/x7lyB/wTNGCIcHVMNipm/cU1Q7w5THwIRrSU=; b=zAgoVRmjKopQptfjt67R46qrgqXC6e7F8RrNLBq0gotYSQZOeWgnOMgIva55l3NKHe 271ABzS+rcGJOZQdiqE85sxQfOFOoRat3iYCzFrPjqU1z47X6J+NV0980nOYhWUh+R/O jGs+KODx1PnSoxZjaQ022rqvHyqLvBGrs+ADB02lZCe7MizoIkD14Zoaj5x3ofhG5uNC R0IX+JtSNH7XAyq6Uc7xOHafeRMb6/s9jQr8UmKTBVR7AzN8Mms7u4xn3/TBrLglW8/A oa/lwW0/JfNKx318653BCbr2BptGYdVt9mK9Xh31imoa0JeyRvCsQGN7Zwl6a8I4AqPi EsAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691042170; x=1691646970; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=C7WsYV/x7lyB/wTNGCIcHVMNipm/cU1Q7w5THwIRrSU=; b=C/X2da06Xu9MRoY99oDR4uZQtQI7YmFZF5LGxl9NBRTomiPWLyJd7vrkE1WiAOXl6v Qmj7/nie7uYAX4ARdedYAEoSjGCRH7ooFkoLXP6CQVK/0uCv2el0t0e7I8Z96l3sO9Iw 6JXWwpBSonjaeKDMAmAm/bKMN+6AXp/FjZzF3UMfU0gFXTqv44dm0izm8Tirst/QoLBh nzdKvh7OW+MJeMux2b5Boyi7FVBiWU+2bb9xG4PhQK1AiU2jraJO0L2efUoSm9Y1Wkm3 AJuqCrNcgJZsBrcaDruRtfzMGAWUfdFCKgzyJOZfD/kJNalgckwpg0QzdaVhzMjY2HaU 9jHA== X-Gm-Message-State: ABy/qLaFpr8bFBV39ls9ng6ZkXncnYQn3EnRnr6cY9Vbh+Z7xLLjhnY8 hN8B2s8HM9MIQdBF3uV/fqHSDw== X-Received: by 2002:a17:902:ea95:b0:1b0:6038:2982 with SMTP id x21-20020a170902ea9500b001b060382982mr17234494plb.41.1691042169672; Wed, 02 Aug 2023 22:56:09 -0700 (PDT) Received: from localhost ([122.172.87.195]) by smtp.gmail.com with ESMTPSA id a12-20020a170902eccc00b001b03b7f8adfsm13451200plh.246.2023.08.02.22.56.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 22:56:09 -0700 (PDT) Date: Thu, 3 Aug 2023 11:26:07 +0530 From: Viresh Kumar To: Florian Fainelli Cc: "Gustavo A. R. Silva" , Markus Mayer , Broadcom internal kernel review list , "Rafael J. Wysocki" , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Kees Cook Subject: Re: [PATCH v3] cpufreq: brcmstb-avs-cpufreq: Fix -Warray-bounds bug Message-ID: <20230803055607.ueliy6eofvhoy4gw@vireshk-i7> References: <66e19ae3-253d-5377-5cc2-566ec3cfed49@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <66e19ae3-253d-5377-5cc2-566ec3cfed49@broadcom.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 01-08-23, 10:05, Florian Fainelli wrote: > On 7/31/23 20:15, Gustavo A. R. Silva wrote: > > Allocate extra space for terminating element at: > > > > drivers/cpufreq/brcmstb-avs-cpufreq.c: > > 449 table[i].frequency = CPUFREQ_TABLE_END; > > > > and add code comment to make this clear. > > > > This fixes the following -Warray-bounds warning seen after building > > ARM with multi_v7_defconfig (GCC 13): > > In function 'brcm_avs_get_freq_table', > > inlined from 'brcm_avs_cpufreq_init' at drivers/cpufreq/brcmstb-avs-cpufreq.c:623:15: > > drivers/cpufreq/brcmstb-avs-cpufreq.c:449:28: warning: array subscript 5 is outside array bounds of 'void[60]' [-Warray-bounds=] > > 449 | table[i].frequency = CPUFREQ_TABLE_END; > > In file included from include/linux/node.h:18, > > from include/linux/cpu.h:17, > > from include/linux/cpufreq.h:12, > > from drivers/cpufreq/brcmstb-avs-cpufreq.c:44: > > In function 'devm_kmalloc_array', > > inlined from 'devm_kcalloc' at include/linux/device.h:328:9, > > inlined from 'brcm_avs_get_freq_table' at drivers/cpufreq/brcmstb-avs-cpufreq.c:437:10, > > inlined from 'brcm_avs_cpufreq_init' at drivers/cpufreq/brcmstb-avs-cpufreq.c:623:15: > > include/linux/device.h:323:16: note: at offset 60 into object of size 60 allocated by 'devm_kmalloc' > > 323 | return devm_kmalloc(dev, bytes, flags); > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > This helps with the ongoing efforts to tighten the FORTIFY_SOURCE > > routines on memcpy() and help us make progress towards globally > > enabling -Warray-bounds. > > > > Link: https://github.com/KSPP/linux/issues/324 > > Fixes: de322e085995 ("cpufreq: brcmstb-avs-cpufreq: AVS CPUfreq driver for Broadcom STB SoCs") > > Cc: stable@vger.kernel.org > > Signed-off-by: Gustavo A. R. Silva > > Reviewed-by: Florian Fainelli Applied. Thanks. -- viresh