From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932276AbbETQZn (ORCPT ); Wed, 20 May 2015 12:25:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49985 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932207AbbETQZj (ORCPT ); Wed, 20 May 2015 12:25:39 -0400 Date: Wed, 20 May 2015 11:25:37 -0500 From: Josh Poimboeuf To: Andy Lutomirski Cc: Ingo Molnar , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Michal Marek , Peter Zijlstra , X86 ML , live-patching@vger.kernel.org, "linux-kernel@vger.kernel.org" , Linus Torvalds , Andy Lutomirski , Denys Vlasenko , Brian Gerst , Peter Zijlstra , Borislav Petkov , Andrew Morton Subject: Re: [PATCH v4 0/3] Compile-time stack frame pointer validation Message-ID: <20150520162537.GD16995@treble.redhat.com> References: <20150520103339.GA22205@gmail.com> <20150520141331.GA16995@treble.redhat.com> <20150520144810.GA10374@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 20, 2015 at 09:03:37AM -0700, Andy Lutomirski wrote: > On Wed, May 20, 2015 at 7:48 AM, Ingo Molnar wrote: > > Yeah, so many of these seem to be 'leaf only' functions: functions > > that don't ever call functions themselves. > > > > So lets assume we always have CONFIG_FRAME_POINTERS=y. > > > > If they don't set up a frame pointer then they in essence won't show > > up in the call chain - but normally they wouldn't because they call > > nothing. > > > > If they trigger an exception/fault or if they get hit by an interrupt > > then I think we'll still correctly walk the stack - just those > > functions might be missing from the deterministic call chain, right? > > (it will still show up as a '?' entry.) > > I've never quite understood what the '?' means. It basically means "here's a function address we found on the stack, which may or may not have been called." It's needed because stack walking isn't currently 100% reliable. > > If they crash then we'll see them because the crashing RIP will be > > printed. > > > > So I'm wondering what the x86 policy here should be: to create frame > > pointers in them or not. Cc:-ed a few more gents for thoughts. > > > > I think it would be nice to have full DWARF unwind support for > everything at some point. Unfortunately, I don't see any easy path to > getting there. It doesn't help that AFAIK no one has ever proposed a > usable in-kernel DWARF unwinder. > > It also doesn't help that writing correct CFI annotations in inline > asm can be very complicated. > > I think that ia64 manages to have complete unwind support. How did > they manage it? > > If we had an unwinder, it would be relatively straightforward to write > something perf-based that would frequently check that we can unwind > all the way out of an NMI back to userspace and warn if we couldn't. I agree that DWARF unwind support would be nice. I have some plans about how to achieve that in future patch sets. It includes several pieces: - compile-time DWARF data validation (using some similar approaches to this patch set) - run time DWARF data validation, including: - a DWARF unwinder which doesn't blindly trust any of the DWARF data - ensuring DWARF and frame pointer data are consistent with each other - ensuring it can walk all the way to the bottom of the stack - a DEBUG option which validates the stack periodically from an NMI and/or schedule() -- Josh