Re: Bug: "perf record" reporting buffer overflow when writing data
From: Yang Jihong
Date: Wed Apr 26 2023 - 21:19:29 EST
Hello,
On 2023/4/26 20:52, Will Ochowicz wrote:
Hi Yang,
1. Displaying notes found in: .note.gnu.build-id
Owner Data size Description
GNU 0x00000028 NT_GNU_BUILD_ID (unique
build ID bitstring)
Build ID:
6236326637343061343961353463366632643232333465366562353039656634
3938656130663039
2. That patch did fix the issue.
Thanks for your test to help confirm the problem.
I'll send a fix patch.
Would you mind giving me a quick explanation of the issue for my own
edification?
According to the coredump stack trace, the following code causes the
out-of-bounds access problem:
#7 0x00005555557e7ddd in memcpy (__len=40, __src=0x555556a28b38,
__dest=0x7fffffff843c) at
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:29
#8 write_buildid (fd=0x7fffffff8590, misc=<optimized out>, pid=-1,
bid=0x555556a28b38, name_len=<optimized out>, name=0x555556a28c0c
"/opt/pylon/lib/libpylonbase-6.1.1.so") at util/build-id.c:312
That is, an error occurred when writing the build_id of the
"/opt/pylon/lib/libpylonbase-6.1.1.so" file.
The corresponding code is as follows:
write_buildid()
{
...
memcpy(&b.data, bid->data, bid->size);
...
}
b.data is an array whose size is Build_ID_SIZE(20), but bid->size is
greater than this value. Check the perf code and find this problem.
Thanks,
Yang.