This is a note to let you know that I've just added the patch titled selftests/bpf: Add load_kallsyms_refresh function 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: selftests-bpf-add-load_kallsyms_refresh-function.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:23 2022 From: Jiri Olsa <jolsa@xxxxxxxxxx> Date: Fri, 16 Dec 2022 13:56:25 +0100 Subject: selftests/bpf: Add load_kallsyms_refresh function To: stable@xxxxxxxxxxxxxxx Cc: Song Liu <song@xxxxxxxxxx>, bpf@xxxxxxxxxxxxxxx, Martynas Pumputis <m@xxxxxxxxx> Message-ID: <20221216125628.1622505-6-jolsa@xxxxxxxxxx> From: Jiri Olsa <jolsa@xxxxxxxxxx> commit 10705b2b7a8e4eb46ab5bf1b9ee354cb9a929428 upstream. Adding load_kallsyms_refresh function to re-read symbols from /proc/kallsyms file. This will be needed to get proper functions addresses from bpf_testmod.ko module, which is loaded/unloaded several times during the tests run, so symbols might be already old when we need to use them. Acked-by: Song Liu <song@xxxxxxxxxx> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx> Link: https://lore.kernel.org/r/20221025134148.3300700-6-jolsa@xxxxxxxxxx Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- tools/testing/selftests/bpf/trace_helpers.c | 20 +++++++++++++------- tools/testing/selftests/bpf/trace_helpers.h | 2 ++ 2 files changed, 15 insertions(+), 7 deletions(-) --- a/tools/testing/selftests/bpf/trace_helpers.c +++ b/tools/testing/selftests/bpf/trace_helpers.c @@ -23,7 +23,7 @@ static int ksym_cmp(const void *p1, cons return ((struct ksym *)p1)->addr - ((struct ksym *)p2)->addr; } -int load_kallsyms(void) +int load_kallsyms_refresh(void) { FILE *f; char func[256], buf[256]; @@ -31,12 +31,7 @@ int load_kallsyms(void) void *addr; int i = 0; - /* - * This is called/used from multiplace places, - * load symbols just once. - */ - if (sym_cnt) - return 0; + sym_cnt = 0; f = fopen("/proc/kallsyms", "r"); if (!f) @@ -57,6 +52,17 @@ int load_kallsyms(void) return 0; } +int load_kallsyms(void) +{ + /* + * This is called/used from multiplace places, + * load symbols just once. + */ + if (sym_cnt) + return 0; + return load_kallsyms_refresh(); +} + struct ksym *ksym_search(long key) { int start = 0, end = sym_cnt; --- a/tools/testing/selftests/bpf/trace_helpers.h +++ b/tools/testing/selftests/bpf/trace_helpers.h @@ -10,6 +10,8 @@ struct ksym { }; int load_kallsyms(void); +int load_kallsyms_refresh(void); + struct ksym *ksym_search(long key); long ksym_get_addr(const char *name); 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