ftrace: Return the first found result in lookup_rec()
Steven Rostedt
maintainerLinus,
Have ftrace lookup_rec() return a consistent record otherwise it can break live patching.
Please pull the latest trace-v5.6-rc4 tree, which can be found at:
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git
trace-v5.6-rc4
Tag SHA1: 3bedd0c3802cdffacf9fd6a4cac9f3fa6a4da477 Head SHA1: d9815bff6b379ff46981bea9dfeb146081eab314
Artem Savkov (1):
ftrace: Return the first found result in lookup_rec()
----
kernel/trace/ftrace.c | 2 ++ 1 file changed, 2 insertions(+) --------------------------- commit d9815bff6b379ff46981bea9dfeb146081eab314 Author: Artem Savkov <[email protected]> Date: Fri Mar 6 18:43:17 2020 +0100
ftrace: Return the first found result in lookup_rec()
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.
kernel/trace/ftrace.c +2 -0
@@ -1547,6 +1547,8 @@ 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); +if (rec) +break ; }return rec; }
The pull request you sent on Wed, 11 Mar 2020 10:45:36 -0400:
The pull request you sent on Wed, 11 Mar 2020 10:45:36 -0400:
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.gittrace-v5.6-rc4
has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/36feb996308ec3392495e3341bab2570b11cb1bd
Thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker