Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1544733

Re: *** buffer overflow detected ***: /usr/src/linux/tools/perf/perf terminated

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject Re: *** buffer overflow detected ***: /usr/src/linux/tools/perf/perf terminated
Date 2016-12-19 19:40 +0100
Message-ID <sQb0S-33f-19@gated-at.bofh.it> (permalink)
References <sQ8Po-1KN-25@gated-at.bofh.it> <sQ9s5-20e-3@gated-at.bofh.it> <sQ9V7-2r7-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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;
 		}

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

*** buffer overflow detected ***: /usr/src/linux/tools/perf/perf  terminated Markus Trippelsdorf <markus@trippelsdorf.de> - 2016-12-19 17:20 +0100
  Re: *** buffer overflow detected ***: /usr/src/linux/tools/perf/perf  terminated Markus Trippelsdorf <markus@trippelsdorf.de> - 2016-12-19 18:00 +0100
    Re: *** buffer overflow detected ***: /usr/src/linux/tools/perf/perf  terminated Markus Trippelsdorf <markus@trippelsdorf.de> - 2016-12-19 18:30 +0100
      Re: *** buffer overflow detected ***: /usr/src/linux/tools/perf/perf  terminated Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-12-19 19:40 +0100

csiph-web