Skip to contentSkip to conversation

Fix: arm: kprobes: optimized kprobes illegal instruction

PATCH In review Mathieu Desnoyers 2 participants 3 messages Feb 4, 2019 – Feb 5, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix: arm: kprobes: optimized kprobes illegal instruction

commit e46daee53bb5 "ARM: 8806/1: kprobes: Fix false positive with FORTIFY_SOURCE" introduced a regression in optimized kprobes. It triggers "invalid instruction" oopses when using kprobes instrumentation through lttng and perf. This commit was introduced in kernel v4.20, and has been backported to stable kernels 4.19 and 4.14.

This crash was also reported by Hongzhi Song on the redhat bugzilla where the patch was originally introduced.

---
 arch/arm/probes/kprobes/opt-arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/probes/kprobes/opt-arm.c +1 -1
index 2c118a6ab358..0dc23fc227ed 100644
@@ -247,7 +247,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *or
 	}
 
 	/* Copy arch-dep-instance from template. */
-	memcpy(code, (unsigned char *)optprobe_template_entry,
+	memcpy(code, (unsigned long *)&optprobe_template_entry,
 			TMPL_END_IDX * sizeof(kprobe_opcode_t));
 
 	/* Adjust buffer according to instruction. */
Signature · 1 line
2.11.0
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Mathieu Desnoyers

commit e46daee53bb5 "ARM: 8806/1: kprobes: Fix false positive with FORTIFY_SOURCE" introduced a regression in optimized kprobes. It triggers "invalid instruction" oopses when using kprobes instrumentation through lttng and perf. This commit was introduced in kernel v4.20, and has been backported to stable kernels 4.19 and 4.14.

This crash was also reported by Hongzhi Song on the redhat bugzilla where the patch was originally introduced.

Ew, yes. Thanks for catching this.

Fixes e46daee53bb5 ("ARM: 8806/1: kprobes: Fix false positive with

FORTIFY_SOURCE")

Can you send this to the ARM patch tracker, please?

-Kees

Quoted 34 lines
---
 arch/arm/probes/kprobes/opt-arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/probes/kprobes/opt-arm.c +1 -2
index 2c118a6ab358..0dc23fc227ed 100644
@@ -247,7 +247,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe *op, struct kprobe *or
        }
 
        /* Copy arch-dep-instance from template. */
-       memcpy(code, (unsigned char *)optprobe_template_entry,
+       memcpy(code, (unsigned long *)&optprobe_template_entry,
                        TMPL_END_IDX * sizeof(kprobe_opcode_t));
 
        /* Adjust buffer according to instruction. */
--

2.11.0

Signature · 1 line
Kees Cook
#2 lore raw
Quoted 13 lines · ----- On Feb 5, 2019, at 10:04 AM, Kees Cook [email protected] wrote:
Quoted 10 lines · Mathieu Desnoyers

commit e46daee53bb5 "ARM: 8806/1: kprobes: Fix false positive with FORTIFY_SOURCE"
introduced a regression in optimized kprobes. It triggers "invalid instruction" oopses when using kprobes instrumentation through lttng and perf. This commit was introduced in kernel v4.20, and has been backported to stable kernels 4.19 and 4.14.

This crash was also reported by Hongzhi Song on the redhat bugzilla where the patch was originally introduced.

Quoted 7 lines

Ew, yes. Thanks for catching this.

Fixes e46daee53bb5 ("ARM: 8806/1: kprobes: Fix false positive with

FORTIFY_SOURCE")

Can you send this to the ARM patch tracker, please?

Sure, will do right away,

Thanks!

Mathieu

Quoted 44 lines

-Kees

Quoted 34 lines

Link:
https://lore.kernel.org/lkml/[email protected]

CC Robert Berger <[email protected]>
CC Masami Hiramatsu <[email protected]>
CC William Cohen <[email protected]>
CC Laura Abbott <[email protected]>
CC Kees Cook <[email protected]>
CC Russell King <[email protected]>
CC <[email protected]> # v4.14+
---
 arch/arm/probes/kprobes/opt-arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/probes/kprobes/opt-arm.c +1 -1
index 2c118a6ab358..0dc23fc227ed 100644
@@ -247,7 +247,7 @@ int arch_prepare_optimized_kprobe(struct optimized_kprobe
 *op, struct kprobe *or
        }
 
        /* Copy arch-dep-instance from template. */
-       memcpy(code, (unsigned char *)optprobe_template_entry,
+       memcpy(code, (unsigned long *)&optprobe_template_entry,
                        TMPL_END_IDX * sizeof(kprobe_opcode_t));
 
        /* Adjust buffer according to instruction. */
Quoted 3 lines

--
2.11.0

--
Kees Cook

Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com