From: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
To: Vince Weaver <vincent.weaver@maine.edu>
Cc: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>,
linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>
Subject: Re: [patch] perf tool buffer overflow in perf_header__read_build_ids
Date: Sun, 25 Aug 2019 11:33:02 -0300 [thread overview]
Message-ID: <20190825143302.GE26569@kernel.org> (raw)
In-Reply-To: <alpine.DEB.2.21.1908231641170.7106@macbook-air>
Em Fri, Aug 23, 2019 at 04:42:47PM -0400, Vince Weaver escreveu:
> On Fri, 26 Jul 2019, Arnaldo Carvalho de Melo wrote:
> > Em Tue, Jul 23, 2019 at 04:42:30PM -0400, Vince Weaver escreveu:
> > > my perf_tool_fuzzer has found another issue, this one a buffer overflow
> > > in perf_header__read_build_ids. The build id filename is read in with a
> > > filename length read from the perf.data file, but this can be longer than
> > > PATH_MAX which will smash the stack.
> > >
> > > This might not be the right fix, not sure if filename should be NUL
> > > terminated or not.
> > >
> > > Signed-off-by: Vince Weaver <vincent.weaver@maine.edu>
> > >
> > > diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> > > index c24db7f4909c..9a893a26e678 100644
> > > --- a/tools/perf/util/header.c
> > > +++ b/tools/perf/util/header.c
> > > @@ -2001,6 +2001,9 @@ static int perf_header__read_build_ids(struct perf_header *header,
> > > perf_event_header__bswap(&bev.header);
> > >
> > > len = bev.header.size - sizeof(bev);
> > > +
> > > + if (len>PATH_MAX) len=PATH_MAX;
> > > +
> >
> > Humm, I wonder if we shouldn't just declare the whole file invalid like
> > you did with the previous patch?
> > > if (readn(input, filename, len) != len)
> > > goto out;
> > > /*
>
> did we ever decide how to fix this issue? Or were you waiting on a
> followup patch from me?
Fell thru the cracks, but yeah, I was waiting for a patch, can you send
it?
- Arnaldo
> This is actually an exploitable security bug if you can convince someone
> to run "perf" on an untrusted perf.data file.
Indeed, and in light of the current discussion about unprivileged eBPF I
think we should start dropping privileges in perf report, etc.
- Arnaldo
next prev parent reply other threads:[~2019-08-25 14:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-23 15:06 [patch] perf tool divide by zero error if f_header.attr_size==0 Vince Weaver
2019-07-23 15:17 ` Arnaldo Carvalho de Melo
2019-07-23 20:42 ` [patch] perf tool buffer overflow in perf_header__read_build_ids Vince Weaver
2019-07-26 19:05 ` Arnaldo Carvalho de Melo
2019-08-23 20:42 ` Vince Weaver
2019-08-25 14:33 ` Arnaldo Carvalho de Melo [this message]
2019-07-26 19:00 ` [patch] perf tool divide by zero error if f_header.attr_size==0 Arnaldo Carvalho de Melo
2019-07-29 21:34 ` [tip:perf/urgent] perf header: Fix " tip-bot for Vince Weaver
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=20190825143302.GE26569@kernel.org \
--to=arnaldo.melo@gmail.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=vincent.weaver@maine.edu \
/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.