All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf symbols: Fix return incorrect build_id size in elf_read_build_id()
@ 2023-04-27  1:28 Yang Jihong
  2023-04-27  6:02 ` Adrian Hunter
  0 siblings, 1 reply; 4+ messages in thread
From: Yang Jihong @ 2023-04-27  1:28 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
	namhyung, irogers, adrian.hunter, leo.yan, eranian,
	linux-perf-users, linux-kernel
  Cc: yangjihong1

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: be96ea8ffa78 ("perf symbols: Fix issue with binaries using 16-bytes buildids (v2)")
Reported-by: Will Ochowicz <Will.Ochowicz@genusplc.com>
Link: https://lore.kernel.org/lkml/CWLP265MB49702F7BA3D6D8F13E4B1A719C649@CWLP265MB4970.GBRP265.PROD.OUTLOOK.COM/T/
Tested-by: Will Ochowicz <Will.Ochowicz@genusplc.com>
Signed-off-by: Yang Jihong <yangjihong1@huawei.com>
---
 tools/perf/util/symbol-elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 41882ae8452e..059f88eca630 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -903,7 +903,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;
 			}
 		}
-- 
2.30.GIT


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-04-29  1:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-27  1:28 [PATCH] perf symbols: Fix return incorrect build_id size in elf_read_build_id() Yang Jihong
2023-04-27  6:02 ` Adrian Hunter
2023-04-27  7:27   ` Yang Jihong
2023-04-29  1:31   ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.