From patchwork Mon Oct 24 11:30:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8434 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp401024wru; Mon, 24 Oct 2022 04:48:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5gRpvl3WUdAW9+IJpIBqNGOHJ1YIJk6iqYrdbI5CFDNHydeypZfBYHvdMmUa1eaQdqQrTB X-Received: by 2002:a17:906:730c:b0:791:997f:d65d with SMTP id di12-20020a170906730c00b00791997fd65dmr28034805ejc.18.1666612082802; Mon, 24 Oct 2022 04:48:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666612082; cv=none; d=google.com; s=arc-20160816; b=pNxY59sgkxoEQHvcAq3rNsNNMKPQNsCibqfaDeoZWRxQPe9jFWJLhxpFTEu5u11EyH HPWY1YuJhfZYb/dbOhKo5FKQeh5Y+5scjsqbIPWzrTwwOmN0+9PmW75karF2XmXRuA1Q KrbmyAdubXIlvknOvHSpk9qF6YZv+8IpEbML9uCqSGduz/0zLxWlCv6GWoJtEPXJq2E2 ByZ74oQvDZM5CJlYmykm866X4GLx2hj8x3A4Q7q5gHmz5+0bAQ/K33CkyN8Q8u7djiSq H9MLSJyhPadwe0J9JCMjpcXGK+pZWnoQ6PsRGaTFaPl7glbdID4sR1efSzC7oYzF57Lm t+9w== 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=bKg9WAkkYdo4VgTajrnDnnw5yhyTxE6NMMSdtZZbug8=; b=wFB4SegAOM9dG9J1NtEWBNKY3ZVb0NfmgN0U5Bba2sHTMY7aToqTwafJ1daQqWMfiz Taav1oa3CLhKsXzimH/szUL6UphspT1Es0sunJ39+75mnRkHfDGdkoPG9zjEDYRlzErC lKAwfHuBgP4PKC59h47au3RvDhZsePuAr5g083fOa74uQqK6U76SWYvhIw5Zg0QnuILu 561ohSZ5oB8iHzpEDvB3r3sDo4toyhKTEEbXKTb6nu0btG7F5XbAG8oVo4Hw5tir0FHZ xNaOagVzmBLF3tEFjUlkhDwdqAgz8UfviVrCG/SDt37lRv91qCm+54m5dqVJ39eNB2TV Dpsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MyDN1wqE; 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 dp19-20020a170906c15300b0078c47b4478esi25733452ejc.106.2022.10.24.04.47.39; Mon, 24 Oct 2022 04:48:02 -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=MyDN1wqE; 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 S231519AbiJXLrH (ORCPT + 99 others); Mon, 24 Oct 2022 07:47:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231126AbiJXLpK (ORCPT ); Mon, 24 Oct 2022 07:45:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEBE775CD5; Mon, 24 Oct 2022 04:42:24 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 99993612AB; Mon, 24 Oct 2022 11:41:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF1CCC433C1; Mon, 24 Oct 2022 11:41:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611663; bh=N9qKZYT7mOJgyhIRE5pCqOGzv5ItisKgr4od6nYdI7U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MyDN1wqEn1UCdNBjRQRzOtoesmmWc1qL7Kf4gIW/9GfzqJ49DQkw6OCRUSsPUDYiC aYcAVNXyjMPKlmTPRF0DAz99YoffmM++Msxf9yPkvClLS2gB/2B/wJAMLxRfnVZTvh CvQ/VdLHoZhaaomm6OJmdCXaF8I1idpkcqSSV2uY= 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 4.9 064/159] sh: machvec: Use char[] for section boundaries Date: Mon, 24 Oct 2022 13:30:18 +0200 Message-Id: <20221024112951.802269614@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112949.358278806@linuxfoundation.org> References: <20221024112949.358278806@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?1747569431231250966?= X-GMAIL-MSGID: =?utf-8?q?1747569431231250966?= 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 7a99e6af6372..9ec764c4ffe9 100644 --- a/arch/sh/include/asm/sections.h +++ b/arch/sh/include/asm/sections.h @@ -3,7 +3,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 ec05f491c347..a9f797a76e7c 100644 --- a/arch/sh/kernel/machvec.c +++ b/arch/sh/kernel/machvec.c @@ -22,8 +22,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) @@ -89,8 +89,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 @@ -104,7 +104,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; } printk(KERN_NOTICE "Booting machvec: %s\n", get_system_type());