lkml.org 
[lkml]   [2022]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v6] ftrace: Add FTRACE_MCOUNT_MAX_OFFSET to avoid adding weak function
On Fri, 27 May 2022 23:40:03 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> @@ -6830,6 +6960,10 @@ void ftrace_module_enable(struct module *mod)
> if (ftrace_start_up)
> cnt += referenced_filters(rec);
>
> + /* Weak functions should still be ignored */
> + if (!test_for_valid_rec(rec))
> + continue;

This also needs to clear the other flags.

As this is for module load, it does a two stage setup. That is to make the
correct state of the ftrace locations in the module. As the updates to NOP
is done before the text is set to RO, and if tracing is enabled/disabled
during this time, it will trigger a BUG as it detects executable code
running in RW text. To solve that, the initial setting of the records of
the module is done with the DISABLE flag set, so they are ignored by the
enabling and disabling of ftrace. All the module ftrace locations are set to
NOP.

This function is called after the text is set to ro and we enable the
module functions based on the flags set. But if we are ignoring the record
(as kvm has weak functions), we need to not only skip the setting of the
code, but need to clear the flags to state they are not set. Otherwise it
screws up the accounting of ftrace, and ftrace will WARN and disable itself.

-- Steve




> +
> rec->flags &= ~FTRACE_FL_DISABLED;
> rec->flags += cnt;
>

\
 
 \ /
  Last update: 2022-05-28 15:33    [W:0.029 / U:0.388 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site