From patchwork Mon Jun 3 10:57:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Schiffer X-Patchwork-Id: 10972753 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D01B76 for ; Mon, 3 Jun 2019 10:58:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C192288AC for ; Mon, 3 Jun 2019 10:58:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E5DF28501; Mon, 3 Jun 2019 10:58:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A510D288AC for ; Mon, 3 Jun 2019 10:58:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=fIetZvn1CNYZIQwzjt3hJI3e2T7Xl36wMkug1Wij9J4=; b=TbQWh2tUfmgzq+vOy/WP6rtaGT CIOls67AN2W+tngD6zZfaMzEOTw8dwNo+inut8mYLSXt1WMgO8tAT9b4Tb9P3BFcbfKoBbOJh0fFL UlC6apcPZ4f3CaO2fNZylqbZYRUPlPXpiIrfP2KnaHsV33DtNM3py+bVrVCGe79d4gosftPB75q9/ xFzzFQ6kaiF8mU3TLDeKumMI1J4X4eJHvKPdHqELvsgMwAW3MnqdTNWY38Or6si1Gkg/SUxJiQfDM IWIPFo6HOXVMyvsTAY5esMVYvQvXZ0c0xBfCkS2m40ci7Dt/wCP4pfTV9tjhi6VCnN7LKS8zEBR1Y uaH0DqlA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hXkfm-0004E1-7d; Mon, 03 Jun 2019 10:58:38 +0000 Received: from mx1.tq-group.com ([62.157.118.193]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hXkff-00045k-Fe for linux-arm-kernel@lists.infradead.org; Mon, 03 Jun 2019 10:58:33 +0000 X-IronPort-AV: E=Sophos;i="5.60,546,1549926000"; d="scan'208";a="7665932" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 03 Jun 2019 12:58:11 +0200 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Mon, 03 Jun 2019 12:58:12 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Mon, 03 Jun 2019 12:58:12 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1559559491; x=1591095491; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=ts5LC/RvHzgs2W6xsbaqMxcECartTZCimeTJSzte1xI=; b=geU3Y913XpTWmF+Sa4xYUSpKeGsVtAk0wDtNeV1/ymRejadKSf4WUjrs 103VgINyi/Q0i67fxF1jRzMh9nTQV9aU6/VpR6phZXXEfJKiPyaSlBa7/ 52RMJWKq8B8jFNIRPHzUj9yg7UGgy+UGM7ZB/3RujWqjd5xlGSqyAMCrP saTl8baRYZnb0Sh+5Olvvb0Wimb0ztDudzv/J2PAHR8ff3sssrSw+fPw9 FZv3zKRgYaYGFZ+wC0wRCqElmTxZlq0kJ25zq2zKc/To5UpeTEfuwS/o/ 0hbFiDNgzak/9oW6wfMIjJt7ZfL6/QBhwFjJl7/DWUTrckDvOrxDLiBMF A==; X-IronPort-AV: E=Sophos;i="5.60,546,1549926000"; d="scan'208";a="7665931" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 03 Jun 2019 12:58:11 +0200 Received: from schifferm-ubuntu4.tq-net.de (schifferm-ubuntu4.tq-net.de [10.117.49.26]) by vtuxmail01.tq-net.de (Postfix) with ESMTPA id 801C9280075; Mon, 3 Jun 2019 12:58:15 +0200 (CEST) From: Matthias Schiffer To: Russell King , Jessica Yu Subject: [PATCH modules 1/2] module: allow arch overrides for .exit section names Date: Mon, 3 Jun 2019 12:57:25 +0200 Message-Id: <20190603105726.22436-2-matthias.schiffer@ew.tq-group.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190603105726.22436-1-matthias.schiffer@ew.tq-group.com> References: <20190603105726.22436-1-matthias.schiffer@ew.tq-group.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190603_035831_841821_C9231BC3 X-CRM114-Status: GOOD ( 12.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthias Schiffer , linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Some archs like ARM store unwind information for .exit.text in sections with unusual names. As this unwind information refers to .exit.text, it must not be loaded when .exit.text is not loaded (when CONFIG_MODULE_UNLOAD is unset); otherwise, loading a module can fail due to relocation failures. Signed-off-by: Matthias Schiffer --- include/linux/moduleloader.h | 8 ++++++++ kernel/module.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h index 31013c2effd3..cddbd85fb659 100644 --- a/include/linux/moduleloader.h +++ b/include/linux/moduleloader.h @@ -5,6 +5,7 @@ #include #include +#include /* These may be implemented by architectures that need to hook into the * module loader code. Architectures that don't need to do anything special @@ -93,4 +94,11 @@ void module_arch_freeing_init(struct module *mod); #define MODULE_ALIGN PAGE_SIZE #endif +#ifndef HAVE_ARCH_MODULE_EXIT_SECTION +static inline bool module_exit_section(const char *name) +{ + return strstarts(name, ".exit"); +} +#endif + #endif diff --git a/kernel/module.c b/kernel/module.c index 6e6712b3aaf5..e8e4cd0a471f 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2924,7 +2924,7 @@ static int rewrite_section_headers(struct load_info *info, int flags) #ifndef CONFIG_MODULE_UNLOAD /* Don't load .exit sections */ - if (strstarts(info->secstrings+shdr->sh_name, ".exit")) + if (module_exit_section(info->secstrings+shdr->sh_name)) shdr->sh_flags &= ~(unsigned long)SHF_ALLOC; #endif } From patchwork Mon Jun 3 10:57:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Schiffer X-Patchwork-Id: 10972755 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA64576 for ; Mon, 3 Jun 2019 10:58:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B910428562 for ; Mon, 3 Jun 2019 10:58:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD80D288B8; Mon, 3 Jun 2019 10:58:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5CF0428562 for ; Mon, 3 Jun 2019 10:58:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=vv0hAYbaKMHm/IJVhqKOUZsRncSbEW1cVy2De+brP2U=; b=iGfaFON16bLNRa1KoCLWTuCgfl otIRRb/d8pze7q/ooKjQgDEgXGdx1051+mEdVNCuXnyZVQ++SIjb46mWtRysujhwVpSxPJeJKQRW1 BKqDpCOp4tt1cREXi+KxTVZDojX1/r+l9vrVQ1fHtiecqbkKFM9iyW27UW7xLYmfzuh5aGanFT4kI rdEOaImyR71ECsRn/wuO3zqWGJgTHTMk9xwOjSKB7cvs9uv+bbZqly18RpkT9rlmeqCgJcm05dVzp VFwxvSl3/DJsIATXQ3eYSYcioQ/IgQSJBmJgWUu+DUlHiyyqBga9zcg3xMCS/CaKa843XoQntbHiI uifi4dFg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hXkfw-0004TE-Gi; Mon, 03 Jun 2019 10:58:48 +0000 Received: from mx1.tq-group.com ([62.157.118.193]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hXkfg-00046D-KQ for linux-arm-kernel@lists.infradead.org; Mon, 03 Jun 2019 10:58:35 +0000 X-IronPort-AV: E=Sophos;i="5.60,546,1549926000"; d="scan'208";a="7665934" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 03 Jun 2019 12:58:11 +0200 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Mon, 03 Jun 2019 12:58:12 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Mon, 03 Jun 2019 12:58:12 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1559559491; x=1591095491; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=ZLG5fX7UU9AzbSEEnsbZKEWE/R7gaNCrk+0uE58Tc7U=; b=juhs5WdzDM2DBEOm5b2EiUWdwABpa2u190ZtJk0AJaYgwkmMFUoagyLb nIenGCdGGIsEIOnls41TMpRKSzzsTlbwAQAECSOPkkweWxhP0AA5jKTgz L1JkD36A1oCeKC8Hqo9+RliSfb/JL/voucNluCyaeieWb8dBNvEvmAn3y 9Bwxq2+godqdd72MLGjTE0krX2KjEqQmACYi58KAX/2u1jmeABp1kl2c5 It2a4JBE0yKvS1OLpp60s0hPo+ldTVibgtQDrY2JMRPsK32NBN/0mZesT PcoMs29Z+YJXxpK0H0kLV8OLc1APOwtKprYpEV1rrZW9DzIv7bnqwqrkT g==; X-IronPort-AV: E=Sophos;i="5.60,546,1549926000"; d="scan'208";a="7665933" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 03 Jun 2019 12:58:11 +0200 Received: from schifferm-ubuntu4.tq-net.de (schifferm-ubuntu4.tq-net.de [10.117.49.26]) by vtuxmail01.tq-net.de (Postfix) with ESMTPA id A18CA280077; Mon, 3 Jun 2019 12:58:15 +0200 (CEST) From: Matthias Schiffer To: Russell King , Jessica Yu Subject: [PATCH modules 2/2] ARM: module: recognize unwind exit sections Date: Mon, 3 Jun 2019 12:57:26 +0200 Message-Id: <20190603105726.22436-3-matthias.schiffer@ew.tq-group.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190603105726.22436-1-matthias.schiffer@ew.tq-group.com> References: <20190603105726.22436-1-matthias.schiffer@ew.tq-group.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190603_035833_137204_7A741CE3 X-CRM114-Status: UNSURE ( 9.27 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Matthias Schiffer , linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In addition to the prefix ".exit", ".ARM.extab.exit" and ".ARM.exidx.exit" must be recognizes as exit sections as well. Otherwise, loading modules can fail without CONFIG_MODULE_UNLOAD depending on the memory layout, when relocations for the unwind sections refer to the .exit.text section: imx_sdma: section 16 reloc 0 sym '': relocation 42 out of range (0x7f015260 -> 0xc0f5a5e8) where 0x7F000000 is the module load area and 0xC0000000 is the vmalloc area. Relocation 42 refers to R_ARM_PREL31, which is limited to signed 31bit offsets. Signed-off-by: Matthias Schiffer --- arch/arm/include/asm/module.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/include/asm/module.h b/arch/arm/include/asm/module.h index 182163b55546..f3401758d711 100644 --- a/arch/arm/include/asm/module.h +++ b/arch/arm/include/asm/module.h @@ -4,6 +4,8 @@ #include +#include + struct unwind_table; #ifdef CONFIG_ARM_UNWIND @@ -72,4 +74,13 @@ static inline unsigned long kallsyms_symbol_value(const Elf_Sym *sym) } #endif +#define HAVE_ARCH_MODULE_EXIT_SECTION +static inline bool module_exit_section(const char *name) +{ + return strstarts(name, ".exit") || + strstarts(name, ".ARM.extab.exit") || + strstarts(name, ".ARM.exidx.exit"); + +} + #endif /* _ASM_ARM_MODULE_H */