[PATCHES perf-tools-next v1 00/13] Sanity check perf.data headers

From: Arnaldo Carvalho de Melo

Date: Thu Apr 09 2026 - 20:40:30 EST


Hi,

Sashiko recently mentioned the lack of sanity checking headers
in perf.data files, that with a fuzzy or maliciously crafted file could
make processing a perf.data file cause deleterious results.

Add sanity checks and some arbitrarily generous upper limits to
headers, if some are found to be questionable, lets tweak them in
upcoming versions of this patchset.

As registered in the Assisted-by tags in the patches, this was
done using Claude code to speed up development, hopefully no
hallucinations are present.

I'm also trying to get some of these checks into review-prompts
skills, some of which were already merged, for instance:

https://github.com/masoncl/review-prompts/commit/2bb2159893ea926e120105416e95629b9ef1508c

Thanks,

- Arnaldo

Arnaldo Carvalho de Melo (13):
perf header: Validate nr_domains when reading HEADER_CPU_DOMAIN_INFO
perf header: Bump up the max number of command line args allowed
perf header: Sanity check HEADER_NRCPUS and HEADER_CPU_DOMAIN_INFO
perf header: Sanity check HEADER_CPU_TOPOLOGY
perf header: Sanity check HEADER_NUMA_TOPOLOGY
perf header: Sanity check HEADER_MEM_TOPOLOGY
perf header: Sanity check HEADER_PMU_MAPPINGS
perf header: Sanity check HEADER_GROUP_DESC
perf header: Sanity check HEADER_CACHE
perf header: Sanity check HEADER_HYBRID_TOPOLOGY
perf header: Sanity check HEADER_PMU_CAPS
perf header: Sanity check HEADER_BPF_PROG_INFO
perf header: Add sanity checks to HEADER_BPF_BTF processing

tools/perf/util/header.c | 219 +++++++++++++++++++++++++++++++++++++--
1 file changed, 213 insertions(+), 6 deletions(-)

--
2.53.0