]> git.ipfire.org Git - thirdparty/linux.git/commit
perf header: Validate build_id filename length to prevent buffer overflow
authorSeungJu Cheon <suunj1331@gmail.com>
Thu, 2 Apr 2026 16:04:10 +0000 (01:04 +0900)
committerNamhyung Kim <namhyung@kernel.org>
Fri, 3 Apr 2026 01:11:24 +0000 (18:11 -0700)
commit85a9a4abcdc09ee941273c99d3ad0bc2ddef09ea
tree2995c7457f0cc408e5a78457b0fa9e504d1ca242
parente0f4767bf403131f7ec7378d0d23ad6c29b01936
perf header: Validate build_id filename length to prevent buffer overflow

The build_id parsing functions calculate a filename length from the
event header size and read directly into a stack buffer of PATH_MAX
bytes without bounds checking. A malformed perf.data file with a
crafted header.size can cause the length to be negative or exceed
PATH_MAX, resulting in a stack buffer overflow.

Add bounds checking for the filename length in both
perf_header__read_build_ids() and the ABI quirk variant. Print a
warning message when invalid length is detected.

Signed-off-by: SeungJu Cheon <suunj1331@gmail.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/header.c