From ea0c15ec5ed89875c0f7a1c13c62c9e4909d36b9 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 31 Aug 2023 09:18:33 +0200 Subject: [PATCH] 5.4-stable patches added patches: arm64-module-use-module_init_layout_section-to-spot-init-sections.patch --- ...layout_section-to-spot-init-sections.patch | 72 +++++++++++++++++++ queue-5.4/series | 1 + 2 files changed, 73 insertions(+) create mode 100644 queue-5.4/arm64-module-use-module_init_layout_section-to-spot-init-sections.patch diff --git a/queue-5.4/arm64-module-use-module_init_layout_section-to-spot-init-sections.patch b/queue-5.4/arm64-module-use-module_init_layout_section-to-spot-init-sections.patch new file mode 100644 index 00000000000..c62de364809 --- /dev/null +++ b/queue-5.4/arm64-module-use-module_init_layout_section-to-spot-init-sections.patch @@ -0,0 +1,72 @@ +From f928f8b1a2496e7af95b860f9acf553f20f68f16 Mon Sep 17 00:00:00 2001 +From: James Morse +Date: Tue, 1 Aug 2023 14:54:08 +0000 +Subject: arm64: module: Use module_init_layout_section() to spot init sections + +From: James Morse + +commit f928f8b1a2496e7af95b860f9acf553f20f68f16 upstream. + +Today module_frob_arch_sections() spots init sections from their +'init' prefix, and uses this to keep the init PLTs separate from the rest. + +module_emit_plt_entry() 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. + +This results in the following: +| WARNING: CPU: 2 PID: 51 at arch/arm64/kernel/module-plts.c:99 module_emit_plt_entry+0x184/0x1cc +| Modules linked in: crct10dif_common +| CPU: 2 PID: 51 Comm: modprobe Not tainted 6.5.0-rc4-yocto-standard-dirty #15208 +| Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015 +| pstate: 20400005 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) +| pc : module_emit_plt_entry+0x184/0x1cc +| lr : module_emit_plt_entry+0x94/0x1cc +| sp : ffffffc0803bba60 +[...] +| Call trace: +| module_emit_plt_entry+0x184/0x1cc +| apply_relocate_add+0x2bc/0x8e4 +| load_module+0xe34/0x1bd4 +| init_module_from_file+0x84/0xc0 +| __arm64_sys_finit_module+0x1b8/0x27c +| invoke_syscall.constprop.0+0x5c/0x104 +| do_el0_svc+0x58/0x160 +| el0_svc+0x38/0x110 +| el0t_64_sync_handler+0xc0/0xc4 +| el0t_64_sync+0x190/0x194 + +A previous patch exposed module_init_layout_section(), use that so the +logic is the same. + +Reported-by: Adam Johnston +Tested-by: Adam Johnston +Fixes: 055f23b74b20 ("module: check for exit sections in layout_sections() instead of module_init_section()") +Cc: # 5.15.x: 60a0aab7463ee69 arm64: module-plts: inline linux/moduleloader.h +Cc: # 5.15.x +Signed-off-by: James Morse +Acked-by: Catalin Marinas +Signed-off-by: Luis Chamberlain +Signed-off-by: Greg Kroah-Hartman +--- + arch/arm64/kernel/module-plts.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/arch/arm64/kernel/module-plts.c ++++ b/arch/arm64/kernel/module-plts.c +@@ -301,7 +301,7 @@ int module_frob_arch_sections(Elf_Ehdr * + /* sort by type, symbol index and addend */ + sort(rels, numrels, sizeof(Elf64_Rela), cmp_rela, NULL); + +- if (!str_has_prefix(secstrings + dstsec->sh_name, ".init")) ++ if (!module_init_layout_section(secstrings + dstsec->sh_name)) + core_plts += count_plts(syms, rels, numrels, + sechdrs[i].sh_info, dstsec); + else diff --git a/queue-5.4/series b/queue-5.4/series index 58504703bbe..c53d4f0d4bc 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -1,2 +1,3 @@ powerpc-pmac-smp-avoid-unused-variable-warnings.patch powerpc-pmac-smp-drop-unnecessary-volatile-qualifier.patch +arm64-module-use-module_init_layout_section-to-spot-init-sections.patch -- 2.47.3