[SRU][F][PATCH v2 2/3] ftrace: Return the first found result in lookup_rec()
Koichiro Den
koichiro.den at canonical.com
Fri Oct 25 13:42:29 UTC 2024
From: Artem Savkov <asavkov at redhat.com>
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 at vger.kernel.org
Fixes: 7e16f581a817 ("ftrace: Separate out functionality from ftrace_location_range()")
Signed-off-by: Artem Savkov <asavkov at redhat.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt at goodmis.org>
(cherry picked from commit d9815bff6b379ff46981bea9dfeb146081eab314)
[koichiroden: Follow-up fix for the preceding prerequisite commit]
CVE-2024-38588
Signed-off-by: Koichiro Den <koichiro.den at canonical.com>
---
kernel/trace/ftrace.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index d9992fef7287..e40bbd18bc99 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1552,6 +1552,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;
}
--
2.43.0
More information about the kernel-team
mailing list