summaryrefslogtreecommitdiff
path: root/tools/perf
diff options
context:
space:
mode:
authorSuchit Karunakaran <suchitkarunakaran@gmail.com>2026-01-22 20:17:04 +0300
committerSasha Levin <sashal@kernel.org>2026-03-04 15:19:26 +0300
commit0abe77dcaca79cefd5bd3f124e16520d37184b61 (patch)
tree30fdb23759abcf0f6c99f0d32e34828d76e6452c /tools/perf
parent59a7c3c9c3128a4e2d8c85185a4c8ea4ff5c1300 (diff)
downloadlinux-0abe77dcaca79cefd5bd3f124e16520d37184b61.tar.xz
perf annotate: Fix memcpy size in arch__grow_instructions()
[ Upstream commit f0d98c78f8bf73ce2a9b7793f66cda240fa9ab10 ] 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 <irogers@google.com> Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/disasm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
index 924429142631..88706b98b906 100644
--- a/tools/perf/util/disasm.c
+++ b/tools/perf/util/disasm.c
@@ -81,7 +81,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;
}