From patchwork Mon Oct 24 11:29:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8906 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp434112wru; Mon, 24 Oct 2022 05:51:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7JJnJKhrgwkYhLCpt2iULGyChUpXCN28jPO7IKmTMZrIj5OqUJkgca829kfg/SFZ41KQSB X-Received: by 2002:a63:6942:0:b0:41c:9261:54fd with SMTP id e63-20020a636942000000b0041c926154fdmr28842970pgc.34.1666615886131; Mon, 24 Oct 2022 05:51:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615886; cv=none; d=google.com; s=arc-20160816; b=mYjs+JmrMhG1Y2XRUbWqjQUR1RcBrlUnNLUEvgf1YohSzIDeKnCViBhU7cVpwGFP70 TqFQbCRbYHEuPygd+OkNeASykMi2RJ50tWCS//YSeaMdAnYCwczgRnC0PW32hGGbzGa/ +P3HhlXJ8xJCHoMxAdQ504tMH2WlVCvIfYZgedGPfaP6w6ytDZn8i/2SI77lS6T1+khk tr/mGLX7ErDZnCYHIn+SH582mjf6m68VZ7mnRSS5biERh1K3p3GRpY03RvunkMndqfK6 TrYWj6MsQdqajY7EfASZ9vFlWkemgQc2W2UxfMJ6cH/FRhv+KXjtnprLlxAJC7FmMvwy qDKQ== 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=/yn1BOOtCq44xb3t12KEGR0KPKfwNHsiBRV78UrAKjc=; b=nJwBIqiTjQDE0/ASUhzoeDjHIIaB8fIlyozCxyu8POVZNmazlP9rWz0NWbA3h3wot7 unSOsJA7bk0Zlkuau23d1KmrwTysvNr1TWokrqUJOPz+n73XKNwXCEy5o+tpjmqcdrwS oZKHOnWh5XhTo9r/mQb+txaygwggtFZ+fw49g7XhKsX5jFiHS4T5Yi7uGfqdojCQ9ihI fzueuE3JoqA/czuYEhM9ZkazRfrCfoidq0Z7eHQQLMnkB8uzk/iO94EqAylGaMy5R3Sl 2P5DnSfH39z/VCl222P3iNHBnbjAXNhFWuadwodfBwbsrB5Z6ybJcj5kSdDcLQhkKnac Yt7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=K6jGO3bi; 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 i7-20020aa796e7000000b00557c8a20395si32551574pfq.120.2022.10.24.05.51.07; Mon, 24 Oct 2022 05:51:26 -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=K6jGO3bi; 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 S232139AbiJXMtq (ORCPT + 99 others); Mon, 24 Oct 2022 08:49:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234537AbiJXMpC (ORCPT ); Mon, 24 Oct 2022 08:45:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E82A65F5; Mon, 24 Oct 2022 05:09:37 -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 59DB5612FE; Mon, 24 Oct 2022 12:08:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67F45C433C1; Mon, 24 Oct 2022 12:08:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613313; bh=7kquWWJa6dl+O7F/u2jmTd2EKZ7sY3//BZHI9nmrGcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K6jGO3bilaSt5Ho6eKE8YD3PczIU5EYz3I87NZhzHKtDaSqX6k24o5Ju6ZJrtCcAV mGEwllAiOySYHdoFEJlOgUprD/7nC5YRw2Yxc+qqAFaWKFDbeTMH2I4iAL230Cy8GM 64C9Ej5zybqMVupYSNNm3hMfTXCeSbtCGLpaJpAg= 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.4 060/255] sh: machvec: Use char[] for section boundaries Date: Mon, 24 Oct 2022 13:29:30 +0200 Message-Id: <20221024113004.494467418@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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?1747573419112527836?= X-GMAIL-MSGID: =?utf-8?q?1747573419112527836?= 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 beadbbdb4486..3e0a4306f1d5 100644 --- a/arch/sh/kernel/machvec.c +++ b/arch/sh/kernel/machvec.c @@ -19,8 +19,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) @@ -86,8 +86,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 @@ -101,7 +101,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());