Skip to content

Commit c5d641f

Browse files
libin2015rostedt
authored andcommitted
x86: ftrace: Fix the comments for ftrace_modify_code_direct()
There is no need to worry about module and __init text disappearing case, because that ftrace has a module notifier that is called when a module is being unloaded and before the text goes away and this code grabs the ftrace_lock mutex and removes the module functions from the ftrace list, such that it will no longer do any modifications to that module's text, the update to make functions be traced or not is done under the ftrace_lock mutex as well. And by now, __init section codes should not been modified by ftrace, because it is black listed in recordmcount.c and ignored by ftrace. Link: http://lkml.kernel.org/r/[email protected] Reviewed-by: Thomas Gleixner <[email protected]> Suggested-by: Steven Rostedt <[email protected]> Signed-off-by: Li Bin <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
1 parent 05a724b commit c5d641f

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

arch/x86/kernel/ftrace.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,11 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
108108
ftrace_expected = old_code;
109109

110110
/*
111-
* Note: Due to modules and __init, code can
112-
* disappear and change, we need to protect against faulting
113-
* as well as code changing. We do this by using the
114-
* probe_kernel_* functions.
115-
*
116-
* No real locking needed, this code is run through
117-
* kstop_machine, or before SMP starts.
111+
* Note:
112+
* We are paranoid about modifying text, as if a bug was to happen, it
113+
* could cause us to read or write to someplace that could cause harm.
114+
* Carefully read and modify the code with probe_kernel_*(), and make
115+
* sure what we read is what we expected it to be before modifying it.
118116
*/
119117

120118
/* read the text we want to modify */

0 commit comments

Comments
 (0)