On Thu, 13 Jun 2019 20:07:22 -0500 Josh Poimboeuf <jpoimboe@xxxxxxxxxx> wrote: > It's possible for livepatch and ftrace to be toggling a module's text > permissions at the same time, resulting in the following panic: > [..] > The above panic occurs when loading two modules at the same time with > ftrace enabled, where at least one of the modules is a livepatch module: > > CPU0 CPU1 > klp_enable_patch() > klp_init_object_loaded() > module_disable_ro() > ftrace_module_enable() > ftrace_arch_code_modify_post_process() > set_all_modules_text_ro() > klp_write_object_relocations() > apply_relocate_add() > *patches read-only code* - BOOM > > A similar race exists when toggling ftrace while loading a livepatch > module. > > Fix it by ensuring that the livepatch and ftrace code patching > operations -- and their respective permissions changes -- are protected > by the text_mutex. > > Reported-by: Johannes Erdfelt <johannes@xxxxxxxxxxx> > Fixes: 444d13ff10fb ("modules: add ro_after_init support") > Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx> > Acked-by: Jessica Yu <jeyu@xxxxxxxxxx> > Reviewed-by: Petr Mladek <pmladek@xxxxxxxx> > Reviewed-by: Miroslav Benes <mbenes@xxxxxxx> This patch looks uncontroversial. I'm going to pull this one in and start testing it. And if it works, I'll push to Linus. -- Steve