All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Trippelsdorf <markus@trippelsdorf.de>
To: linux-kernel@vger.kernel.org
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Ingo Molnar <mingo@redhat.com>
Subject: Re: *** buffer overflow detected ***: /usr/src/linux/tools/perf/perf terminated
Date: Mon, 19 Dec 2016 17:52:43 +0100	[thread overview]
Message-ID: <20161219165243.GA289@x4> (raw)
In-Reply-To: <20161219161821.GA294@x4>

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        
> 
> __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
> 51      }
> (gdb) bt
> #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
> #1  0x00007ffff5f29cbb in __GI_abort () at abort.c:89
> #2  0x00007ffff5f6f553 in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=0x7ffff6056455 "*** %s ***: %s terminated\n") at ../sysdeps/posix/libc_fatal.c:175
> #3  0x00007ffff600d8c7 in __GI___fortify_fail (msg=msg@entry=0x7ffff60563ec "buffer overflow detected") at fortify_fail.c:30
> #4  0x00007ffff600b790 in __GI___chk_fail () at chk_fail.c:28
> #5  0x00007ffff600bc35 in __read_chk (fd=fd@entry=3, buf=buf@entry=0x7fffffff48f0, nbytes=nbytes@entry=1572864, buflen=buflen@entry=8192) at read_chk.c:30
> #6  0x00000000004fafc4 in read (__nbytes=1572864, __buf=0x7fffffff48f0, __fd=3) at /usr/include/bits/unistd.h:39
> #7  sysfs__read_build_id (filename=filename@entry=0x7fffffff6940 "/sys/kernel/notes", build_id=build_id@entry=0x1db5e34, size=size@entry=20) at util/symbol-elf.c:540
> #8  0x00000000004a8c22 in dso__read_running_kernel_build_id (dso=dso@entry=0x1db5d70, machine=machine@entry=0x1db5ab8) at util/dso.c:1152
> #9  0x00000000004b875a in machine__get_kernel (machine=machine@entry=0x1db5ab8) at util/machine.c:715
> #10 0x00000000004ba0ab in machine__create_kernel_maps (machine=machine@entry=0x1db5ab8) at util/machine.c:1127
> #11 0x00000000004bf169 in perf_session__create_kernel_maps (session=session@entry=0x1db59d0) at util/session.c:70
> #12 0x00000000004bf43b in perf_session__new (file=file@entry=0x0, repipe=repipe@entry=false, tool=tool@entry=0x0) at util/session.c:154
> #13 0x0000000000441eca in __cmd_top (top=0x7fffffff8a70) at builtin-top.c:925
> #14 cmd_top (argc=<optimized out>, argv=<optimized out>, prefix=<optimized out>) at builtin-top.c:1330
> #15 0x0000000000487481 in run_builtin (p=p@entry=0x679d78 <commands+312>, argc=argc@entry=2, argv=argv@entry=0x7fffffffe4c0) at perf.c:358
> #16 0x0000000000487722 in handle_internal_command (argc=2, argv=0x7fffffffe4c0) at perf.c:420
> #17 0x0000000000487982 in run_argv (argv=0x7fffffffe250, argcp=0x7fffffffe25c) at perf.c:466
> #18 main (argc=<optimized out>, argv=<optimized out>) at perf.c:610
> 
> (gdb) up
> #7  sysfs__read_build_id (filename=filename@entry=0x7fffffff6940 "/sys/kernel/notes", build_id=build_id@entry=0x1db5e34, size=size@entry=20) at util/symbol-elf.c:540
> 540                             if (read(fd, bf, n) != n)
> (gdb) l
> 535                                     }
> 536                             } else if (read(fd, bf, descsz) != (ssize_t)descsz)
> 537                                     break;
> 538                     } else {
> 539                             int n = namesz + descsz;
> 540                             if (read(fd, bf, n) != n)
> 541                                     break;
> 542                     }
> 543             }
> 544             close(fd);
> 
> (gdb) p n
> $4 = 1572864
> (gdb) p BUFSIZ
> $5 = 8192

It only happens when I link my kernel with gold.

(with ld.bfd)
markus@x4 linux % readelf -n vmlinux

Displaying notes found in: .notes
  Owner                 Data size       Description
  GNU                  0x00000014       NT_GNU_BUILD_ID (unique build ID bitstring)
    Build ID: 74b478c2194c0ba07481acf30f6f8781d4ffcdee

(with ld.gold)
markus@x4 linux % readelf -n vmlinux

Displaying notes found in: .note.gnu.build-id
  Owner                 Data size       Description
  GNU                  0x00000014       NT_GNU_BUILD_ID (unique build ID bitstring)
    Build ID: 017ef6e6f8ce3b44332d0baa0767526bb3a77bf8

Displaying notes found in: .note.gnu.gold-version
  Owner                 Data size       Description
  GNU                  0x00000009       NT_GNU_GOLD_VERSION (gold version)
    Version: gold 1.12

And perf than chokes when parsing /sys/kernel/notes.

-- 
Markus

  reply	other threads:[~2016-12-19 16:52 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 [this message]
2016-12-19 17:28   ` Markus Trippelsdorf
2016-12-19 18:37     ` Arnaldo Carvalho de Melo

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=20161219165243.GA289@x4 \
    --to=markus@trippelsdorf.de \
    --cc=acme@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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.