All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vince Weaver <vincent.weaver@maine.edu>
To: Arnaldo Carvalho de Melo <arnaldo.melo@gmail.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>,
	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: Fri, 23 Aug 2019 16:42:47 -0400 (EDT)	[thread overview]
Message-ID: <alpine.DEB.2.21.1908231641170.7106@macbook-air> (raw)
In-Reply-To: <20190726190541.GC20482@kernel.org>

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?
> 
> - Arnaldo
> 
> >  		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?

This is actually an exploitable security bug if you can convince someone 
to run "perf" on an untrusted perf.data file.

Vince

  reply	other threads:[~2019-08-23 20:42 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 [this message]
2019-08-25 14:33       ` Arnaldo Carvalho de Melo
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=alpine.DEB.2.21.1908231641170.7106@macbook-air \
    --to=vincent.weaver@maine.edu \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=arnaldo.melo@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --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.