* [PATCH] perf: Check permission only for parent tracepoint event
@ 2014-07-16 12:33 Jiri Olsa
2014-07-24 13:07 ` Alexander Yarygin
0 siblings, 1 reply; 2+ messages in thread
From: Jiri Olsa @ 2014-07-16 12:33 UTC (permalink / raw)
To: linux-kernel
Cc: Jiri Olsa, Alexander Yarygin, Arnaldo Carvalho de Melo,
Corey Ashford, Frederic Weisbecker, Ingo Molnar, Paul Mackerras,
Peter Zijlstra
There's no need to check cloned event's permission once the
parent was already checked.
Also the code is checking 'current' process permissions, which
is not owner process for cloned events, thus could end up with
wrong permission check result.
Reported-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Cc: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1405079782-8139-1-git-send-email-jolsa@kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
kernel/trace/trace_event_perf.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
index 5d12bb407b44..4b9c114ee9de 100644
--- a/kernel/trace/trace_event_perf.c
+++ b/kernel/trace/trace_event_perf.c
@@ -30,6 +30,18 @@ static int perf_trace_event_perm(struct ftrace_event_call *tp_event,
return ret;
}
+ /*
+ * We checked and allowed to create parent,
+ * allow children without checking.
+ */
+ if (p_event->parent)
+ return 0;
+
+ /*
+ * It's ok to check current process (owner) permissions in here,
+ * because code below is called only via perf_event_open syscall.
+ */
+
/* 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))
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] perf: Check permission only for parent tracepoint event
2014-07-16 12:33 [PATCH] perf: Check permission only for parent tracepoint event Jiri Olsa
@ 2014-07-24 13:07 ` Alexander Yarygin
0 siblings, 0 replies; 2+ messages in thread
From: Alexander Yarygin @ 2014-07-24 13:07 UTC (permalink / raw)
To: Jiri Olsa
Cc: linux-kernel, Alexander Yarygin, Arnaldo Carvalho de Melo,
Corey Ashford, Frederic Weisbecker, Ingo Molnar, Paul Mackerras,
Peter Zijlstra
At Wed, 16 Jul 2014 14:33:29 +0200,
Jiri Olsa wrote:
>
> There's no need to check cloned event's permission once the
> parent was already checked.
>
> Also the code is checking 'current' process permissions, which
> is not owner process for cloned events, thus could end up with
> wrong permission check result.
>
> Reported-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
> Cc: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
> Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
> Cc: Frederic Weisbecker <fweisbec@gmail.com>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> Link: http://lkml.kernel.org/r/1405079782-8139-1-git-send-email-jolsa@kernel.org
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
> kernel/trace/trace_event_perf.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/kernel/trace/trace_event_perf.c b/kernel/trace/trace_event_perf.c
> index 5d12bb407b44..4b9c114ee9de 100644
> --- a/kernel/trace/trace_event_perf.c
> +++ b/kernel/trace/trace_event_perf.c
> @@ -30,6 +30,18 @@ static int perf_trace_event_perm(struct ftrace_event_call *tp_event,
> return ret;
> }
>
> + /*
> + * We checked and allowed to create parent,
> + * allow children without checking.
> + */
> + if (p_event->parent)
> + return 0;
> +
> + /*
> + * It's ok to check current process (owner) permissions in here,
> + * because code below is called only via perf_event_open syscall.
> + */
> +
> /* 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))
> --
> 1.8.3.1
>
Tested-by: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-07-24 13:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-16 12:33 [PATCH] perf: Check permission only for parent tracepoint event Jiri Olsa
2014-07-24 13:07 ` Alexander Yarygin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox