From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf buildid: fix off-by-one in write_buildid()
Date: Tue, 19 Apr 2016 10:40:56 -0300 [thread overview]
Message-ID: <20160419134056.GC3677@kernel.org> (raw)
In-Reply-To: <1461053847-5633-1-git-send-email-aryabinin@virtuozzo.com>
Em Tue, Apr 19, 2016 at 11:17:27AM +0300, Andrey Ryabinin escreveu:
> write_buildid() increments 'name_len' with intention to take into account
> trailing zero byte. However, 'name_len' was already incremented in
> machine__write_buildid_table() before.
> So this leads to out-of-bounds read in do_write():
Adrian, can you please take a look at the db-export improvements made in
this series? It'd be good to have your ack for those,
thanks!
- Arnaldo
> $ ./perf record sleep 0
> [ perf record: Woken up 1 times to write data ]
> =================================================================
> ==15899==ERROR: AddressSanitizer: global-buffer-overflow on address 0x00000099fc92 at pc 0x7f1aa9c7eab5 bp 0x7fff940f84d0 sp 0x7fff940f7c78
> READ of size 19 at 0x00000099fc92 thread T0
> #0 0x7f1aa9c7eab4 (/usr/lib/gcc/x86_64-pc-linux-gnu/5.3.0/libasan.so.2+0x44ab4)
> #1 0x649c5b in do_write util/header.c:67
> #2 0x649c5b in write_padded util/header.c:82
> #3 0x57e8bc in write_buildid util/build-id.c:239
> #4 0x57e8bc in machine__write_buildid_table util/build-id.c:278
> ...
>
> 0x00000099fc92 is located 0 bytes to the right of global variable '*.LC99' defined in 'util/symbol.c' (0x99fc80) of size 18
> '*.LC99' is ascii string '[kernel.kallsyms]'
> ...
>
> Shadow bytes around the buggy address:
> 0x00008012bf80: f9 f9 f9 f9 00 00 00 00 00 00 03 f9 f9 f9 f9 f9
> =>0x00008012bf90: 00 00[02]f9 f9 f9 f9 f9 00 00 00 00 00 05 f9 f9
> 0x00008012bfa0: f9 f9 f9 f9 00 03 f9 f9 f9 f9 f9 f9 00 00 00 00
>
> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
> ---
> tools/perf/util/build-id.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
> index 0573c2e..a1ff68b 100644
> --- a/tools/perf/util/build-id.c
> +++ b/tools/perf/util/build-id.c
> @@ -235,7 +235,7 @@ static int write_buildid(const char *name, size_t name_len, u8 *build_id,
> if (err < 0)
> return err;
>
> - return write_padded(fd, name, name_len + 1, len);
> + return write_padded(fd, name, name_len, len);
> }
>
> static int machine__write_buildid_table(struct machine *machine, int fd)
> --
> 2.7.3
next prev parent reply other threads:[~2016-04-19 13:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-19 8:17 [PATCH] perf buildid: fix off-by-one in write_buildid() Andrey Ryabinin
2016-04-19 13:38 ` Arnaldo Carvalho de Melo
2016-04-19 15:48 ` Andrey Ryabinin
2016-04-19 13:40 ` Arnaldo Carvalho de Melo [this message]
2016-04-20 12:36 ` Adrian Hunter
2016-04-20 13:23 ` Arnaldo Carvalho de Melo
2016-04-27 15:28 ` [tip:perf/core] perf buildid: Fix " tip-bot for Andrey Ryabinin
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=20160419134056.GC3677@kernel.org \
--to=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=aryabinin@virtuozzo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.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 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.