From 9d6ed89ef0bb3251dc90e3c633744b376c5ba165 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 9 Nov 2024 14:32:27 +0000 Subject: [PATCH] Revert "arm64: probes: Fix uprobes for big-endian kernels" This reverts commit e6ab336213918575124d6db43dc5d3554526242e which is commit 13f8f1e05f1dc36dbba6cba0ae03354c0dafcde7 upstream. It breaks the Android kernel abi and can be brought back in the future in an abi-safe way if it is really needed. Bug: 161946584 Change-Id: Iddbda00bfb1246f4ddf99af31d251287784ec5b7 Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/uprobes.h | 8 +++++--- arch/arm64/kernel/probes/uprobes.c | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/uprobes.h b/arch/arm64/include/asm/uprobes.h index 98f29a43bfe8..ba4bff5ca674 100644 --- a/arch/arm64/include/asm/uprobes.h +++ b/arch/arm64/include/asm/uprobes.h @@ -10,9 +10,11 @@ #include #include +#define MAX_UINSN_BYTES AARCH64_INSN_SIZE + #define UPROBE_SWBP_INSN cpu_to_le32(BRK64_OPCODE_UPROBES) #define UPROBE_SWBP_INSN_SIZE AARCH64_INSN_SIZE -#define UPROBE_XOL_SLOT_BYTES AARCH64_INSN_SIZE +#define UPROBE_XOL_SLOT_BYTES MAX_UINSN_BYTES typedef u32 uprobe_opcode_t; @@ -21,8 +23,8 @@ struct arch_uprobe_task { struct arch_uprobe { union { - __le32 insn; - __le32 ixol; + u8 insn[MAX_UINSN_BYTES]; + u8 ixol[MAX_UINSN_BYTES]; }; struct arch_probe_insn api; bool simulate; diff --git a/arch/arm64/kernel/probes/uprobes.c b/arch/arm64/kernel/probes/uprobes.c index 8a02c549e57f..2c247634552b 100644 --- a/arch/arm64/kernel/probes/uprobes.c +++ b/arch/arm64/kernel/probes/uprobes.c @@ -42,7 +42,7 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, else if (!IS_ALIGNED(addr, AARCH64_INSN_SIZE)) return -EINVAL; - insn = le32_to_cpu(auprobe->insn); + insn = *(probe_opcode_t *)(&auprobe->insn[0]); switch (arm_probe_decode_insn(insn, &auprobe->api)) { case INSN_REJECTED: @@ -108,7 +108,7 @@ bool arch_uprobe_skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs) if (!auprobe->simulate) return false; - insn = le32_to_cpu(auprobe->insn); + insn = *(probe_opcode_t *)(&auprobe->insn[0]); addr = instruction_pointer(regs); if (auprobe->api.handler)