Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Matt Turner" <mattst88@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v8 3/3] perf tools gtk: fix two hierarchy-view stack buffer overflows
Date: Wed, 09 Sep 2026 03:10:57 +0000	[thread overview]
Message-ID: <20260909031057.90BA31F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260908-perf-gtk2-v8-3-e90d5d155f0d@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Potential stack buffer overflow when writing to `col_types` array if `nr_cols` exceeds `MAX_COLUMNS`.
--

commit d31e2f191655501641db6dac561539e4edaedb03
Author: Matt Turner <mattst88@gmail.com>

perf tools gtk: fix two hierarchy-view stack buffer overflows

This commit fixes two stack buffer overflows in the perf GTK hierarchy view.
It tracks the write offset and uses scnprintf() to prevent buffer overflows
when building merged column headers. It also clamps the value passed to
advance_hpp() to prevent size underflows during entry formatting.

> diff --git a/tools/perf/ui/gtk/hists.c b/tools/perf/ui/gtk/hists.c
> index 716dcf02bd0e8..80df3fec8ea13 100644
> --- a/tools/perf/ui/gtk/hists.c
> +++ b/tools/perf/ui/gtk/hists.c

[ ... ]

> @@ -505,6 +516,7 @@ static void perf_gtk__show_hierarchy(GtkWidget *window, struct hists *hists,
>  	GtkWidget *view;
>  	int col_idx;
>  	int nr_cols = 0;
> +	int ret;
>  	char s[512];
>  	char buf[512];
>  	bool first_node, first_col;

[Severity: High]
This is a pre-existing issue, but while looking at
perf_gtk__show_hierarchy(), can this code overflow the col_types[] array?

Further down in perf_gtk__show_hierarchy(), the code does:

	hists__for_each_format(hists, fmt) {
		if (perf_hpp__is_sort_entry(fmt) ||
		    perf_hpp__is_dynamic_entry(fmt))
			break;

		col_types[nr_cols++] = G_TYPE_STRING;
	}
	col_types[nr_cols++] = G_TYPE_STRING;

Since col_types is declared as GType col_types[MAX_COLUMNS], if a
perf.data file defines a large number of overhead formats (for example,
from an event group with >= 32 events), could nr_cols exceed MAX_COLUMNS
and write past the end of the stack buffer?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260908-perf-gtk2-v8-0-e90d5d155f0d@gmail.com?part=3

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

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09  2:50 [PATCH v8 0/3] perf tools: port UI from GTK2 to GTK4 Matt Turner
2026-09-09  2:50 ` [PATCH v8 1/3] tools: port perf ui from GTK 2 to GTK 4 Matt Turner
2026-09-09  3:06   ` sashiko-bot
2026-09-09  2:50 ` [PATCH v8 2/3] perf tools: make the GTK4 report browser actually loadable at runtime Matt Turner
2026-09-09  3:01   ` sashiko-bot
2026-09-09  2:50 ` [PATCH v8 3/3] perf tools gtk: fix two hierarchy-view stack buffer overflows Matt Turner
2026-09-09  3:10   ` sashiko-bot [this message]
2026-09-09 11:13 ` [PATCH v8 0/3] perf tools: port UI from GTK2 to GTK4 Arnaldo Carvalho de Melo
2026-09-09 11:25   ` Arnaldo Carvalho de Melo
2026-09-09 11:29     ` Arnaldo Carvalho de Melo
2026-09-09 11:35       ` Arnaldo Carvalho de Melo
2026-09-09 11:43         ` Arnaldo Carvalho de Melo
2026-09-09 11:52           ` Arnaldo Carvalho de Melo
2026-09-09 20:02             ` Arnaldo Carvalho de Melo

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=20260909031057.90BA31F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mattst88@gmail.com \
    --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