From: Peter Zijlstra <peterz@infradead.org>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Yarygin <yarygin@linux.vnet.ibm.com>,
Arnaldo Carvalho de Melo <acme@kernel.com>,
Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
Christian Borntraeger <borntraeger@de.ibm.com>,
linux-kernel@vger.kernel.org
Subject: Re: [BUG] perf stat: events inheritance can break task targets
Date: Mon, 7 Jul 2014 21:46:35 +0200 [thread overview]
Message-ID: <20140707194635.GZ6758@twins.programming.kicks-ass.net> (raw)
In-Reply-To: <20140707170040.GB2070@krava.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1516 bytes --]
On Mon, Jul 07, 2014 at 07:00:40PM +0200, Jiri Olsa wrote:
> diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
> index 5d12bb4..b44184b 100644
> --- a/kernel/trace/trace_event_perf.c
> +++ b/kernel/trace/trace_event_perf.c
> @@ -24,6 +24,9 @@ static int total_ref_count;
> static int perf_trace_event_perm(struct ftrace_event_call *tp_event,
> struct perf_event *p_event)
> {
> + struct task_struct owner = p_event->parent ? p_event->parent->owner :
> + p_event->owner;
> +
> if (tp_event->perf_perm) {
> int ret = tp_event->perf_perm(tp_event, p_event);
> if (ret)
> @@ -32,7 +35,7 @@ static int perf_trace_event_perm(struct ftrace_event_call *tp_event,
>
> /* The ftrace function trace is allowed only for root. */
> if (ftrace_event_is_function(tp_event)) {
> - if (perf_paranoid_tracepoint_raw() && !capable(CAP_SYS_ADMIN))
> + if (perf_paranoid_tracepoint_raw() && !has_capability(owner, CAP_SYS_ADMIN))
> return -EPERM;
>
> /*
> @@ -65,7 +68,7 @@ static int perf_trace_event_perm(struct ftrace_event_call *tp_event,
> * ...otherwise raw tracepoint data can be a severe data leak,
> * only allow root to have these.
> */
> - if (perf_paranoid_tracepoint_raw() && !capable(CAP_SYS_ADMIN))
> + if (perf_paranoid_tracepoint_raw() && !has_capability(owner, CAP_SYS_ADMIN))
> return -EPERM;
>
> return 0;
You need to either hold rcu_read_lock() or otherwise ensure the owner is
still valid.
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2014-07-07 19:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-07 16:41 [BUG] perf stat: events inheritance can break task targets Alexander Yarygin
2014-07-07 17:00 ` Jiri Olsa
2014-07-07 19:46 ` Peter Zijlstra [this message]
2014-07-08 6:59 ` Jiri Olsa
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=20140707194635.GZ6758@twins.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.com \
--cc=borntraeger@de.ibm.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=paulus@samba.org \
--cc=yarygin@linux.vnet.ibm.com \
/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