]> git.ipfire.org Git - thirdparty/linux.git/commit
perf tools: Fix uninitialized pathname on uncompressed fallback in filename__decompress()
authorArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 8 Jun 2026 01:43:09 +0000 (22:43 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 10 Jun 2026 21:56:01 +0000 (18:56 -0300)
commit51cdb188edeaf389e4377859b9c483c19ce5a259
tree70c7836ae6a822b27223793c8b2b065007c26630
parent1b4e9fbdeabc549965e70ac0cd8095d57ff6df06
perf tools: Fix uninitialized pathname on uncompressed fallback in filename__decompress()

filename__decompress() has an early return path for files that are not
actually compressed.  This path returns the fd from open() directly but
never writes to the pathname output parameter, leaving the caller with
an uninitialized buffer despite a successful return.

Callers like dso__decompress_kmodule_path() pass pathname to
decompress_kmodule() which uses it to set the decompressed file path.
If pathname is uninitialized, subsequent operations on the path produce
undefined behavior.

Fix by setting pathname to an empty string on the uncompressed path.
Callers already check for an empty pathname to distinguish temporary
decompressed files (which need unlink) from the original file.

Reported-by: sashiko-bot <sashiko-bot@kernel.org>
Fixes: 7ac22b088afe26a4 ("perf tools: Add filename__decompress function")
Cc: Jiri Olsa <jolsa@kernel.org>
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/tests/code-reading.c
tools/perf/util/disasm.c
tools/perf/util/dso.c
tools/perf/util/symbol-elf.c