summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2026-04-11 01:08:53 +0300
committerNamhyung Kim <namhyung@kernel.org>2026-04-14 09:21:52 +0300
commitf823d7efb81cd2a799dc386da4f9292fdc2c1dbe (patch)
tree3ca68a3c560412a8d044aa4a072daaad96cb6bc7 /tools
parentfab205e49286ab01cbc6fa8debd65a5a6e6cca71 (diff)
downloadlinux-f823d7efb81cd2a799dc386da4f9292fdc2c1dbe.tar.xz
perf header: Validate nr_domains when reading HEADER_CPU_DOMAIN_INFO
Further validate the HEADER_CPU_DOMAIN_INFO fields, this time checking the nr_domains field. Assisted-by: Claude Code:claude-opus-4-6 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/header.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index c6efddb70aee..a2796b72adc4 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -3731,6 +3731,12 @@ static int process_cpu_domain_info(struct feat_fd *ff, void *data __maybe_unused
if (do_read_u32(ff, &nr_domains))
return -1;
+ if (nr_domains > max_sched_domains) {
+ pr_err("Invalid HEADER_CPU_DOMAIN_INFO: nr_domains %u > max_sched_domains (%u)\n",
+ nr_domains, max_sched_domains);
+ return -1;
+ }
+
cd_map[cpu]->nr_domains = nr_domains;
cd_map[cpu]->domains = calloc(max_sched_domains, sizeof(*d_info));