mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
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 commitd9f2ecbc5e("perf dso: Move build_id to dso_id") introduced the PERF_RECORD_MISC_MMAP_BUILD_ID check in perf_record_mmap2__read_build_id(). Commit53b00ff358("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>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
c7c92f76f9
commit
35b16a7a2c
@@ -703,6 +703,11 @@ static int perf_event__synthesize_modules_maps_cb(struct map *map, void *data)
|
|||||||
|
|
||||||
memcpy(event->mmap2.filename, dso__long_name(dso), dso__long_name_len(dso) + 1);
|
memcpy(event->mmap2.filename, dso__long_name(dso), dso__long_name_len(dso) + 1);
|
||||||
|
|
||||||
|
/* Clear stale build ID from previous module iteration */
|
||||||
|
event->mmap2.header.misc &= ~PERF_RECORD_MISC_MMAP_BUILD_ID;
|
||||||
|
memset(event->mmap2.build_id, 0, sizeof(event->mmap2.build_id));
|
||||||
|
event->mmap2.build_id_size = 0;
|
||||||
|
|
||||||
perf_record_mmap2__read_build_id(&event->mmap2, args->machine, false);
|
perf_record_mmap2__read_build_id(&event->mmap2, args->machine, false);
|
||||||
} else {
|
} else {
|
||||||
size = PERF_ALIGN(dso__long_name_len(dso) + 1, sizeof(u64));
|
size = PERF_ALIGN(dso__long_name_len(dso) + 1, sizeof(u64));
|
||||||
|
|||||||
Reference in New Issue
Block a user