From patchwork Mon Oct 24 11:28:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9515 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp482003wru; Mon, 24 Oct 2022 07:24:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM49D6MEWoWwNDi4VX3veDrQazLkIcOMGK1kbqwRqKpY9IFR+7sj4gtB7lai2nsP+jUd2k7/ X-Received: by 2002:aa7:ccd7:0:b0:461:c6e9:8b0 with SMTP id y23-20020aa7ccd7000000b00461c6e908b0mr4873168edt.287.1666621453297; Mon, 24 Oct 2022 07:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666621453; cv=none; d=google.com; s=arc-20160816; b=WzCfqSE4cLtpnsuvc/J2ynVBjcom/mxzAqoGHVI5nDPrB1/toeYqJphdWmOn4OhV4q o+0WGBJrgdKUyHhWDcECian/bjwIcE17hNuc+3ECUH8mYbTSkVUHF2ba6nPCtYtB3+L7 j+St6MabrrWkAlhQKn8cjmgz9LXdJcO5BqIgF8sde8djNiYkt8WA7Ns/doFtD4iYUZrC aepC/VBGzZwjRra6Ou6x8dZzrkjphYM1dS0CGhs+wt2edp1Qm4r+zq8IZXYCtbO2Sek1 8dT5xus2Wf7XkO4DKIIkDgz+2LfjexaXrrWjf0mtBsNFawFNOMR1H1ecz09uni7haWci tYcQ== 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=ShU4kcFcwcmeHI11i6B6t1FlNTuvWrP8zoAi55eSGYCJ79Cgm4/kAMNM7uUgBY5jDx KvIKuEJrk+Imk6bG+izVsYyrBEIzLUFG1QI+TGByW/zrtSKMZOl87713oglKP5q5RdZT 7m9begoZaa9K9tdJQUHFHtyscn2c2IB22T0D/leivCJ+6SrMZBQ48E9Y8Jlka3UrF/Qx x1UqR2qEMpuJFrprep9ORrEik7lMU1m1mZ2BLKx4w2c/IHE8ZRuaVUXJVkAx/gFjBK6G nWWJ3MMgcqGXSk35UcP+QHPkug+Gl6JV11NJhLTs4wdGCbTb9NN59UzO+0ZkP/bn8A4K KAcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="T31da/6n"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gb27-20020a170907961b00b00741a16e8562si28500400ejc.826.2022.10.24.07.23.49; Mon, 24 Oct 2022 07:24:13 -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="T31da/6n"; 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 S235944AbiJXOW1 (ORCPT + 99 others); Mon, 24 Oct 2022 10:22:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235310AbiJXOS7 (ORCPT ); Mon, 24 Oct 2022 10:18:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30A622C66E; Mon, 24 Oct 2022 05:56:30 -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 ams.source.kernel.org (Postfix) with ESMTPS id 7517BB818EB; Mon, 24 Oct 2022 12:39:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8AB4C433C1; Mon, 24 Oct 2022 12:39:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615146; bh=tsYIEnNeNXBKuktBDiK6adMOHZqbmAxFQCb+rNO0Bnc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T31da/6n9n64A6UeKcHpwI6mhzWkI3QBWY2dCyry0gBnd4AP6We6rmvmQOyTvFiIw QGREWFDxsZ7upxgQ1r50IZ8Flmq/GYpt+44Xm8yjRp/GizFFFu/SLVvQFaunzrFzBG B7qiUUl0Cp1WaevUJX9p8YFntqncAOUUc8eTNYWk= 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 5.15 140/530] sh: machvec: Use char[] for section boundaries Date: Mon, 24 Oct 2022 13:28:04 +0200 Message-Id: <20221024113051.399438104@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747579256986331338?= X-GMAIL-MSGID: =?utf-8?q?1747579256986331338?= 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());