From: Suchit Karunakaran Date: Thu, 22 Jan 2026 17:17:04 +0000 (+0530) Subject: perf annotate: Fix memcpy size in arch__grow_instructions() X-Git-Tag: v7.0-rc1~16^2~129 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0d98c78f8bf73ce2a9b7793f66cda240fa9ab10;p=thirdparty%2Flinux.git perf annotate: Fix memcpy size in arch__grow_instructions() The memcpy() in arch__grow_instructions() is copying the wrong number of bytes when growing from a non-allocated table. It should copy arch->nr_instructions * sizeof(struct ins) bytes, not just arch->nr_instructions bytes. This bug causes data corruption as only a partial copy of the instruction table is made, leading to garbage data in most entries and potential crashes Fixes: 2a1ff812c40be982 ("perf annotate: Introduce alternative method of keeping instructions table") Reviewed-by: Ian Rogers Signed-off-by: Suchit Karunakaran Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Ingo Molnar Cc: James Clark Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c index 4f60726247d6..9b0ba1fc5aec 100644 --- a/tools/perf/util/disasm.c +++ b/tools/perf/util/disasm.c @@ -82,7 +82,7 @@ grow_from_non_allocated_table: if (new_instructions == NULL) return -1; - memcpy(new_instructions, arch->instructions, arch->nr_instructions); + memcpy(new_instructions, arch->instructions, arch->nr_instructions * sizeof(struct ins)); goto out_update_instructions; }