Skip to content

Commit 5a2ceeb

Browse files
captain5050namhyung
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Namhyung Kim <[email protected]>
1 parent f398238 commit 5a2ceeb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tools/perf/util/build-id.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,10 @@ bool perf_session__read_build_ids(struct perf_session *session, bool with_hits)
951951

952952
void build_id__init(struct build_id *bid, const u8 *data, size_t size)
953953
{
954-
WARN_ON(size > BUILD_ID_SIZE);
954+
if (size > BUILD_ID_SIZE) {
955+
pr_debug("Truncating build_id size from %zd\n", size);
956+
size = BUILD_ID_SIZE;
957+
}
955958
memcpy(bid->data, data, size);
956959
bid->size = size;
957960
}

0 commit comments

Comments
 (0)