From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Edward Humes <aurxenon@lunos.org>,
Matt Turner <mattst88@gmail.com>, Sasha Levin <sashal@kernel.org>,
richard.henderson@linaro.org, ink@jurassic.park.msu.ru,
linux-alpha@vger.kernel.org
Subject: [PATCH AUTOSEL 6.2 13/16] alpha: fix R_ALPHA_LITERAL reloc for large modules
Date: Sun, 5 Mar 2023 08:52:04 -0500 [thread overview]
Message-ID: <20230305135207.1793266-13-sashal@kernel.org> (raw)
In-Reply-To: <20230305135207.1793266-1-sashal@kernel.org>
From: Edward Humes <aurxenon@lunos.org>
[ Upstream commit b6b17a8b3ecd878d98d5472a9023ede9e669ca72 ]
Previously, R_ALPHA_LITERAL relocations would overflow for large kernel
modules.
This was because the Alpha's apply_relocate_add was relying on the kernel's
module loader to have sorted the GOT towards the very end of the module as it
was mapped into memory in order to correctly assign the global pointer. While
this behavior would mostly work fine for small kernel modules, this approach
would overflow on kernel modules with large GOT's since the global pointer
would be very far away from the GOT, and thus, certain entries would be out of
range.
This patch fixes this by instead using the Tru64 behavior of assigning the
global pointer to be 32KB away from the start of the GOT. The change made
in this patch won't work for multi-GOT kernel modules as it makes the
assumption the module only has one GOT located at the beginning of .got,
although for the vast majority kernel modules, this should be fine. Of the
kernel modules that would previously result in a relocation error, none of
them, even modules like nouveau, have even come close to filling up a single
GOT, and they've all worked fine under this patch.
Signed-off-by: Edward Humes <aurxenon@lunos.org>
Signed-off-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/alpha/kernel/module.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
index 5b60c248de9ea..cbefa5a773846 100644
--- a/arch/alpha/kernel/module.c
+++ b/arch/alpha/kernel/module.c
@@ -146,10 +146,8 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
base = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr;
symtab = (Elf64_Sym *)sechdrs[symindex].sh_addr;
- /* The small sections were sorted to the end of the segment.
- The following should definitely cover them. */
- gp = (u64)me->core_layout.base + me->core_layout.size - 0x8000;
got = sechdrs[me->arch.gotsecindex].sh_addr;
+ gp = got + 0x8000;
for (i = 0; i < n; i++) {
unsigned long r_sym = ELF64_R_SYM (rela[i].r_info);
--
2.39.2
next prev parent reply other threads:[~2023-03-05 13:53 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-05 13:51 [PATCH AUTOSEL 6.2 01/16] clk: qcom: mmcc-apq8084: remove spdm clocks Sasha Levin
2023-03-05 13:51 ` [PATCH AUTOSEL 6.2 02/16] MIPS: Fix a compilation issue Sasha Levin
2023-03-05 13:51 ` [PATCH AUTOSEL 6.2 03/16] powerpc: Check !irq instead of irq == NO_IRQ and remove NO_IRQ Sasha Levin
2023-03-05 13:51 ` [PATCH AUTOSEL 6.2 04/16] powerpc/64: Don't recurse irq replay Sasha Levin
2023-03-05 13:51 ` [PATCH AUTOSEL 6.2 05/16] s390/virtio: sort out physical vs virtual pointers usage Sasha Levin
2023-03-06 10:26 ` Nico Boehr
2023-03-14 17:26 ` Sasha Levin
2023-03-05 13:51 ` [PATCH AUTOSEL 6.2 06/16] powerpc/iommu: fix memory leak with using debugfs_lookup() Sasha Levin
2023-03-05 13:51 ` [PATCH AUTOSEL 6.2 07/16] clk: renesas: rcar-gen3: Disable R-Car H3 ES1.* Sasha Levin
2023-03-05 13:59 ` Geert Uytterhoeven
2023-03-14 17:42 ` Sasha Levin
2023-03-05 13:51 ` [PATCH AUTOSEL 6.2 08/16] powerpc: Remove __kernel_text_address() in show_instructions() Sasha Levin
2023-03-05 13:52 ` [PATCH AUTOSEL 6.2 09/16] powerpc/bpf/32: Only set a stack frame when necessary Sasha Levin
2023-03-05 13:52 ` [PATCH AUTOSEL 6.2 10/16] powerpc/64: Fix task_cpu in early boot when booting non-zero cpuid Sasha Levin
2023-03-05 13:52 ` [PATCH AUTOSEL 6.2 11/16] powerpc/64: Move paca allocation to early_setup() Sasha Levin
2023-03-05 13:52 ` [PATCH AUTOSEL 6.2 12/16] powerpc/kcsan: Exclude udelay to prevent recursive instrumentation Sasha Levin
2023-03-05 13:52 ` Sasha Levin [this message]
2023-03-05 13:52 ` [PATCH AUTOSEL 6.2 14/16] macintosh: windfarm: Use unsigned type for 1-bit bitfields Sasha Levin
2023-03-05 13:52 ` [PATCH AUTOSEL 6.2 15/16] PCI: Add SolidRun vendor ID Sasha Levin
2023-03-05 13:52 ` [PATCH AUTOSEL 6.2 16/16] PCI: Avoid FLR for SolidRun SNET DPU rev 1 Sasha Levin
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=20230305135207.1793266-13-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=aurxenon@lunos.org \
--cc=ink@jurassic.park.msu.ru \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mattst88@gmail.com \
--cc=richard.henderson@linaro.org \
--cc=stable@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox