From bfff915c97d548cdaba471eb0c87ffad42ad0e21 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 16 Nov 2024 10:14:15 +0000 Subject: [PATCH] Revert "arm64: probes: Fix uprobes for big-endian kernels" This reverts commit 14841bb7a531b96e2dde37423a3b33e75147c60d 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: I3e6141d5184c37814b1ea62f3e2966e97e3e3932 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 a2f137a595fc..d49aef2657cd 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)