public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Stephane Eranian <eranian@google.com>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu, jolsa@redhat.com,
	fweisbec@gmail.com
Subject: Re: [PATCH v2] perf: fix ring_buffer perf_output_space() boundary calculation
Date: Tue, 19 Mar 2013 13:35:02 +0100	[thread overview]
Message-ID: <1363696502.22553.38.camel@laptop> (raw)
In-Reply-To: <20130318133327.GA3056@quad>

On Mon, 2013-03-18 at 14:33 +0100, Stephane Eranian wrote:
> This patch fixes a flaw in perf_output_space(). In case the size
> of the space needed is bigger than the actual buffer size, there
> may be situations where the function would return true (i.e., there
> is space) when it should not. head > offset due to rounding of the
> masking logic.
> 
> The problem can be tested by activating BTS on Intel processors.
> A BTS record can be as big as 16 pages. The following command
> fails:
> 
> $ perf record -m 4 -c 1 -e branches:u my_test_program
> 
> You will get a buffer corruption with this. Perf report won't be
> able to parse the perf.data.
> 
> The fix is to first check that the requested space is smaller than the
> buffer size. If so, then the masking logic will work fine. If not,
> then
> there is no chance the record can be saved and it will be gracefully
> handled
> by upper code layers.
> 
> In v2, we also make the logic for the writable more explicit by
> renaming it to rb->overwrite because it tells whether or not the
> buffer can overwrite its tail (suggested by PeterZ).
> 
> Signed-off-by: Stephane Eranian <eranian@google.com>
> ---

Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>

Thanks!


  reply	other threads:[~2013-03-19 12:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-18 13:33 [PATCH v2] perf: fix ring_buffer perf_output_space() boundary calculation Stephane Eranian
2013-03-19 12:35 ` Peter Zijlstra [this message]
2013-03-21 18:16 ` [tip:perf/urgent] perf: Fix " tip-bot for Stephane Eranian

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=1363696502.22553.38.camel@laptop \
    --to=peterz@infradead.org \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox