From: sashiko-bot@kernel.org
To: wen.yang@linux.dev
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v6 8/9] selftests/verification: Add tlob selftests
Date: Thu, 20 Aug 2026 16:56:32 +0000 [thread overview]
Message-ID: <20260820165633.5066B1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <c1305284e09e0522c5c88e8ebf4a0f6e59541999.1787243842.git.wen.yang@linux.dev>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Using `$(nproc) - 1` to determine a target CPU ID assumes that CPU IDs are contiguous and start from 0, which breaks on sparse affinity masks or offline CPUs.
- [Medium] The ELF parser in `tlob_sym.c` lacks sufficient bounds checks when validating headers and iterating over sections, leading to out-of-bounds memory accesses.
--
--- Patch [8]: [PATCH v6 8/9] selftests/verification: Add tlob selftests ---
commit cb49807af49abc34cb32dee7d7e1d06575cff80a
Author: Wen Yang <wen.yang@linux.dev>
selftests/verification: Add tlob selftests
This commit adds seven ftrace-style test scripts for the tlob RV monitor,
covering uprobe binding management, budget violation detection, and per-state
time accounting. It also includes a standalone runner and C helper programs
for target execution and ELF symbol parsing.
> diff --git a/tools/testing/selftests/verification/test.d/tlob/uprobe_detail_waiting.tc b/tools/testing/selftests/verification/test.d/tlob/uprobe_detail_waiting.tc
> new file mode 100644
> index 0000000000000..798a04012b6ea
> --- /dev/null
> +++ b/tools/testing/selftests/verification/test.d/tlob/uprobe_detail_waiting.tc
[ ... ]
> +start_offset=$("$TLOB_SYM" sym_offset "$UPROBE_TARGET" tlob_preempt_work 2>/dev/null)
> +stop_offset=$("$TLOB_SYM" sym_offset "$UPROBE_TARGET" tlob_preempt_work_done 2>/dev/null)
> +
> +# Pick the last CPU to avoid cpu0 which is used by vng infrastructure.
> +cpu=$(($(nproc) - 1))
> +
[Severity: Medium]
Does this CPU ID calculation safely handle systems with sparse CPU affinity
masks or offline CPUs?
If a system has non-contiguous CPU IDs (for example, if CPU 1 is offline but
CPUs 0 and 2 are online), nproc will evaluate to 2. This calculation would
yield CPU 1, which might cause the subsequent taskset commands to fail with
an invalid argument error since CPU 1 is unavailable.
> +echo 1 > ../events/rv/detail_env_tlob/enable
> +echo 1 > ../tracing_on
> +echo 1 > monitors/tlob/enable
> +echo > ../trace
[ ... ]
> diff --git a/tools/testing/selftests/verification/tlob_sym.c b/tools/testing/selftests/verification/tlob_sym.c
> new file mode 100644
> index 0000000000000..2d9561331d2f9
> --- /dev/null
> +++ b/tools/testing/selftests/verification/tlob_sym.c
[ ... ]
> + for (int pass = 0; pass < 2 && !found; pass++) {
> + const char *target = pass ? ".dynsym" : ".symtab";
> +
> + for (si = 0; si < ehdr->e_shnum && !found; si++) {
> + Elf64_Shdr *sh = &shdrs[si];
> + const char *name = shstrtab + sh->sh_name;
[Severity: Medium]
Is there a risk of an out-of-bounds read when accessing the string table
here?
It appears sh->sh_name is used as an offset into shstrtab and passed to
strcmp() without bounds checking against the actual string table size. Could
a malformed binary cause a segmentation fault when the tool attempts to read
beyond the mapped memory?
> +
> + if (strcmp(name, target) != 0)
> + continue;
> +
> + Elf64_Shdr *strtab_sh = &shdrs[sh->sh_link];
[Severity: Medium]
Could this array indexing access memory outside the section header table?
The sh->sh_link field is used directly as an index into shdrs. Since there
is no verification that sh->sh_link is less than ehdr->e_shnum, a malformed
ELF file could cause the tool to read arbitrary memory when mapping headers.
> + const char *strtab = (char *)map + strtab_sh->sh_offset;
> + Elf64_Sym *syms = (Elf64_Sym *)((char *)map + sh->sh_offset);
> + uint64_t nsyms = sh->sh_size / sizeof(Elf64_Sym);
> + uint64_t j;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1787243842.git.wen.yang@linux.dev?part=8
next prev parent reply other threads:[~2026-08-20 16:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 16:45 [PATCH v6 0/9] rv: Add task latency over budget RV monitor wen.yang
2026-08-20 16:45 ` [PATCH v6 1/9] rv: Introduce DA_MON_ALLOCATION_STRATEGY wen.yang
2026-08-20 16:45 ` [PATCH v6 2/9] rv: Add generic uprobe infrastructure for RV monitors wen.yang
2026-08-20 16:59 ` sashiko-bot
2026-08-20 16:45 ` [PATCH v6 3/9] rv: Add tlob model DOT file wen.yang
2026-08-20 16:53 ` sashiko-bot
2026-08-20 16:45 ` [PATCH v6 4/9] rv: Fix ha_invariant_passed_ns silent bypass of invariant check wen.yang
2026-08-20 16:58 ` sashiko-bot
2026-08-20 16:45 ` [PATCH v6 5/9] rv: Make da_monitor_reset_hook and EVENT_NONE_LBL overridable wen.yang
2026-08-20 16:59 ` sashiko-bot
2026-08-20 16:45 ` [PATCH v6 6/9] rv: Add tlob hybrid automaton monitor wen.yang
2026-08-20 17:03 ` sashiko-bot
2026-08-20 16:45 ` [PATCH v6 7/9] rv: Add KUnit tests for the tlob monitor wen.yang
2026-08-20 16:45 ` [PATCH v6 8/9] selftests/verification: Add tlob selftests wen.yang
2026-08-20 16:56 ` sashiko-bot [this message]
2026-08-20 16:45 ` [PATCH v6 9/9] selftests/ftrace: Walk up to find test.d/functions when a subdirectory is passed wen.yang
2026-08-20 16:58 ` 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=20260820165633.5066B1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wen.yang@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