All of lore.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, ak@linux.intel.com,
	jolsa@redhat.com
Subject: Re: [PATCH] perf: check branch sampling priv level in generic code
Date: Tue, 21 May 2013 13:08:58 +0200	[thread overview]
Message-ID: <20130521110858.GH26912@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20130521105337.GA2879@quad>

On Tue, May 21, 2013 at 12:53:37PM +0200, Stephane Eranian wrote:
> 
> This patch reverts commit 7cc23cd:
>  perf/x86/intel/lbr: Demand proper privileges for PERF_SAMPLE_BRANCH_KERNEL
> 
> The check is now implemented in generic code
> instead of x86 specific code. That way we
> do not have to repeat the test in each arch
> supporting branch sampling.

Good point indeed.

> Signed-off-by: Stephane Eranian <eranian@google.com>
> ---
>  arch/x86/kernel/cpu/perf_event_intel_lbr.c |   13 +++----------
>  kernel/events/core.c                       |    9 ++++-----
>  2 files changed, 7 insertions(+), 15 deletions(-)
> 

> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 9dc297f..cf79c81 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -6327,11 +6327,6 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
>  		if (!(mask & ~PERF_SAMPLE_BRANCH_PLM_ALL))
>  			return -EINVAL;
>  
> -		/* kernel level capture: check permissions */
> -		if ((mask & PERF_SAMPLE_BRANCH_PERM_PLM)
> -		    && perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))
> -			return -EACCES;
> -

Oh hey, there was a check.. 

>  		/* propagate priv level, when not set for branch */
>  		if (!(mask & PERF_SAMPLE_BRANCH_PLM_ALL)) {
>  
> @@ -6349,6 +6344,10 @@ static int perf_copy_attr(struct perf_event_attr __user *uattr,
>  			 */
>  			attr->branch_sample_type = mask;
>  		}
> +		/* kernel level capture: check permissions */
> +		if ((mask & PERF_SAMPLE_BRANCH_KERNEL)
> +		    && perf_paranoid_kernel() && !capable(CAP_SYS_ADMIN))
> +			return -EACCES;
>  	}
>  
>  	if (attr->sample_type & PERF_SAMPLE_REGS_USER) {
> -- 
> 1.7.9.5
> 

  reply	other threads:[~2013-05-21 12:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-21 10:53 [PATCH] perf: check branch sampling priv level in generic code Stephane Eranian
2013-05-21 11:08 ` Peter Zijlstra [this message]
2013-05-21 12:38   ` Stephane Eranian
2013-05-28 13:01 ` [tip:perf/core] perf/x86: Check " 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=20130521110858.GH26912@twins.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=ak@linux.intel.com \
    --cc=eranian@google.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 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.