From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752772AbcFVNIS (ORCPT ); Wed, 22 Jun 2016 09:08:18 -0400 Received: from smtprelay0205.hostedemail.com ([216.40.44.205]:47894 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751434AbcFVNIR (ORCPT ); Wed, 22 Jun 2016 09:08:17 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2693:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3871:3872:3874:4321:5007:6119:6261:7875:7901:7903:10004:10400:10848:10967:11026:11232:11658:11914:12043:12296:12438:12517:12519:12555:12663:12740:13138:13161:13229:13231:13439:14096:14097:14181:14659:14721:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:13,LUA_SUMMARY:none X-HE-Tag: roof52_82568a4e74d13 X-Filterd-Recvd-Size: 2840 Date: Wed, 22 Jun 2016 09:08:14 -0400 From: Steven Rostedt To: Chunyu Hu Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] tracing: Fix oops caused by graph notrace filter Message-ID: <20160622090814.0bd039e3@gandalf.local.home> In-Reply-To: <1466506666-28804-1-git-send-email-chuhu@redhat.com> References: <1466506666-28804-1-git-send-email-chuhu@redhat.com> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 21 Jun 2016 18:57:46 +0800 Chunyu Hu wrote: > wakeup tracer can use function_graph trace when display_graph trace > option is setup by user via tracefs, and bypass the set_graph_function > and set_graph_notrace. But the bypass of set_graph_notrace is not clean. > Although wakeup_graph_entry does most of the bypass, and both the enry > and exit event will be submitted to the trace ring buffer, the ret_stack > index, which will be assigned to depth field of graph enrty event is not > handled. The issue is that the depth is used as the array index of > fgraph_cpu_data and can cause an oops when it's negative. irqsoff tracer > has same issue. To see the oops: > > echo 1 > options/display_graph > echo schedule > set_graph_notrace > echo wakeup > current_tracer > cat trace > cat trace I'm not able to trigger an oops, but I do see them being traced. > > Making ftrace_graph_notrace_addr always return false when tracers need > to bypass it is a proposed fix. There's a lot of things wrong with this patch, but before we go there, why should the latency tracers ignore set_graph_notrace? What about this patch? -- Steve diff --git a/kernel/trace/trace_irqsoff.c b/kernel/trace/trace_irqsoff.c index 03cdff84d026..68fcee5097d2 100644 --- a/kernel/trace/trace_irqsoff.c +++ b/kernel/trace/trace_irqsoff.c @@ -175,6 +175,9 @@ static int irqsoff_graph_entry(struct ftrace_graph_ent *trace) int ret; int pc; + if (trace->depth < 0) + return 0; + 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 9d4399b553a3..ce9889bff8b4 100644 --- a/kernel/trace/trace_sched_wakeup.c +++ b/kernel/trace/trace_sched_wakeup.c @@ -239,6 +239,9 @@ static int wakeup_graph_entry(struct ftrace_graph_ent *trace) unsigned long flags; int pc, ret = 0; + if (trace->depth < 0) + return 0; + if (!func_prolog_preempt_disable(tr, &data, &pc)) return 0;