From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756546AbcHBXQg (ORCPT ); Tue, 2 Aug 2016 19:16:36 -0400 Received: from smtprelay0190.hostedemail.com ([216.40.44.190]:36739 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752316AbcHBXQ2 (ORCPT ); Tue, 2 Aug 2016 19:16:28 -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:981:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2692:2693:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3874:4250:5007:6117:6119:6261:6742:7875:7903:10004:10400:10848:10967:11026:11232:11658:11914:12296:12438:12517:12519:12663:12740:13069:13138:13161:13229:13231:13255:13311:13357:13439:14096:14097:14181:14659:14721:21080:30012:30054:30070:30090:30091,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:12,LUA_SUMMARY:none X-HE-Tag: offer65_723d99dd6123f X-Filterd-Recvd-Size: 3533 Date: Tue, 2 Aug 2016 19:16:22 -0400 From: Steven Rostedt To: Josh Poimboeuf Cc: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, Andy Lutomirski , Linus Torvalds , Brian Gerst , Kees Cook , Peter Zijlstra , Frederic Weisbecker , Byungchul Park Subject: Re: [PATCH 05/19] x86/dumpstack: fix function graph tracing stack dump reliability issues Message-ID: <20160802191622.466f53d2@gandalf.local.home> In-Reply-To: <20160802221359.tkb3mkjzkq3petrq@treble> References: <20160729185521.62a5cd2a@gandalf.local.home> <20160730005059.5krpl2xsvqfbnntj@treble> <20160729222036.340b51ce@grimm.local.home> <20160730135125.qqw5qz24szlc2crz@treble> <20160801102821.1d6261a9@gandalf.local.home> <20160801153633.c7sa2rclkqwbdagd@treble> <20160802210011.k6li4mnyvky5jtev@treble> <20160802171610.09156c90@gandalf.local.home> <20160802221359.tkb3mkjzkq3petrq@treble> 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, 2 Aug 2016 17:13:59 -0500 Josh Poimboeuf wrote: > > Then we only need the fp use case when FRAME_POINTER is not set. As > > mcount forces FRAME_POINTER, we only need to worry about the fentry > > case. > > Hm, I'm confused. First, I don't see where mcount forces FRAME_POINTER. Hmm, we should probably force it generally, as gcc itself requires mcount to be used with framepointers. -mcount can't be used without them. > > Second, I don't see why that even matters. If mcount and frame pointers > are enabled, then the 'fp' field of ftrace_ret_stack is needed for the > gcc sanity check, right? So we couldn't override 'fp', and the old > "stateful index" version of ftrace_graph_ret_addr() would have to be > used in the code above for reliable addresses, and we'd still have the > same out-of-sync bug. > > Or am I missing something? > Or I missed something. How did we get out of sync? If we have frame pointers, shouldn't the "return_to_handler" be seen as reliable by the code (not that we save it as such)? That is, if the frame pointer shows that the next function is return_to_handler, then we increment the index into ret_stack, otherwise we simply record the return_to_handler as a normal "unreliable" function, without any processing of it. I guess I don't actually understand how the NMI screwed it up, as function graph doesn't trace "do_nmi()" itself nor anything before that. I'm guessing it really got out of sync because there's a "return_to_handler" in the stack that wasn't really called (not a frame pointer). The ftrace_graph_ret_addr() will shift the index currently regardless if the return_to_handler found is part of a stack frame, or just left over in the stack. THAT is why I think it got out of sync. -- Steve