This is a note to let you know that I've just added the patch titled ftrace: Add support to resolve module symbols in ftrace_lookup_symbols to the 6.0-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: ftrace-add-support-to-resolve-module-symbols-in-ftrace_lookup_symbols.patch and it can be found in the queue-6.0 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From stable-owner@xxxxxxxxxxxxxxx Fri Dec 16 13:57:01 2022 From: Jiri Olsa <jolsa@xxxxxxxxxx> Date: Fri, 16 Dec 2022 13:56:22 +0100 Subject: ftrace: Add support to resolve module symbols in ftrace_lookup_symbols To: stable@xxxxxxxxxxxxxxx Cc: Martynas Pumputis <m@xxxxxxxxx>, Song Liu <song@xxxxxxxxxx>, bpf@xxxxxxxxxxxxxxx Message-ID: <20221216125628.1622505-3-jolsa@xxxxxxxxxx> From: Jiri Olsa <jolsa@xxxxxxxxxx> commit 3640bf8584f4ab0f5eed6285f09213954acd8b62 upstream. Currently ftrace_lookup_symbols iterates only over core symbols, adding module_kallsyms_on_each_symbol call to check on modules symbols as well. Also removing 'args.found == args.cnt' condition, because it's already checked in kallsyms_callback function. Also removing 'err < 0' check, because both *kallsyms_on_each_symbol functions do not return error. Reported-by: Martynas Pumputis <m@xxxxxxxxx> Acked-by: Song Liu <song@xxxxxxxxxx> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx> Link: https://lore.kernel.org/r/20221025134148.3300700-3-jolsa@xxxxxxxxxx Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- kernel/trace/ftrace.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -8261,6 +8261,10 @@ struct kallsyms_data { size_t found; }; +/* This function gets called for all kernel and module symbols + * and returns 1 in case we resolved all the requested symbols, + * 0 otherwise. + */ static int kallsyms_callback(void *data, const char *name, struct module *mod, unsigned long addr) { @@ -8304,17 +8308,19 @@ static int kallsyms_callback(void *data, int ftrace_lookup_symbols(const char **sorted_syms, size_t cnt, unsigned long *addrs) { struct kallsyms_data args; - int err; + int found_all; memset(addrs, 0, sizeof(*addrs) * cnt); args.addrs = addrs; args.syms = sorted_syms; args.cnt = cnt; args.found = 0; - err = kallsyms_on_each_symbol(kallsyms_callback, &args); - if (err < 0) - return err; - return args.found == args.cnt ? 0 : -ESRCH; + + found_all = kallsyms_on_each_symbol(kallsyms_callback, &args); + if (found_all) + return 0; + found_all = module_kallsyms_on_each_symbol(kallsyms_callback, &args); + return found_all ? 0 : -ESRCH; } #ifdef CONFIG_SYSCTL Patches currently in stable-queue which might be from stable-owner@xxxxxxxxxxxxxxx are queue-6.0/ftrace-add-support-to-resolve-module-symbols-in-ftrace_lookup_symbols.patch queue-6.0/selftests-bpf-add-kprobe_multi-kmod-attach-api-tests.patch queue-6.0/bpf-take-module-reference-on-kprobe_multi-link.patch queue-6.0/selftests-bpf-add-load_kallsyms_refresh-function.patch queue-6.0/kallsyms-make-module_kallsyms_on_each_symbol-generally-available.patch queue-6.0/selftests-bpf-add-bpf_testmod_fentry_-functions.patch queue-6.0/selftests-bpf-add-kprobe_multi-check-to-module-attach-test.patch queue-6.0/bpf-rename-__bpf_kprobe_multi_cookie_cmp-to-bpf_kprobe_multi_addrs_cmp.patch