Re: [PATCH] ftrace: Remove possible deadlock between register_kprobe() and ftrace_run_update_code()

From: Thomas Gleixner
Date: Thu Jun 27 2019 - 18:18:42 EST


On Thu, 27 Jun 2019, Petr Mladek wrote:
> Fortunately, the problematic fix is needed only on x86_64. It is
> the only architecture that calls set_all_modules_text_rw()
> in ftrace path and supports livepatching at the same time.
>
> Therefore it is enough to move text_mutex handling from the generic
> kernel/trace/ftrace.c into arch/x86/kernel/ftrace.c:
>
> ftrace_arch_code_modify_prepare()
> ftrace_arch_code_modify_post_process()
>
> This patch basically reverts the ftrace part of the problematic

^^^^^^^^^ Sigh

> commit 9f255b632bf12c4dd7 ("module: Fix livepatch/ftrace module
> text permissions race"). And provides x86_64 specific-fix.
>
> Some refactoring of the ftrace code will be needed when livepatching
> is implemented for arm or nds32. These architectures call
> set_all_modules_text_rw() and use stop_machine() at the same time.
>
> Fixes: 9f255b632bf12c4dd7 ("module: Fix livepatch/ftrace module text permissions race")
> Signed-off-by: Petr Mladek <pmladek@xxxxxxxx>

Acked-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>