From: sashiko-bot@kernel.org
To: "Thomas Falcon" <thomas.falcon@intel.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v10 3/6] perf header: Support memory ranges
Date: Wed, 16 Sep 2026 16:45:03 +0000 [thread overview]
Message-ID: <20260916164503.8E5981F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260916163127.318885-4-thomas.falcon@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] perf: memory leak of env->memory_ranges when parsing malformed data
--
commit 1ab84913c01dd8ba27d90b19de21357887b69fea
Author: Thomas Falcon <thomas.falcon@intel.com>
perf header: Support memory ranges
This commit introduces support for tracking different types of memory
ranges, such as persistent or CXL-attached memory. It parses ACPI MRRM
data exposed via sysfs and saves it in the perf.data file header under
a new feature bit.
Link: https://lore.kernel.org/lkml/20250505173819.419271-1-tony.luck@intel.com/
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index ec2935c0ed04e..38f2da9de5f0d 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
[ ... ]
> @@ -4227,6 +4372,65 @@ static int process_cpu_domain_info(struct feat_fd *ff, void *data __maybe_unused
> return ret;
> }
>
> +static int process_memory_ranges(struct feat_fd *ff, void *data __maybe_unused)
> +{
> + struct perf_env *env = &ff->ph->env;
> + struct memory_range *ranges, *r;
> + u32 nr_memory_ranges, i;
[ ... ]
> + ranges = calloc(nr_memory_ranges, sizeof(*ranges));
> + if (!ranges)
> + return -1;
> +
> + for (i = 0; i < nr_memory_ranges; i++) {
> + r = &ranges[i];
> +
> + if (do_read_u64(ff, &r->base))
> + goto error;
> + if (do_read_u64(ff, &r->length))
> + goto error;
> + if (do_read_u32(ff, (u32 *) &r->node))
> + goto error;
> + if (__do_read(ff, &r->local_region_id, sizeof(u8)))
> + goto error;
> + if (__do_read(ff, &r->remote_region_id, sizeof(u8)))
> + goto error;
> + }
> +
> + env->memory_ranges = ranges;
> + env->nr_memory_ranges = nr_memory_ranges;
[Severity: Medium]
If a malformed perf.data file or pipe stream contains multiple
HEADER_MEMORY_RANGES sections, process_memory_ranges() in
tools/perf/util/header.c could be executed multiple times.
Can this assignment cause a memory leak by overwriting env->memory_ranges
without freeing the previously allocated array?
Could this leak be exploited to cause a Denial of Service (OOM) in the
userspace perf tool when processing untrusted pipe streams?
> +
> + return 0;
> +error:
> + zfree(&ranges);
> + return -1;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260916163127.318885-1-thomas.falcon@intel.com?part=3
next prev parent reply other threads:[~2026-09-16 16:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 16:31 [PATCH v10 0/6] perf: Add support for memory region/range reporting Thomas Falcon
2026-09-16 16:31 ` [PATCH v10 1/6] perf mem: Fix size tracking for mem_lvl's in perf_script__meminfo_scnprintf() Thomas Falcon
2026-09-16 16:41 ` sashiko-bot
2026-09-16 16:31 ` [PATCH v10 2/6] perf mem: Add support for printing PERF_MEM_LVLNUM_L0 Thomas Falcon
2026-09-16 16:46 ` sashiko-bot
2026-09-16 16:31 ` [PATCH v10 3/6] perf header: Support memory ranges Thomas Falcon
2026-09-16 16:45 ` sashiko-bot [this message]
2026-09-16 16:31 ` [PATCH v10 4/6] perf tools: Show memory region in perf-c2c subcommand Thomas Falcon
2026-09-16 16:42 ` sashiko-bot
2026-09-17 6:04 ` Mi, Dapeng
2026-09-17 17:37 ` Falcon, Thomas
2026-09-18 1:01 ` Mi, Dapeng
2026-09-16 16:31 ` [PATCH v10 5/6] perf tools: Show memory region in perf-script subcommand Thomas Falcon
2026-09-16 16:50 ` sashiko-bot
2026-09-16 16:31 ` [PATCH v10 6/6] perf c2c: print memory region data with stdio output Thomas Falcon
2026-09-16 16:48 ` 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=20260916164503.8E5981F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=thomas.falcon@intel.com \
/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