All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Markus Trippelsdorf <markus@trippelsdorf.de>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>
Subject: Re: *** buffer overflow detected ***: /usr/src/linux/tools/perf/perf terminated
Date: Mon, 19 Dec 2016 15:37:16 -0300	[thread overview]
Message-ID: <20161219183716.GB551@kernel.org> (raw)
In-Reply-To: <20161219172842.GB289@x4>

Em Mon, Dec 19, 2016 at 06:28:42PM +0100, Markus Trippelsdorf escreveu:
> On 2016.12.19 at 17:52 +0100, Markus Trippelsdorf wrote:
> > On 2016.12.19 at 17:18 +0100, Markus Trippelsdorf wrote:
> > > Running the latest kernel git tree, I get buffer overflow warnings when
> > > I try to run "perf top":
> > > 
> > > *** buffer overflow detected ***: /usr/src/linux/tools/perf/perf terminated        
> > 
> > It only happens when I link my kernel with gold.
<SNIP>
> > And perf than chokes when parsing /sys/kernel/notes.
> 
> Started with gold commit:
> 
>  commit bfbf34de2f27672282d4fa4c0916cc41890dcc6c
>  Author: Cary Coutant <ccoutant@gmail.com>
>  Date:   Mon Dec 12 18:51:29 2016 -0800
> 
>     When using linker scripts, place linker-generated sections by the output section name.
> 
> I've opened a gold bug:
> https://sourceware.org/bugzilla/show_bug.cgi?id=20983

I guess we need something along the lines of below, but I think the max
should be set to the filesize, have to spend some more time here, using
stat() in such case, etc, wdyt?

- Arnaldo

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 99400b0e8f2a..adbc6c02c3aa 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -537,6 +537,12 @@ int sysfs__read_build_id(const char *filename, void *build_id, size_t size)
 				break;
 		} else {
 			int n = namesz + descsz;
+
+			if (n > (int)sizeof(bf)) {
+				n = sizeof(bf);
+				pr_debug("%s: truncating reading of build id in sysfs file %s: n_namesz=%u, n_descsz=%u.\n",
+					 __func__, filename, nhdr.n_namesz, nhdr.n_descsz);
+			}
 			if (read(fd, bf, n) != n)
 				break;
 		}

      reply	other threads:[~2016-12-19 18:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-19 16:18 *** buffer overflow detected ***: /usr/src/linux/tools/perf/perf terminated Markus Trippelsdorf
2016-12-19 16:52 ` Markus Trippelsdorf
2016-12-19 17:28   ` Markus Trippelsdorf
2016-12-19 18:37     ` Arnaldo Carvalho de Melo [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=20161219183716.GB551@kernel.org \
    --to=acme@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markus@trippelsdorf.de \
    --cc=mingo@redhat.com \
    /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 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.