Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Thomas Falcon" <thomas.falcon@intel.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v8 6/6] perf c2c: print memory region data with stdio output
Date: Thu, 10 Sep 2026 19:59:24 +0000	[thread overview]
Message-ID: <20260910195924.B29D61F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260910194324.98002-7-thomas.falcon@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Unsafe end address calculation for zero-length memory ranges, causing integer underflow.
--

commit 353c7e26bf2f698e86dedab128c94a9970b19c51
Author: Thomas Falcon <thomas.falcon@intel.com>

perf c2c: print memory region data with stdio output

Print memory range data in perf-c2c subcommand. Only available in stdio
mode currently. If memory ranges are not supported or present, print
nothing.

> diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
> index e37c1a3a4ca5e..9d0182a7d4d5a 100644
> --- a/tools/perf/builtin-c2c.c
> +++ b/tools/perf/builtin-c2c.c
[ ... ]
> +	for (int i = 0; i < nr_ranges; i++) {
> +		struct memory_range *r = &env->memory_ranges[i];
> +
> +		fprintf(out, "Range %d: [0x%016" PRIx64 "-0x%016" PRIx64 "] Node %d, local region id %u, remote region id %u\n",
> +			i, r->base, r->base + r->length - 1, r->node,

[Severity: Low]
Does this code risk an integer underflow if a memory range has a length of 0?

If r->length is 0, the end address calculation underflows, which can lead to
an incorrect address being printed (for example, wrapping around to
0xffffffffffffffff if the base address is 0).

Since the parsing function process_memory_ranges() can allow 0-length
ranges, should this calculation check for r->length == 0 before
subtracting 1?

> +			r->local_region_id, r->remote_region_id);
> +	}
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260910194324.98002-1-thomas.falcon@intel.com?part=6

      reply	other threads:[~2026-09-10 19:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10 19:43 [PATCH v8 0/6] perf: Add support for memory region/range reporting Thomas Falcon
2026-09-10 19:43 ` [PATCH v8 1/6] perf mem: Fix size tracking for mem_lvl's in perf_script__meminfo_scnprintf() Thomas Falcon
2026-09-10 19:55   ` sashiko-bot
2026-09-10 19:43 ` [PATCH v8 2/6] perf mem: Add support for printing PERF_MEM_LVLNUM_L0 Thomas Falcon
2026-09-10 19:51   ` sashiko-bot
2026-09-10 19:43 ` [PATCH v8 3/6] perf header: Support memory ranges Thomas Falcon
2026-09-10 19:58   ` sashiko-bot
2026-09-10 19:43 ` [PATCH v8 4/6] perf tools: Show memory region in perf-c2c subcommand Thomas Falcon
2026-09-10 19:54   ` sashiko-bot
2026-09-11  0:50   ` Mi, Dapeng
2026-09-11 15:58     ` Falcon, Thomas
2026-09-10 19:43 ` [PATCH v8 5/6] perf tools: Show memory region in perf-script subcommand Thomas Falcon
2026-09-10 19:53   ` sashiko-bot
2026-09-11  0:51   ` Mi, Dapeng
2026-09-10 19:43 ` [PATCH v8 6/6] perf c2c: print memory region data with stdio output Thomas Falcon
2026-09-10 19:59   ` sashiko-bot [this message]

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=20260910195924.B29D61F000FF@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