From: sashiko-bot@kernel.org
To: "Arnaldo Carvalho de Melo" <acme@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v2 7/8] perf annotate-data: Resolve type DIEs in the debug file they came from
Date: Sun, 13 Sep 2026 03:38:52 +0000 [thread overview]
Message-ID: <20260913033852.B09721F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260913032632.116277-8-acme@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Unbounded recursion and iteration in DWARF member type chasers (`die_find_member` and `die_get_member_type`).
--
commit 2cb5592a12267288ad7685ab9363967d18e8063c
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: perf annotate-data: Resolve type DIEs in the debug file they came from
This commit resolves type DIE offsets in their correct debug file to prevent
an infinite loop in die_get_pointer_type(). It introduces bounded recursion
and iteration (MAX_TYPE_CHASE, MAX_MEMBER_DEPTH) to safely handle corrupted
or cyclic DWARF structures.
> diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> index d7160f87ac7d7..e35f724ea6835 100644
> --- a/tools/perf/util/dwarf-aux.c
> +++ b/tools/perf/util/dwarf-aux.c
> @@ -266,16 +266,35 @@ Dwarf_Die *die_get_type(Dwarf_Die *vr_die, Dwarf_Die *die_mem)
> return NULL;
> }
>
> +/*
> + * The chases below cross typedefs and qualifiers to get to the type that
> + * is actually meant, and a DIE that is not what it looks like, e.g. one
> + * parsed at an offset that is not the start of a DIE in the file it was
> + * resolved in, can have a DW_AT_type that refers back to itself, which
> + * makes them spin forever: 'perf report -s type' did exactly that on the
> + * dwz compressed debug info of zlib-ng (libz.so.1), burning all of a CPU
> + * with no output while resolving a hist entry in build_tree().
> + *
> + * No sane chain is this long, so give up instead of hanging, telling about
> + * it so that the broken debug info can be looked at.
> + */
> +#define MAX_TYPE_CHASE 32
> +
> /* Get a type die, but skip qualifiers */
> Dwarf_Die *__die_get_real_type(Dwarf_Die *vr_die, Dwarf_Die *die_mem)
[Severity: High]
This is a pre-existing issue, but since we are bounding DWARF chases here
to prevent hangs on cyclic structures, should die_get_member_type() also
have similar limits?
When processing broken DWARF info, if a nested structure's real type resolves
back to itself without advancing the offset, this loop in die_get_member_type()
can spin infinitely:
tools/perf/util/dwarf-aux.c:die_get_member_type() {
...
while (tag == DW_TAG_structure_type || tag == DW_TAG_union_type) {
member = die_find_child(&mb_type, __die_find_member_offset_cb,
(void *)(long)offset, die_mem);
...
}
Similarly, does __die_find_member_cb() require a recursion bound?
If it encounters a self-referential unnamed structure, it can perform
unbounded recursion through die_find_member(), potentially leading to a
stack overflow:
tools/perf/util/dwarf-aux.c:__die_find_member_cb() {
...
else if (!dwarf_diename(die_mem)) {
Dwarf_Die type_die, tmp_die;
if (die_get_type(die_mem, &type_die) &&
die_find_member(&type_die, name, &tmp_die))
return DIE_FIND_CB_END;
...
}
Could these unbound paths cause perf report to hang or crash when processing
untrusted or corrupted perf.data profiles?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260913032632.116277-1-acme@kernel.org?part=7
next prev parent reply other threads:[~2026-09-13 3:38 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-13 3:26 [PATCH v2 0/8] perf tools: Annotate fixes, stdio progress indication, debuginfo-client in more places Arnaldo Carvalho de Melo
2026-09-13 3:26 ` [PATCH v2 1/8] perf test: Skip data_type_profiling when the PMU cannot record memory events Arnaldo Carvalho de Melo
2026-09-13 3:31 ` sashiko-bot
2026-09-13 3:26 ` [PATCH v2 2/8] perf debuginfo: Fetch debuginfo keyed by build ID using debuginfod Arnaldo Carvalho de Melo
2026-09-13 3:36 ` sashiko-bot
2026-09-13 12:15 ` Arnaldo Melo
2026-09-13 3:26 ` [PATCH v2 3/8] perf symbol: Fall back to fetching the vmlinux by build ID Arnaldo Carvalho de Melo
2026-09-13 3:36 ` sashiko-bot
2026-09-13 3:26 ` [PATCH v2 4/8] perf annotate-data: Show the sample count in the data-type browser Arnaldo Carvalho de Melo
2026-09-13 3:34 ` sashiko-bot
2026-09-13 3:26 ` [PATCH v2 5/8] perf report: Add --progress option Arnaldo Carvalho de Melo
2026-09-13 3:35 ` sashiko-bot
2026-09-13 3:26 ` [PATCH v2 6/8] perf scripts: Add perf-stuck, to tell where a running perf is stuck Arnaldo Carvalho de Melo
2026-09-13 3:37 ` sashiko-bot
2026-09-13 3:26 ` [PATCH v2 7/8] perf annotate-data: Resolve type DIEs in the debug file they came from Arnaldo Carvalho de Melo
2026-09-13 3:38 ` sashiko-bot [this message]
2026-09-13 3:26 ` [PATCH v2 8/8] perf mem record: Request PERF_SAMPLE_CPU by default Arnaldo Carvalho de Melo
2026-09-13 3:42 ` 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=20260913033852.B09721F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=acme@kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.