lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1466765712-10544-1-git-send-email-chuhu@redhat.com>
Date:	Fri, 24 Jun 2016 18:55:12 +0800
From:	Chunyu Hu <chuhu@...hat.com>
To:	rostedt@...dmis.org
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH V3] tracing: Make latency tracers fully support the set_graph_notrace

latency tracers(wakeup, wakeup_rt, wakeup_dl, irqsoff) can use the
function_graph trace when display_graph trace option is set by user
via tracefs. And currently the set_graph_notrace filter is not fully
supported in latency tracers, only the graph_ret event can be filtered,
the graph_ent events will always be submitted to the trace ring buffer
without respecting to the filter.

The issue is that the submitted graph_entry event that matches the
filter can be assigned with a negative depth(minuts FTRACE_NOTRACE_DEPTH)
which will be used as the array index of fgraph_cpu_data when printing
trace entries, as a result, an oops can be hit when accessing the array.

Fully supporting the set_graph_notrace filter in latency tracers can
avoid this oops and provide a small enhancement for these tracers at
the same time.

To reproduce the oops:
echo 1 > options/display_graph
echo schedule > set_graph_notrace
echo wakeup > current_tracer
cat trace (several times)

Signed-off-by: Chunyu Hu <chuhu@...hat.com>
---
 kernel/trace/trace_irqsoff.c      | 6 ++++++
 kernel/trace/trace_sched_wakeup.c | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c
index 03cdff8..a4ed46a 100644
--- a/kernel/trace/trace_irqsoff.c
+++ b/kernel/trace/trace_irqsoff.c
@@ -175,6 +175,12 @@ static int irqsoff_graph_entry(struct ftrace_graph_ent *trace)
 	int ret;
 	int pc;
 
+	if (trace->depth < 0)
+		return 0;
+
+	if (ftrace_graph_notrace_addr(trace->func))
+		return 1;
+
 	if (!func_prolog_dec(tr, &data, &flags))
 		return 0;
 
diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c
index 9d4399b..e54fff7 100644
--- a/kernel/trace/trace_sched_wakeup.c
+++ b/kernel/trace/trace_sched_wakeup.c
@@ -239,6 +239,12 @@ static int wakeup_graph_entry(struct ftrace_graph_ent *trace)
 	unsigned long flags;
 	int pc, ret = 0;
 
+	if (trace->depth < 0)
+		return 0;
+
+	if (ftrace_graph_notrace_addr(trace->func))
+		return 1;
+
 	if (!func_prolog_preempt_disable(tr, &data, &pc))
 		return 0;
 
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ