aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Rogers <irogers@google.com>2025-07-24 09:32:42 -0700
committerNamhyung Kim <namhyung@kernel.org>2025-07-24 13:50:17 -0700
commit5a2ceebd8175874ae0e91a304ad6600d82806973 (patch)
treec14b1773a389496d95238ee8e339f7a4f7f7f165
parentperf build-id: Reduce size of "size" variable (diff)
downloadlinux-5a2ceebd8175874ae0e91a304ad6600d82806973.tar.gz
linux-5a2ceebd8175874ae0e91a304ad6600d82806973.zip
perf build-id: Truncate to avoid overflowing the build_id data
Warning when the build_id data would be overflowed would lead to memory corruption, switch to truncation. Signed-off-by: Ian Rogers <irogers@google.com> Link: https://lore.kernel.org/r/20250724163302.596743-3-irogers@google.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
-rw-r--r--tools/perf/util/build-id.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index e763e8d99a43..5bc2040bdd0d 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -951,7 +951,10 @@ bool perf_session__read_build_ids(struct perf_session *session, bool with_hits)
void build_id__init(struct build_id *bid, const u8 *data, size_t size)
{
- WARN_ON(size > BUILD_ID_SIZE);
+ if (size > BUILD_ID_SIZE) {
+ pr_debug("Truncating build_id size from %zd\n", size);
+ size = BUILD_ID_SIZE;
+ }
memcpy(bid->data, data, size);
bid->size = size;
}