[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260122171704.142218-1-suchitkarunakaran@gmail.com>
Date: Thu, 22 Jan 2026 22:47:04 +0530
From: Suchit Karunakaran <suchitkarunakaran@...il.com>
To: acme@...nel.org,
mingo@...hat.com,
namhyung@...nel.org,
peterz@...radead.org
Cc: adrian.hunter@...el.com,
alexander.shishkin@...ux.intel.com,
irogers@...gle.com,
james.clark@...aro.org,
jolsa@...nel.org,
mark.rutland@....com,
linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org,
Suchit Karunakaran <suchitkarunakaran@...il.com>
Subject: [PATCH] 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
Signed-off-by: Suchit Karunakaran <suchitkarunakaran@...il.com>
---
tools/perf/util/disasm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/disasm.c b/tools/perf/util/disasm.c
index 50b9433f3f8e..6faa9df8e373 100644
--- a/tools/perf/util/disasm.c
+++ b/tools/perf/util/disasm.c
@@ -81,7 +81,7 @@ static int arch__grow_instructions(struct arch *arch)
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;
}
--
2.52.0
Powered by blists - more mailing lists