Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752463AbbHUHyz (ORCPT ); Fri, 21 Aug 2015 03:54:55 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:35230 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751585AbbHUHyx (ORCPT ); Fri, 21 Aug 2015 03:54:53 -0400 Date: Fri, 21 Aug 2015 09:54:49 +0200 From: Ingo Molnar To: Josh Poimboeuf Cc: Andrew Morton , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, Michal Marek , Peter Zijlstra , Andy Lutomirski , Borislav Petkov , Linus Torvalds , Andi Kleen , Pedro Alves , Namhyung Kim , Bernd Petrovitsch , Chris J Arges , live-patching@vger.kernel.org Subject: Re: [PATCH v10 03/20] x86/stackvalidate: Compile-time stack validation Message-ID: <20150821075449.GA10443@gmail.com> References: <07bf51833b5e1c52bfd9a4dbda41b80c508dffff.1439521412.git.jpoimboe@redhat.com> <20150815002354.7fb2f21e.akpm@linux-foundation.org> <20150815124913.GB3254@treble.hsd1.ky.comcast.net> <20150819100138.GA10504@gmail.com> <20150820040050.GC2944@treble.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150820040050.GC2944@treble.redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2352 Lines: 53 * Josh Poimboeuf wrote: > +Why do we need stack validation? > +-------------------------------- > + > +Here are some of the benefits of validating stack metadata: > + > +a) More reliable stack traces for frame pointer enabled kernels > + > + Frame pointers are used for debugging purposes. They allow runtime > + code and debug tools to be able to walk the stack to determine the > + chain of function call sites that led to the currently executing > + code. > + > + For some architectures, frame pointers are enabled by > + CONFIG_FRAME_POINTER. For some other architectures they may be > + required by the ABI (sometimes referred to as "backchain pointers"). > + > + For C code, gcc automatically generates instructions for setting up > + frame pointers when the -fno-omit-frame-pointer option is used. > + > + But for asm code, the frame setup instructions have to be written by > + hand, which most people don't do. So the end result is that > + CONFIG_FRAME_POINTER is honored for C code but not for most asm code. > + > + For stack traces based on frame pointers to be reliable, all > + functions which call other functions must first create a stack frame > + and update the frame pointer. If a first function doesn't properly > + create a stack frame before calling a second function, the *caller* > + of the first function will be skipped on the stack trace. > + > + The benefit of stackvalidate here is that it ensures that *all* > + functions honor CONFIG_FRAME_POINTER. As a result, no functions will > + ever [*] be skipped on a stack trace. > + > + [*] unless an interrupt or exception has occurred at the very > + beginning of a function before the stack frame has been created, > + or at the very end of the function after the stack frame has been > + destroyed. This is an inherent limitation of frame pointers. What this section does not point out is the actual effects of missing frame pointer annotations. I.e. how about quoting a before/after stack backtrace to demonstrate it? Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/