From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754238AbbETQk1 (ORCPT ); Wed, 20 May 2015 12:40:27 -0400 Received: from mail-la0-f53.google.com ([209.85.215.53]:33594 "EHLO mail-la0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752835AbbETQkV (ORCPT ); Wed, 20 May 2015 12:40:21 -0400 MIME-Version: 1.0 In-Reply-To: <20150520162537.GD16995@treble.redhat.com> References: <20150520103339.GA22205@gmail.com> <20150520141331.GA16995@treble.redhat.com> <20150520144810.GA10374@gmail.com> <20150520162537.GD16995@treble.redhat.com> From: Andy Lutomirski Date: Wed, 20 May 2015 09:39:59 -0700 Message-ID: Subject: Re: [PATCH v4 0/3] Compile-time stack frame pointer validation To: Josh Poimboeuf 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 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 20, 2015 at 9:25 AM, Josh Poimboeuf wrote: > 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 Fantastic! > - 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() We think alike :) NMI will be much more interesting than schedule. --Andy