[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20161219183716.GB551@kernel.org>
Date: Mon, 19 Dec 2016 15:37:16 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Markus Trippelsdorf <markus@...ppelsdorf.de>
Cc: linux-kernel@...r.kernel.org, Ingo Molnar <mingo@...hat.com>
Subject: Re: *** buffer overflow detected ***: /usr/src/linux/tools/perf/perf
terminated
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@...il.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;
}
Powered by blists - more mailing lists