From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v9 04/11] perf test symbols: Add sorted insertion and equal-start alias tests
Date: Tue, 24 Nov 2026 03:39:27 +0000 [thread overview]
Message-ID: <sashiko-outbox-230475@kernel.org> (raw)
In-Reply-To: <20261124032902.3859564-5-irogers@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] perf test symbols: STB_WEAK alias test in
test__kallsyms_fixup_end() bypassed
--
commit 728aaf364c23458b2251cf89f0396157b988f69d
Author: Ian Rogers <irogers@google.com>
perf test symbols: Add sorted insertion and equal-start alias tests
This commit adds unit tests for sorted symbol insertion, equal-start
symbol aliases, and STB_WEAK / STB_GLOBAL alias resolution in kallsyms.
> diff --git a/tools/perf/tests/symbols.c b/tools/perf/tests/symbols.c
> index b73da581f8956..4e4f8eabec5b8 100644
> --- a/tools/perf/tests/symbols.c
> +++ b/tools/perf/tests/symbols.c
[ ... ]
> @@ -240,24 +476,28 @@ static int test__symbols(struct test_suite *test __maybe_unused, int subtest __m
>
> struct kallsyms_sym {
> u64 start;
> + u8 binding;
> const char *name;
> };
>
> /*
> * kallsyms from an x86 host where nf_tables was loaded in the page right
> * after the last symbol of dca, plus a kernel symbol followed closely by a
> - * module and a module far away from the others.
> + * module, a weak/global alias pair at the same address, and a module far
> + * away from the others.
> */
> static const struct kallsyms_sym kallsyms_syms[] = {
> - { 0xffffffff81000000, "_stext" },
> - { 0xffffffff81000ff0, "last_kernel_symbol" },
> - { 0xffffffff81001000, "near_module_symbol\t[near]" },
> - { 0xffffffffc0c4aa40, "dca_exit\t[dca]" },
> - { 0xffffffffc0c4aa50, "dca_sysfs_exit\t[dca]" },
> - { 0xffffffffc0c4b000, "__nft_trace_packet\t[nf_tables]" },
> - { 0xffffffffc0c4b0b0, "nft_do_chain\t[nf_tables]" },
> - { 0xffffffffc0c4b4e0, "nf_tables_core_module_exit\t[nf_tables]" },
> - { 0xffffffffc2000000, "far_module_symbol\t[far]" },
> + { 0xffffffff81000000, STB_GLOBAL, "_stext" },
> + { 0xffffffff81000500, STB_WEAK, "weak_alias_symbol" },
> + { 0xffffffff81000500, STB_GLOBAL, "global_target_symbol" },
> + { 0xffffffff81000ff0, STB_GLOBAL, "last_kernel_symbol" },
> + { 0xffffffff81001000, STB_GLOBAL, "near_module_symbol\t[near]" },
> + { 0xffffffffc0c4aa40, STB_GLOBAL, "dca_exit\t[dca]" },
> + { 0xffffffffc0c4aa50, STB_GLOBAL, "dca_sysfs_exit\t[dca]" },
> + { 0xffffffffc0c4b000, STB_GLOBAL, "__nft_trace_packet\t[nf_tables]" },
> + { 0xffffffffc0c4b0b0, STB_GLOBAL, "nft_do_chain\t[nf_tables]" },
> + { 0xffffffffc0c4b4e0, STB_GLOBAL, "nf_tables_core_module_exit\t[nf_tables]" },
> + { 0xffffffffc2000000, STB_GLOBAL, "far_module_symbol\t[far]" },
> };
>
> static int check_symbol(struct dso *dso, u64 addr, const char *name, u64 end)
> @@ -287,7 +527,8 @@ static int test__kallsyms_fixup_end(struct test_suite *test __maybe_unused,
> return TEST_FAIL;
>
> for (unsigned int i = 0; i < ARRAY_SIZE(kallsyms_syms); i++) {
> - struct symbol *sym = symbol__new(kallsyms_syms[i].start, 0, 0, 0,
> + struct symbol *sym = symbol__new(kallsyms_syms[i].start, 0,
> + kallsyms_syms[i].binding, STT_FUNC,
> kallsyms_syms[i].name);
>
> if (!sym)
> @@ -296,8 +537,13 @@ static int test__kallsyms_fixup_end(struct test_suite *test __maybe_unused,
> }
>
> symbols__fixup_end(dso__symbols(dso), true);
> + symbols__fixup_duplicate(dso__symbols(dso));
>
> ret = TEST_OK;
> + /* Same-address weak/global alias pair resolves to global_target_symbol. */
> + if (check_symbol(dso, 0xffffffff81000510, "global_target_symbol",
> + 0xffffffff81000ff0))
> + ret = TEST_FAIL;
[Severity: Medium]
Does test__kallsyms_fixup_end() actually exercise the STB_WEAK vs
STB_GLOBAL check in choose_best_symbol()?
Because symbols__fixup_end() skips equal-start entries with
curr->start == prev->start, only the last symbol at 0xffffffff81000500
(global_target_symbol) has its end updated to 0xffffffff81000ff0, while
weak_alias_symbol remains zero-sized. When symbols__fixup_duplicate()
then calls choose_best_symbol(), it picks global_target_symbol via the
earlier non-zero length check without reaching the binding comparison:
tools/perf/util/symbol.c:choose_best_symbol() {
...
/* Prefer a symbol with non zero length */
a = syma->end - syma->start;
b = symb->end - symb->start;
if ((b == 0) && (a > 0))
return SYMBOL_A;
else if ((a == 0) && (b > 0))
return SYMBOL_B;
...
}
As a result, the test passes solely because global_target_symbol is
listed second in kallsyms_syms[]; if global_target_symbol precedes
weak_alias_symbol at the same address, symbols__fixup_end() inflates only
weak_alias_symbol and symbols__fixup_duplicate() drops the global symbol.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124032902.3859564-1-irogers@google.com?part=4
next prev parent reply other threads:[~2026-11-24 3:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 3:28 [PATCH v9 00/11] perf symbol: Sorted array optimizations and memory shrinking Ian Rogers
2026-11-24 3:28 ` [PATCH v9 01/11] perf symbol: Drop num_by_name and sorted_by_name from struct symbols Ian Rogers
2026-11-24 3:28 ` [PATCH v9 02/11] perf symbol: Replace sorted boolean with sorted_cnt prefix length Ian Rogers
2026-11-24 3:28 ` [PATCH v9 03/11] perf symbol: Add secondary sorted run for dso__insert_symbol() Ian Rogers
2026-11-24 3:28 ` [PATCH v9 04/11] perf test symbols: Add sorted insertion and equal-start alias tests Ian Rogers
2026-11-24 3:39 ` sashiko-bot [this message]
2026-11-24 3:28 ` [PATCH v9 05/11] perf dso: Synchronize dso_cache access and make dso->loaded atomic Ian Rogers
2026-11-24 3:28 ` [PATCH v9 06/11] perf symbol: Add symbols__shrink() and symbols__try_delete_unannotated() Ian Rogers
2026-11-24 3:28 ` [PATCH v9 07/11] perf dso: Add dso__shrink() and dso__try_evict() Ian Rogers
2026-11-24 3:28 ` [PATCH v9 08/11] perf session: Add dsos, machine, and perf_session shrinking Ian Rogers
2026-11-24 3:29 ` [PATCH v9 09/11] perf test symbols: Add symbol and DSO shrinking tests Ian Rogers
2026-11-24 3:29 ` [PATCH v9 10/11] perf session: Add dso__session() and session-scoped allocation wrappers Ian Rogers
2026-11-24 3:29 ` [PATCH v9 11/11] perf test symbols: Add session allocation wrapper and lock contention tests Ian Rogers
2026-11-24 3:49 ` [PATCH v9 00/11] perf symbol: Sorted array optimizations and memory shrinking sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-230475@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=irogers@google.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox