Skip to content

Commit ffa2d73

Browse files
sm00thgregkh
authored andcommitted
ftrace: Return the first found result in lookup_rec()
commit d9815bf upstream. 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. Link: http://lkml.kernel.org/r/20200306174317.21699-1-asavkov@redhat.com Cc: stable@vger.kernel.org Fixes: 7e16f58 ("ftrace: Separate out functionality from ftrace_location_range()") Signed-off-by: Artem Savkov <asavkov@redhat.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f6a85df commit ffa2d73

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎kernel/trace/ftrace.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,8 @@ static struct dyn_ftrace *lookup_rec(unsigned long start, unsigned long end)
15521552
rec = bsearch(&key, pg->records, pg->index,
15531553
sizeof(struct dyn_ftrace),
15541554
ftrace_cmp_recs);
1555+
if (rec)
1556+
break;
15551557
}
15561558
return rec;
15571559
}

0 commit comments

Comments
 (0)