Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1109541rwi; Wed, 19 Oct 2022 06:53:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7xXKKHusXwYMEr25zKgkcu/KgXFhgwVCSJhHSFOkObHAmO8IpjD1wYtg1Pp8/Pag3Yi/AP X-Received: by 2002:a17:902:e74d:b0:186:5db4:285f with SMTP id p13-20020a170902e74d00b001865db4285fmr721021plf.119.1666187589694; Wed, 19 Oct 2022 06:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666187589; cv=none; d=google.com; s=arc-20160816; b=XeDfgIhCwbhjSNMoeIf5/OdVcJcfalXZ9XandcciouQuErhln65j+avvHR7MuKTpFL Xy5aHOAp92AJI3jj9/7RHuyL5oi4VWv3yXK31Jp/DOcaUzwigyGDS/MaCcife0IQ61Db EGYFwf77eVIZWwc+ZdFBXtFQGISZLVTRidn2blAitcYjBLkZfDEyd2+LUo+n+RVT0hql 3It/0pkpcgk6NF1cP8DkWdqA4nFgXy6gAQ1XdAP3V4Zph69L487Bwzzj9IO3APeHpT8C s8d7XAtoq5L4tDptwQhaYvbzO3Dbtfq0TsZ+vEsF+v/eDH+D/n5Kmk3uXAtwuh680Xin M5JA== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/FSFo6mf7eMkL0wMWQgBAXbqaoy3pwSZaxsNpeXAa4g=; b=YL+GbmL8iO2UiGVFBwTHHkuLKQMp7oIwcXsgjOA/3szUlFX3WA0vryTZHtwpFQEavE v8xu1yfz+cnrVWqD+M/QJTM7FUwIJGXb7HctNiwIxxBkV4SDRSCIiBwBf2xgBi9KyjB0 CkVCq48YKpD9jGm3NBOUFIv3fwwPNZWUArBz3UPA/O0g2AqN3yg4GijAAU0kTq/nRwso CDJKGK/jSJoYm6ERB1PabGntam7044hMt8OdbxvY6k4YAKzJ42ybDSveTlsRvh6p7F3B U2xxmKvnab/PNVB6uO8F3IcWrmq0/6pyMCRLx4tOusO9KfRif4FvpO6YzcQSUYsvgjF8 BQyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sqUHxYuC; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m3-20020a056a00080300b00535d7265923si20852532pfk.377.2022.10.19.06.52.54; Wed, 19 Oct 2022 06:53:09 -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=@linuxfoundation.org header.s=korg header.b=sqUHxYuC; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231783AbiJSNog (ORCPT + 99 others); Wed, 19 Oct 2022 09:44:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233358AbiJSNoH (ORCPT ); Wed, 19 Oct 2022 09:44:07 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7C0219B649; Wed, 19 Oct 2022 06:31:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 01F36CE20F9; Wed, 19 Oct 2022 08:47:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8C3DC433C1; Wed, 19 Oct 2022 08:47:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169248; bh=tsYIEnNeNXBKuktBDiK6adMOHZqbmAxFQCb+rNO0Bnc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sqUHxYuC/lfoKUPE460L094NAnvLaJWNetFblinmo6vZGmlBBF00qNDoENCq6b2BD If876I4hrWCVc8akhCp2hjniTN1Y9HKHuzl9pJ8I5kufjncCodVQ0TdUmxJzqeXoZD sZCTqaR1rYxdFZ3RXD3gPaeYyoDTLZBE/tnIhTBM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org, Geert Uytterhoeven , Geert Uytterhoeven , "Gustavo A. R. Silva" , Kees Cook , Sasha Levin Subject: [PATCH 6.0 209/862] sh: machvec: Use char[] for section boundaries Date: Wed, 19 Oct 2022 10:24:56 +0200 Message-Id: <20221019083259.250168421@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 From: Kees Cook [ Upstream commit c5783af354688b24abd359f7086c282ec74de993 ] As done for other sections, define the extern as a character array, which relaxes many of the compiler-time object size checks, which would otherwise assume it's a single long. Solves the following build error: arch/sh/kernel/machvec.c: error: array subscript 'struct sh_machine_vector[0]' is partly outside array bounds of 'long int[1]' [-Werror=array-bounds]: => 105:33 Cc: Yoshinori Sato Cc: Rich Felker Cc: linux-sh@vger.kernel.org Reported-by: Geert Uytterhoeven Link: https://lore.kernel.org/lkml/alpine.DEB.2.22.394.2209050944290.964530@ramsan.of.borg/ Fixes: 9655ad03af2d ("sh: Fixup machvec support.") Reviewed-by: Geert Uytterhoeven Reviewed-by: Gustavo A. R. Silva Acked-by: Rich Felker Signed-off-by: Kees Cook Signed-off-by: Sasha Levin --- arch/sh/include/asm/sections.h | 2 +- arch/sh/kernel/machvec.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/sh/include/asm/sections.h b/arch/sh/include/asm/sections.h index 8edb824049b9..0cb0ca149ac3 100644 --- a/arch/sh/include/asm/sections.h +++ b/arch/sh/include/asm/sections.h @@ -4,7 +4,7 @@ #include -extern long __machvec_start, __machvec_end; +extern char __machvec_start[], __machvec_end[]; extern char __uncached_start, __uncached_end; extern char __start_eh_frame[], __stop_eh_frame[]; diff --git a/arch/sh/kernel/machvec.c b/arch/sh/kernel/machvec.c index d606679a211e..57efaf5b82ae 100644 --- a/arch/sh/kernel/machvec.c +++ b/arch/sh/kernel/machvec.c @@ -20,8 +20,8 @@ #define MV_NAME_SIZE 32 #define for_each_mv(mv) \ - for ((mv) = (struct sh_machine_vector *)&__machvec_start; \ - (mv) && (unsigned long)(mv) < (unsigned long)&__machvec_end; \ + for ((mv) = (struct sh_machine_vector *)__machvec_start; \ + (mv) && (unsigned long)(mv) < (unsigned long)__machvec_end; \ (mv)++) static struct sh_machine_vector * __init get_mv_byname(const char *name) @@ -87,8 +87,8 @@ void __init sh_mv_setup(void) if (!machvec_selected) { unsigned long machvec_size; - machvec_size = ((unsigned long)&__machvec_end - - (unsigned long)&__machvec_start); + machvec_size = ((unsigned long)__machvec_end - + (unsigned long)__machvec_start); /* * Sanity check for machvec section alignment. Ensure @@ -102,7 +102,7 @@ void __init sh_mv_setup(void) * vector (usually the only one) from .machvec.init. */ if (machvec_size >= sizeof(struct sh_machine_vector)) - sh_mv = *(struct sh_machine_vector *)&__machvec_start; + sh_mv = *(struct sh_machine_vector *)__machvec_start; } pr_notice("Booting machvec: %s\n", get_system_type()); -- 2.35.1