Re: [PATCH 2/3] arm64: patching: Fix instruction byte order in aarch64_insn_set()

From: Rui Qi

Date: Fri Oct 16 2026 - 02:23:37 EST


On 10/16/26 12:57 AM, Catalin Marinas wrote:
> On Sat, Oct 10, 2026 at 04:50:54PM +0800, Rui Qi wrote:
>> aarch64_insn_set() passes the host-endian u32 instruction straight to
>> text_poke_memset(), which memset32()'s it into memory in host byte order.
>> AArch64 instructions must be little-endian in memory, so on a big-endian
>> kernel the written bytes are reversed and the CPU takes an UNDEFINED
>> instruction exception when fetching them. The sibling aarch64_insn_write()
>> already converts with cpu_to_le32(); aarch64_insn_set() does not.
>>
>> This is reachable in-tree: bpf_arch_text_invalidate() fills freed JIT
>> regions with AARCH64_BREAK_FAULT through aarch64_insn_set(), and arm64
>> selects HAVE_EBPF_JIT without a big-endian guard, so the path is taken on
>> BE kernels with BPF JIT. The direct-fill loop in the same file already
>> cpu_to_le32()'s the constant, confirming the expected byte order.
>>
>> Convert the instruction to little-endian before the memset, mirroring
>> aarch64_insn_write(). On LE the conversion is a no-op, so behaviour is
>> unchanged.
>
> We are just about to remove big-endian support (in 7.4).
>

Thanks for the heads-up.

I'm fine with dropping the big-endian-specific patches for mainline if
arm64 BE support is going away. The remaining patch, however, is not
related to BE: patch 3/3 fixes late PLT/veneer emission into a ROX
module .plt section in the livepatch/module relocation path.

Could you please review that one separately?

Thanks,
Rui