linux/tools/perf
Chuck Lever 35b16a7a2c perf synthetic-events: Fix stale build ID in module MMAP2 records
perf_event__synthesize_modules() allocates a single union perf_event and
reuses it across every kernel module callback.

After the first module is processed, perf_record_mmap2__read_build_id()
sets PERF_RECORD_MISC_MMAP_BUILD_ID in header.misc and writes that
module's build ID into the event.

On subsequent iterations the callback overwrites start, len, pid, and
filename for the next module but never clears the stale build ID fields
or the MMAP_BUILD_ID flag.

When perf_record_mmap2__read_build_id() runs for the second module it
sees the flag, reads the stale build ID into a dso_id, and
__dso__improve_id() permanently poisons the DSO with the wrong build ID.

Every module after the first therefore receives the first module's build
ID in its MMAP2 record.

On a system with the sunrpc and nfsd modules loaded, this causes perf
script and perf report to show [unknown] for all module symbols.

The latent bug has existed since commit d9f2ecbc5e ("perf dso:
Move build_id to dso_id") introduced the PERF_RECORD_MISC_MMAP_BUILD_ID
check in perf_record_mmap2__read_build_id().

Commit 53b00ff358 ("perf record: Make --buildid-mmap the default")
then exposed it to all users by making the MMAP2-with-build-ID path the
default.  Both commits were merged in the same series.

Clear the MMAP_BUILD_ID flag and zero the build_id union before each
call to perf_record_mmap2__read_build_id() so that every module starts
with a clean slate.

Fixes: d9f2ecbc5e ("perf dso: Move build_id to dso_id")
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2026-03-11 17:47:42 -03:00
..
Documentation perf tools changes for v7.0: 2026-02-21 10:51:08 -08:00
arch perf cs-etm: Finish removal of ETM_OPT_* 2026-03-10 09:50:44 -03:00
bench perf tools: Switch printf("...%s", strerror(errno)) to printf("...%m") 2026-01-14 17:22:50 -03:00
check-header_ignore_hunks/lib
dlfilters
include/perf
jvmti perf tools: Use const for variables receiving str{str,r?chr}() returns 2025-12-17 09:30:37 -03:00
pmu-events perf build: Prevent "argument list too long" error 2026-03-04 11:22:31 -03:00
python
scripts perf script: Fix script_fetch_insn for more than just x86 2026-01-27 01:35:22 -03:00
tests perf tools changes for v7.0: 2026-02-21 10:51:08 -08:00
trace perf beauty: Update the arch/x86/include/asm/irq_vectors.h copy with the kernel sources 2026-03-04 11:49:24 -03:00
ui perf disasm: Refactor arch__find and initialization of arch structs 2026-01-23 16:58:39 -03:00
util perf synthetic-events: Fix stale build ID in module MMAP2 records 2026-03-11 17:47:42 -03:00
.gitignore perf jevents: Build support for generating metrics from python 2026-01-28 15:18:44 -03:00
Build
CREDITS
MANIFEST
Makefile
Makefile.config tools build: Fix rust cross compilation 2026-03-04 11:37:30 -03:00
Makefile.perf tools build: Fix rust cross compilation 2026-03-04 11:37:30 -03:00
builtin-annotate.c
builtin-bench.c
builtin-buildid-cache.c perf symbol: Fix ENOENT case for filename__read_build_id 2025-12-17 07:30:51 -08:00
builtin-buildid-list.c
builtin-c2c.c
builtin-check.c perf check: Add libbabeltrace to the listed features 2026-02-12 17:45:22 -03:00
builtin-config.c
builtin-daemon.c perf tools: Switch printf("...%s", strerror(errno)) to printf("...%m") 2026-01-14 17:22:50 -03:00
builtin-data.c perf data: Allow filtering conversion by time range 2026-01-06 19:20:02 -03:00
builtin-diff.c perf diff: Constify strchr() return variables 2025-12-17 09:30:37 -03:00
builtin-evlist.c
builtin-ftrace.c perf ftrace: Fix hashmap__new() error checking 2026-03-10 11:53:27 -03:00
builtin-help.c perf help: Move common_cmds into builtin-help 2026-01-14 17:22:50 -03:00
builtin-inject.c perf inject: With --convert-callchain ignore the dummy event for dwarf stacks 2026-01-23 16:58:39 -03:00
builtin-kallsyms.c
builtin-kmem.c
builtin-kvm.c perf session: Add e_flags to the e_machine helper 2026-02-03 18:01:27 -03:00
builtin-kwork.c
builtin-list.c Merge remote-tracking branch 'torvalds/master' into perf-tools-next 2026-01-26 17:03:53 -03:00
builtin-lock.c
builtin-mem.c
builtin-probe.c perf tools: Switch printf("...%s", strerror(errno)) to printf("...%m") 2026-01-14 17:22:50 -03:00
builtin-record.c perf record: Make logs more readable for event open failures 2026-02-06 11:53:10 -03:00
builtin-report.c perf session: Add e_flags to the e_machine helper 2026-02-03 18:01:27 -03:00
builtin-sched.c perf sched stats: Define macro for SEP_LEN 2026-01-28 15:18:39 -03:00
builtin-script.c perf script: Allow the generated script to be a path 2026-02-12 17:45:22 -03:00
builtin-stat.c perf stat: Add no-affinity flag 2026-02-10 09:35:28 -03:00
builtin-timechart.c
builtin-top.c
builtin-trace.c perf thread: Add optional e_flags output argument to thread__e_machine 2026-01-26 18:21:20 -03:00
builtin-version.c
builtin.h
check-headers.sh tools headers: Don't check arm64's unistd.h 2026-01-26 17:09:31 -03:00
design.txt
perf-archive.sh
perf-completion.sh
perf-iostat.sh
perf-read-vdso.c
perf-sys.h
perf.c perf tools: Switch printf("...%s", strerror(errno)) to printf("...%m") 2026-01-14 17:22:50 -03:00
perf.h