From patchwork Tue Aug 1 14:54:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 13336905 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 89895C00528 for ; Tue, 1 Aug 2023 14:55:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PBb2zHaJmGBCjEDrgIoar2HW84UDMS6CAC8261Pjx68=; b=xXWy9gHK3SoEi9 BmqqSETQOMdFrol/3gJMl2/tzoEa9QqzqvUX3/mR/lZvqyyr7NSsxY4fc41i/01v9BErVi4ik8/Zb ExxNg7lS4Xfe4HqOdL5c+e2Hq2RSgaMws6WIZ1kg+qdb+apA5FLkLv0tOlAs4bIiHhAvl19Qt6mdj Zt6dVwwy76zFWNwj4I3VNPq4N2yhTIplJEB4wkBaPFBAuAfk9iHIdhiN0la3jhqSyjIqGsbZXaKzy 9qQbZQOvwkhguYci/e9JQix6x+buv6b9HbR19uZYJg5dbAlDUlex7C6QOiPInCyjTie6D+VUH8atK awzn/gx/iFQjeppigVQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQqlh-002ekD-2k; Tue, 01 Aug 2023 14:54:37 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qQqle-002eik-32 for linux-arm-kernel@lists.infradead.org; Tue, 01 Aug 2023 14:54:36 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 21C4313D5; Tue, 1 Aug 2023 07:55:14 -0700 (PDT) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3AC313F5A1; Tue, 1 Aug 2023 07:54:29 -0700 (PDT) From: James Morse To: linux-modules@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Luis Chamberlain , Catalin Marinas , Will Deacon , Russell King , Russell King , Jessica Yu , james.morse@arm.com, Adam Johnston Subject: [PATCH 3/3] ARM: module: Use module_init_layout_section() to spot init sections Date: Tue, 1 Aug 2023 14:54:09 +0000 Message-Id: <20230801145409.8935-4-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230801145409.8935-1-james.morse@arm.com> References: <20230801145409.8935-1-james.morse@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230801_075435_031321_43B2BF2C X-CRM114-Status: GOOD ( 14.27 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Today module_frob_arch_sections() spots init sections from their 'init' prefix, and uses this to keep the init PLTs separate from the rest. get_module_plt() uses within_module_init() to determine if a location is in the init text or not, but this depends on whether core code thought this was an init section. Naturally the logic is different. module_init_layout_section() groups the init and exit text together if module unloading is disabled, as the exit code will never run. The result is kernels with this configuration can't load all their modules because there are not enough PLTs for the combined init+exit section. A previous patch exposed module_init_layout_section(), use that so the logic is the same. Fixes: 055f23b74b20 ("module: check for exit sections in layout_sections() instead of module_init_section()") Cc: stable@vger.kernel.org Signed-off-by: James Morse --- I've not managed to get 32bit to call get_module_plt(), but it looks possible to hit the BUG_ON() because of this. --- arch/arm/kernel/module-plts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/kernel/module-plts.c b/arch/arm/kernel/module-plts.c index f5a43fd8c163..da2ee8d6ef1a 100644 --- a/arch/arm/kernel/module-plts.c +++ b/arch/arm/kernel/module-plts.c @@ -251,7 +251,7 @@ int module_frob_arch_sections(Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, /* sort by type and symbol index */ sort(rels, numrels, sizeof(Elf32_Rel), cmp_rel, NULL); - if (strncmp(secstrings + dstsec->sh_name, ".init", 5) != 0) + if (!module_init_layout_section(secstrings + dstsec->sh_name)) core_plts += count_plts(syms, dstsec->sh_addr, rels, numrels, s->sh_info); else