summaryrefslogtreecommitdiff
path: root/arch/powerpc/kernel/uprobes.c
diff options
context:
space:
mode:
authorChristophe Leroy <christophe.leroy@csgroup.eu>2021-05-20 16:50:42 +0300
committerMichael Ellerman <mpe@ellerman.id.au>2021-06-16 16:35:57 +0300
commit18c85964b10b7b78a5cb59a4959a5f82fdc77e4c (patch)
tree95bc35968815c5c3cebab5105a7f004c06489b2d /arch/powerpc/kernel/uprobes.c
parent036b5560bebc72c61d955ae0b115e8e69da8a563 (diff)
downloadlinux-18c85964b10b7b78a5cb59a4959a5f82fdc77e4c.tar.xz
powerpc: Do not dereference code as 'struct ppc_inst' (uprobe, code-patching, feature-fixups)
'struct ppc_inst' is an internal structure to represent an instruction, it is not directly the representation of that instruction in text code. It is not meant to map and dereference code. Dereferencing code directly through 'struct ppc_inst' has two main issues: - On powerpc, structs are expected to be 8 bytes aligned while code is spread every 4 byte. - Should a non prefixed instruction lie at the end of the page and the following page not be mapped, it would generate a page fault. In-memory code must be accessed with ppc_inst_read(). Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/c9a1201dd0a66b4a0f91f0fb46d9385cbf030feb.1621516826.git.christophe.leroy@csgroup.eu
Diffstat (limited to 'arch/powerpc/kernel/uprobes.c')
-rw-r--r--arch/powerpc/kernel/uprobes.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/powerpc/kernel/uprobes.c b/arch/powerpc/kernel/uprobes.c
index 186f69b11e94..46971bb41d05 100644
--- a/arch/powerpc/kernel/uprobes.c
+++ b/arch/powerpc/kernel/uprobes.c
@@ -42,7 +42,7 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe,
return -EINVAL;
if (cpu_has_feature(CPU_FTR_ARCH_31) &&
- ppc_inst_prefixed(auprobe->insn) &&
+ ppc_inst_prefixed(ppc_inst_read(&auprobe->insn)) &&
(addr & 0x3f) == 60) {
pr_info_ratelimited("Cannot register a uprobe on 64 byte unaligned prefixed instruction\n");
return -EINVAL;