From: "Rui Qi" <qirui.001@bytedance.com>
To: <catalin.marinas@arm.com>, <will@kernel.org>
Cc: <mark.rutland@arm.com>, <ardb@kernel.org>, <song@kernel.org>,
<dylanbhatch@google.com>, <linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
"Rui Qi" <qirui.001@bytedance.com>, <stable@vger.kernel.org>
Subject: [PATCH 1/3] arm64/module: Fix big-endian breakage in late data relocations
Date: Sat, 10 Oct 2026 16:47:19 +0800 [thread overview]
Message-ID: <20261010084721.2197683-2-qirui.001@bytedance.com> (raw)
In-Reply-To: <20261010084721.2197683-1-qirui.001@bytedance.com>
The WRITE_PLACE macro declares its temporary value with the type of the
source argument:
__typeof__(val) __val = (val);
For the 16-bit and 32-bit data relocations in reloc_data(), val is the
s64 result of do_reloc(), so __val is an 8-byte integer. When the
module is already loaded (state != MODULE_STATE_UNFORMED), the macro
hands the address of __val to aarch64_insn_copy() and asks it to copy
only sizeof(*place) -- 2 or 4 -- bytes.
aarch64_insn_copy() performs a raw byte copy with no endian conversion.
On a big-endian kernel the most significant bytes of the s64 sit at the
lowest address, so copying only the first 2/4 bytes grabs the
sign-extension upper half instead of the computed relocation value,
corrupting the patched location. The UNFORMED direct-assignment path
is unaffected because the compiler narrows the s64 to the destination
type.
Type the temporary after the destination element instead.
Fixes: 91b89a634487d5614e51ee773a889ed57f5551ca ("arm64/module: Use text-poke API for late relocations.")
Cc: stable@vger.kernel.org
Signed-off-by: Rui Qi <qirui.001@bytedance.com>
---
arch/arm64/kernel/module.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/module.c b/arch/arm64/kernel/module.c
index 24adb581af0e..0fdf4c1c4e05 100644
--- a/arch/arm64/kernel/module.c
+++ b/arch/arm64/kernel/module.c
@@ -50,7 +50,7 @@ static u64 do_reloc(enum aarch64_reloc_op reloc_op, __le32 *place, u64 val)
}
#define WRITE_PLACE(place, val, mod) do { \
- __typeof__(val) __val = (val); \
+ __typeof__(*place) __val = (val); \
\
if (mod->state == MODULE_STATE_UNFORMED) \
*(place) = __val; \
--
2.20.1
next prev parent reply other threads:[~2026-10-10 8:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-10 8:47 [PATCH 0/3] arm64: Fix text-poke byte-order and late PLT/veneer ROX handling Rui Qi
2026-10-10 8:47 ` Rui Qi [this message]
2026-10-10 8:50 ` [PATCH 2/3] arm64: patching: Fix instruction byte order in aarch64_insn_set() Rui Qi
2026-10-10 8:50 ` [PATCH 3/3] arm64: module: Use text-poke for late PLT/veneer emission Rui Qi
2026-10-15 16:57 ` [PATCH 2/3] arm64: patching: Fix instruction byte order in aarch64_insn_set() Catalin Marinas
2026-10-16 6:18 ` Rui Qi
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=20261010084721.2197683-2-qirui.001@bytedance.com \
--to=qirui.001@bytedance.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=dylanbhatch@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=song@kernel.org \
--cc=stable@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®