Ftrace modifies function calls using Int3 breakpoints on x86. The breakpoints are handled only when the patching is in progress. If something goes wrong, there is a recovery code that removes the breakpoints. If this fails, the system might get silently rebooted when a remaining break is not handled or an invalid instruction is proceed.
A better solution is to BUG() when the recovery fails. It helps to point to the sinner responsible for the reboot. Signed-off-by: Petr Mladek <pmla...@suse.cz> --- arch/x86/kernel/ftrace.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index 30d63c4a4195..525a9f954c8b 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c @@ -424,7 +424,7 @@ static int remove_breakpoint(struct dyn_ftrace *rec) /* If this does not have a breakpoint, we are done */ if (ins[0] != BREAKPOINT_INSTRUCTION) - return -1; + return 0; /* Check if it is nop instruction */ valid_ins = ftrace_nop_replace(); @@ -625,8 +625,15 @@ void ftrace_replace_code(int enable) ftrace_bug(ret, rec ? rec->ip : 0); printk(KERN_WARNING "Failed on %s (%d):\n", report, count); for_ftrace_rec_iter(iter) { + int err; + rec = ftrace_rec_iter_record(iter); - remove_breakpoint(rec); + err = remove_breakpoint(rec); + /* + * The breakpoints will not be handled after this function + * finishes. Let's stop on a well defined point. + */ + BUG_ON(err); } } -- 1.8.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/