lkml.org 
[lkml]   [2022]   [Feb]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 04/29] x86/livepatch: Validate __fentry__ location
On Wed, 23 Feb 2022 07:41:39 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:

> > --- a/kernel/trace/ftrace.c
> > +++ b/kernel/trace/ftrace.c
> > @@ -1578,7 +1578,23 @@ unsigned long ftrace_location_range(unsi
> > */
> > unsigned long ftrace_location(unsigned long ip)
> > {
> > - return ftrace_location_range(ip, ip);
> > + struct dyn_ftrace *rec;
> > + unsigned long offset;
> > + unsigned long size;
> > +
> > + rec = lookup_rec(ip, ip);
> > + if (!rec) {
> > + if (!kallsyms_lookup_size_offset(ip, &size, &offset))
> > + goto out;
> > +
> > + rec = lookup_rec(ip - offset, (ip - offset) + size);
> > + }
> > +
>
> Please create a new function for this. Perhaps find_ftrace_location().
>
> ftrace_location() is used to see if the address given is a ftrace
> nop or not. This change will make it always return true.

Now we could do:

return ip <= (rec->ip + MCOUNT_INSN_SIZE) ? rec->ip : 0;

Since we would want rec->ip if the pointer is before the ftrace
instruction. But we would need to audit all use cases and make sure this is
not called from any hot paths (in a callback).

This will affect kprobes and BPF as they both use ftrace_location() as well.

-- Steve

\
 
 \ /
  Last update: 2022-02-23 15:23    [W:0.127 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site