aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Jihong <[email protected]>2023-04-27 01:28:41 +0000
committerArnaldo Carvalho de Melo <[email protected]>2023-05-02 08:36:14 -0300
commit1511e4696acb715a4fe48be89e1e691daec91c0e (patch)
tree60782347d56e4b40e8c105b418fe84abc35c17b0
parent6a7b57d85f4a6232d435eac945b325d9048f030c (diff)
perf symbols: Fix return incorrect build_id size in elf_read_build_id()
In elf_read_build_id(), if gnu build_id is found, should return the size of the actually copied data. If descsz is greater thanBuild_ID_SIZE, write_buildid data access may occur. Fixes: be96ea8ffa788dcc ("perf symbols: Fix issue with binaries using 16-bytes buildids (v2)") Reported-by: Will Ochowicz <[email protected]> Signed-off-by: Yang Jihong <[email protected]> Tested-by: Will Ochowicz <[email protected]> Acked-by: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Leo Yan <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Link: https://lore.kernel.org/lkml/CWLP265MB49702F7BA3D6D8F13E4B1A719C649@CWLP265MB4970.GBRP265.PROD.OUTLOOK.COM/T/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r--tools/perf/util/symbol-elf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 2a165d83aac4..ca75285aa656 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -886,7 +886,7 @@ static int elf_read_build_id(Elf *elf, void *bf, size_t size)
size_t sz = min(size, descsz);
memcpy(bf, ptr, sz);
memset(bf + sz, 0, size - sz);
- err = descsz;
+ err = sz;
break;
}
}