Star64_linux/arch/arm64
James Morse 4ed10d371b arm64: module: Use module_init_layout_section() to spot init sections
commit f928f8b1a2 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 <adam.johnston@arm.com>
Tested-by: Adam Johnston <adam.johnston@arm.com>
Fixes: 055f23b74b ("module: check for exit sections in layout_sections() instead of module_init_section()")
Cc: <stable@vger.kernel.org> # 5.15.x: 60a0aab746 arm64: module-plts: inline linux/moduleloader.h
Cc: <stable@vger.kernel.org> # 5.15.x
Signed-off-by: James Morse <james.morse@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-09-05 01:25:15 +08:00
..
boot arm64: dts: rockchip: Disable HS400 for eMMC on ROCK Pi 4 2023-08-28 23:27:05 +08:00
configs arm64: defconfig: build imx-sdma as a module 2023-04-19 17:47:20 +08:00
crypto crypto: arm64/gcm - Select AEAD for GHASH_ARM64_CE 2023-04-19 17:52:22 +08:00
hyperv arm64: hyperv: Initialize hypervisor on boot 2021-08-04 16:54:36 +00:00
include arm64: errata: Add workaround for TSB flush failures 2023-08-20 16:01:30 +08:00
kernel arm64: module: Use module_init_layout_section() to spot init sections 2023-09-05 01:25:15 +08:00
kvm KVM: arm64: Fix buffer overflow in kvm_arm_set_fw_reg() 2023-06-06 18:07:05 +08:00
lib arm64: mte: DC {GVA,GZVA} shouldn't be used when DCZID_EL0.DZP == 1 2023-04-19 17:43:59 +08:00
mm arm64/mm: mark private VM_FAULT_X defines as vm_fault_t 2023-08-20 15:21:06 +08:00
net bpf, arm64: Use emit_addr_mov_i64() for BPF_PSEUDO_FUNC 2023-04-19 17:51:01 +08:00
tools arm64: errata: Add detection for TRBE write to out-of-range 2023-08-20 16:01:31 +08:00
xen
Kbuild arm64: hyperv: Add Hyper-V hypercall and register access utilities 2021-08-04 16:54:36 +00:00
Kconfig arm64: errata: Add detection for TRBE write to out-of-range 2023-08-20 16:01:31 +08:00
Kconfig.debug
Kconfig.platforms irqchip/exiu: Fix acknowledgment of edge triggered interrupts 2023-04-19 17:49:39 +08:00
Makefile arm64 updates for 5.15: 2021-09-01 15:04:29 -07:00