From: sashiko-bot@kernel.org
To: "Jiebin Sun" <jiebin.sun@intel.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v8 6/9] perf c2c: add function view hierarchy entry creation
Date: Mon, 10 Aug 2026 05:49:44 +0000 [thread overview]
Message-ID: <20260810054945.82FFE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260810052647.588867-7-jiebin.sun@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Deleting a function-view child entry causes an out-of-bounds heap read in `free_callchain()` because the child entry is allocated without trailing `callchain_root` memory.
--
--- Patch [6]: [PATCH v8 6/9] perf c2c: add function view hierarchy entry creation ---
commit 3fbce53bcfd8d8abeda29f9eded35e05dfc305f5
Author: Jiebin Sun <jiebin.sun@intel.com>
perf c2c: add function view hierarchy entry creation
This patch adds the entry-creation layer for the function view hierarchy.
It implements level-1/2/3 lookup-or-create functions and synthetic child
allocation logic, reusing cacheline_idx to preserve source entry identity.
> diff --git a/tools/perf/ui/browsers/c2c-function.c b/tools/perf/ui/browsers/c2c-function.c
> index 4bf8406fde556..4099d4c7e7b44 100644
> --- a/tools/perf/ui/browsers/c2c-function.c
> +++ b/tools/perf/ui/browsers/c2c-function.c
[ ... ]
> @@ -847,6 +865,259 @@ static int __maybe_unused c2c_he__prune_empty_writers(struct hist_entry *l1_he)
> return surviving;
> }
>
> +static void *c2c_function_he_zalloc(size_t size)
> +{
> + struct c2c_hist_entry *c2c_he = zalloc(sizeof(*c2c_he) + size);
> +
> + if (!c2c_he)
> + return NULL;
> +
> + init_stats(&c2c_he->cstats.lcl_hitm);
> + init_stats(&c2c_he->cstats.rmt_hitm);
> + init_stats(&c2c_he->cstats.lcl_peer);
> + init_stats(&c2c_he->cstats.rmt_peer);
> + init_stats(&c2c_he->cstats.load);
> +
> + return &c2c_he->he;
> +}
> +
> +/* Entry operations for function view */
> +static struct hist_entry_ops c2c_function_entry_ops = {
> + .new = c2c_function_he_zalloc,
> + .free = c2c_function_he_free,
> +};
> +
> +static struct c2c_hist_entry *
> +c2c_child_entry__alloc(struct hist_entry *parent_he, struct hist_entry *src_he,
> + int depth, u64 ip)
> +{
> + struct c2c_hist_entry *child_c2c;
> + struct hist_entry *child_he;
> +
> + /* Function-view children never own or display callchains. */
> + child_he = c2c_function_he_zalloc(0);
> + if (!child_he)
> + return NULL;
[Severity: Medium]
Will this cause an out-of-bounds memory read when the entry is freed?
If perf c2c report is run with callchains enabled (symbol_conf.use_callchain
is true), this entry is allocated with 0 extra bytes for the callchain.
When this undersized entry is deleted on the error path below or during
cleanup via c2c_he__free_hierarchy(), hist_entry__delete() accesses
he->callchain based on the global symbol_conf.use_callchain flag:
tools/perf/util/hist.c:hist_entry__delete() {
...
if (symbol_conf.use_callchain)
free_callchain(he->callchain);
...
}
Could this read past the end of the c2c_hist_entry structure and dereference
garbage memory in free_callchain_node()?
> +
> + child_c2c = container_of(child_he, struct c2c_hist_entry, he);
> + child_he->ops = &c2c_function_entry_ops;
> + map_symbol__copy(&child_he->ms, &src_he->ms);
[ ... ]
> + return child_c2c;
> +
> +out_free:
> + hist_entry__delete(child_he);
> + return NULL;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260810052647.588867-1-jiebin.sun@intel.com?part=6
next prev parent reply other threads:[~2026-08-10 5:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 5:26 [PATCH v8 0/9] perf c2c: add a function view Jiebin Sun
2026-08-10 5:26 ` [PATCH v8 1/9] perf c2c: extract shared data structures into util/c2c.h Jiebin Sun
2026-08-10 5:26 ` [PATCH v8 2/9] perf c2c: add function view browser skeleton Jiebin Sun
2026-08-10 5:26 ` [PATCH v8 3/9] perf c2c: add column rendering for function view Jiebin Sun
2026-08-10 5:26 ` [PATCH v8 4/9] perf c2c: add HPP list parsing for function view columns Jiebin Sun
2026-08-10 5:26 ` [PATCH v8 5/9] perf c2c: add function view stats merge and memory management Jiebin Sun
2026-08-10 5:26 ` [PATCH v8 6/9] perf c2c: add function view hierarchy entry creation Jiebin Sun
2026-08-10 5:49 ` sashiko-bot [this message]
2026-08-10 5:26 ` [PATCH v8 7/9] perf c2c: build and finalize the function view hierarchy Jiebin Sun
2026-08-10 5:26 ` [PATCH v8 8/9] perf c2c: add function view browser UI and cacheline detail Jiebin Sun
2026-08-10 5:26 ` [PATCH v8 9/9] perf c2c: document function view in perf-c2c man page Jiebin Sun
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=20260810054945.82FFE1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=jiebin.sun@intel.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