linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yang Jihong <yangjihong1@huawei.com>
To: Will Ochowicz <Will.Ochowicz@genusplc.com>,
	"linux-perf-users@vger.kernel.org"
	<linux-perf-users@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: Bug: "perf record" reporting buffer overflow when writing data
Date: Thu, 27 Apr 2023 09:18:49 +0800	[thread overview]
Message-ID: <2a7fd858-1639-53a7-bc65-d4f65a9eed2f@huawei.com> (raw)
In-Reply-To: <CWLP265MB4970C9D9667C9419567243409C659@CWLP265MB4970.GBRP265.PROD.OUTLOOK.COM>

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.

      parent reply	other threads:[~2023-04-27  1:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-25 16:54 Bug: "perf record" reporting buffer overflow when writing data Will Ochowicz
2023-04-26  2:14 ` Yang Jihong
     [not found]   ` <CWLP265MB4970C9D9667C9419567243409C659@CWLP265MB4970.GBRP265.PROD.OUTLOOK.COM>
2023-04-27  1:18     ` Yang Jihong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a7fd858-1639-53a7-bc65-d4f65a9eed2f@huawei.com \
    --to=yangjihong1@huawei.com \
    --cc=Will.Ochowicz@genusplc.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).