All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: linux-modules@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: Luis Chamberlain <mcgrof@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Russell King <linux@armlinux.org.uk>,
	Russell King <rmk+kernel@armlinux.org.uk>,
	Jessica Yu <jeyu@kernel.org>,
	james.morse@arm.com, Adam Johnston <adam.johnston@arm.com>
Subject: [PATCH 3/3] ARM: module: Use module_init_layout_section() to spot init sections
Date: Tue,  1 Aug 2023 14:54:09 +0000	[thread overview]
Message-ID: <20230801145409.8935-4-james.morse@arm.com> (raw)
In-Reply-To: <20230801145409.8935-1-james.morse@arm.com>

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 <james.morse@arm.com>
---
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
-- 
2.39.2


WARNING: multiple messages have this Message-ID (diff)
From: James Morse <james.morse@arm.com>
To: linux-modules@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Cc: Luis Chamberlain <mcgrof@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Russell King <linux@armlinux.org.uk>,
	Russell King <rmk+kernel@armlinux.org.uk>,
	Jessica Yu <jeyu@kernel.org>,
	james.morse@arm.com, Adam Johnston <adam.johnston@arm.com>
Subject: [PATCH 3/3] ARM: module: Use module_init_layout_section() to spot init sections
Date: Tue,  1 Aug 2023 14:54:09 +0000	[thread overview]
Message-ID: <20230801145409.8935-4-james.morse@arm.com> (raw)
In-Reply-To: <20230801145409.8935-1-james.morse@arm.com>

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 <james.morse@arm.com>
---
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
-- 
2.39.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2023-08-01 14:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-01 14:54 [PATCH 0/3] ARM/arm64: Fix loading of modules with an exit section James Morse
2023-08-01 14:54 ` James Morse
2023-08-01 14:54 ` [PATCH 1/3] module: Expose module_init_layout_section() James Morse
2023-08-01 14:54   ` James Morse
2023-08-01 14:54 ` [PATCH 2/3] arm64: module: Use module_init_layout_section() to spot init sections James Morse
2023-08-01 14:54   ` James Morse
2023-08-02 17:00   ` Catalin Marinas
2023-08-02 17:00     ` Catalin Marinas
2023-08-01 14:54 ` James Morse [this message]
2023-08-01 14:54   ` [PATCH 3/3] ARM: " James Morse
2023-08-01 17:14 ` [PATCH 0/3] ARM/arm64: Fix loading of modules with an exit section Luis Chamberlain
2023-08-01 17:14   ` Luis Chamberlain
2023-08-02 16:28   ` James Morse
2023-08-02 16:28     ` James Morse
2023-08-03 10:20     ` Russell King (Oracle)
2023-08-03 10:20       ` Russell King (Oracle)
2023-08-03 20:43       ` Luis Chamberlain
2023-08-03 20:43         ` Luis Chamberlain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230801145409.8935-4-james.morse@arm.com \
    --to=james.morse@arm.com \
    --cc=adam.johnston@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=jeyu@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mcgrof@kernel.org \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.