Skip to contentSkip to conversation

perf: Check permission only for parent tracepoint event

PATCH In review Jiri Olsa 2 participants 2 messages Jul 16, 2014 – Jul 24, 2014 Tracing

lore
Share & tools
lore

Jiri Olsa

author
#0 lore raw

PATCH 1/1 perf: Check permission only for parent tracepoint event

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.

Cc Alexander Yarygin <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Corey Ashford <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 kernel/trace/trace_event_perf.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
kernel/trace/trace_event_perf.c +12 -0
index 5d12bb407b44..4b9c114ee9de 100644
@@ -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))
Signature · 1 line
1.8.3.1
Tested-by on v1 1/1
#1 lore raw

At Wed, 16 Jul 2014 14:33:29 +0200,

Quoted 48 lines · Jiri Olsa

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.

Cc Alexander Yarygin <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Corey Ashford <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
---
 kernel/trace/trace_event_perf.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
kernel/trace/trace_event_perf.c +12 -0
index 5d12bb407b44..4b9c114ee9de 100644
@@ -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))
Signature · 1 line
1.8.3.1

Thanks.