After having spent some time on a previous question, a user introduced me to an email thread concerning the below issue:
[PATCH] ftrace/x86: Fix function graph tracer reset path
On my system, simply enabling and disabling function graph tracer can
crash the kernel. I don't know how it worked until now.
Themodifies jmp instruction at
assuming it's a 5 bytes near jmp (e9 ).
However it's a short jmp consisting of 2 bytes only (eb ). And
is located just below the
modification above breaks the instruction resulting in kernel oops on
thewith the invalid opcode like below:
diff --git a/arch/x86/kernel/mcount_64.S b/arch/x86/kernel/mcount_64.S
index ed48a9f465f8..e13a695c3084 100644
@@ -182,7 +182,8 @@ GLOBAL(ftrace_graph_call)
+/* This is weak to keep gas from relaxing the jumps */
ftrace_stub is defined in the current file, the assembler knows the distance and can use the shorter version of
jmp that only has limited range.
If it's changed to
weak that means the symbol might not resolve to the one in the current file, as other module may override it. The offset to that potential override is not known, hence the assembler must use the full range
jmp which is what the patching code expects.