lkml.org 
[lkml]   [2020]   [Mar]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] ftrace: return first found result in lookup_rec()
On Fri,  6 Mar 2020 09:10:35 +0100
Artem Savkov <asavkov@redhat.com> wrote:

> It appears that ip ranges can overlap so. In that case lookup_rec()
> returns whatever results it got last even if it found nothing in last
> searched page.
>
> This breaks an obscure livepatch late module patching usecase:
> - load livepatch
> - load the patched module
> - unload livepatch
> - try to load livepatch again
>
> To fix this return from lookup_rec() as soon as it found the record
> containing searched-for ip. This used to be this way prior lookup_rec()
> introduction.
>
> Fixes: 7e16f581a817 ("ftrace: Separate out functionality from ftrace_location_range()")
> Signed-off-by: Artem Savkov <asavkov@redhat.com>
> ---
> kernel/trace/ftrace.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 3f7ee102868a..b0f5ee1fd6e4 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -1547,8 +1547,10 @@ static struct dyn_ftrace *lookup_rec(unsigned long start, unsigned long end)
> rec = bsearch(&key, pg->records, pg->index,
> sizeof(struct dyn_ftrace),
> ftrace_cmp_recs);

how about just adding:

if (rec)
break;

as that will do the same thing without adding two returns.

-- Steve

> + if (rec)
> + return rec;
> }
> - return rec;
> + return NULL;
> }
>
> /**

\
 
 \ /
  Last update: 2020-03-06 18:12    [W:0.084 / U:0.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site