File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 3030#include <linux/elf.h>
3131#include <linux/moduleloader.h>
3232#include <linux/completion.h>
33+ #include <linux/memory.h>
3334#include <asm/cacheflush.h>
3435#include "core.h"
3536#include "patch.h"
@@ -730,16 +731,21 @@ static int klp_init_object_loaded(struct klp_patch *patch,
730731 struct klp_func * func ;
731732 int ret ;
732733
734+ mutex_lock (& text_mutex );
735+
733736 module_disable_ro (patch -> mod );
734737 ret = klp_write_object_relocations (patch -> mod , obj );
735738 if (ret ) {
736739 module_enable_ro (patch -> mod , true);
740+ mutex_unlock (& text_mutex );
737741 return ret ;
738742 }
739743
740744 arch_klp_init_object_loaded (patch , obj );
741745 module_enable_ro (patch -> mod , true);
742746
747+ mutex_unlock (& text_mutex );
748+
743749 klp_for_each_func (obj , func ) {
744750 ret = klp_find_object_symbol (obj -> name , func -> old_name ,
745751 func -> old_sympos ,
Original file line number Diff line number Diff line change 3434#include <linux/hash.h>
3535#include <linux/rcupdate.h>
3636#include <linux/kprobes.h>
37+ #include <linux/memory.h>
3738
3839#include <trace/events/sched.h>
3940
@@ -2610,10 +2611,12 @@ static void ftrace_run_update_code(int command)
26102611{
26112612 int ret ;
26122613
2614+ mutex_lock (& text_mutex );
2615+
26132616 ret = ftrace_arch_code_modify_prepare ();
26142617 FTRACE_WARN_ON (ret );
26152618 if (ret )
2616- return ;
2619+ goto out_unlock ;
26172620
26182621 /*
26192622 * By default we use stop_machine() to modify the code.
@@ -2625,6 +2628,9 @@ static void ftrace_run_update_code(int command)
26252628
26262629 ret = ftrace_arch_code_modify_post_process ();
26272630 FTRACE_WARN_ON (ret );
2631+
2632+ out_unlock :
2633+ mutex_unlock (& text_mutex );
26282634}
26292635
26302636static void ftrace_run_modify_code (struct ftrace_ops * ops , int command ,
@@ -5775,6 +5781,7 @@ void ftrace_module_enable(struct module *mod)
57755781 struct ftrace_page * pg ;
57765782
57775783 mutex_lock (& ftrace_lock );
5784+ mutex_lock (& text_mutex );
57785785
57795786 if (ftrace_disabled )
57805787 goto out_unlock ;
@@ -5836,6 +5843,7 @@ void ftrace_module_enable(struct module *mod)
58365843 ftrace_arch_code_modify_post_process ();
58375844
58385845 out_unlock :
5846+ mutex_unlock (& text_mutex );
58395847 mutex_unlock (& ftrace_lock );
58405848
58415849 process_cached_mods (mod -> name );
You can’t perform that action at this time.
0 commit comments