From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758084AbbGGXie (ORCPT ); Tue, 7 Jul 2015 19:38:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47506 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757291AbbGGXi1 (ORCPT ); Tue, 7 Jul 2015 19:38:27 -0400 Date: Tue, 7 Jul 2015 18:38:24 -0500 From: Josh Poimboeuf To: Andy Lutomirski Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Michal Marek , Peter Zijlstra , Andy Lutomirski , Borislav Petkov , Linus Torvalds , Andi Kleen , Pedro Alves , X86 ML , live-patching@vger.kernel.org, "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v6 4/4] stackvalidate: Add ignore macros Message-ID: <20150707233824.GD31294@treble.redhat.com> References: <30c25e5414ca777fef3b6c189b26b34a290b12f9.1436280380.git.jpoimboe@redhat.com> <20150707225931.GB31294@treble.redhat.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 Tue, Jul 07, 2015 at 04:00:54PM -0700, Andy Lutomirski wrote: > On Tue, Jul 7, 2015 at 3:59 PM, Josh Poimboeuf wrote: > > On Tue, Jul 07, 2015 at 03:00:38PM -0700, Andy Lutomirski wrote: > >> On Tue, Jul 7, 2015 at 7:54 AM, Josh Poimboeuf wrote: > >> > Add new stackvalidate ignore macros: STACKVALIDATE_IGNORE_INSN and > >> > STACKVALIDATE_IGNORE_FUNC. These can be used to tell stackvalidate to > >> > skip validation of an instruction or a function, respectively. > >> > > >> > Signed-off-by: Josh Poimboeuf > >> > --- > >> > include/linux/stackvalidate.h | 38 ++++++++++++++++++++++++++++++++++++++ > >> > 1 file changed, 38 insertions(+) > >> > create mode 100644 include/linux/stackvalidate.h > >> > > >> > diff --git a/include/linux/stackvalidate.h b/include/linux/stackvalidate.h > >> > new file mode 100644 > >> > index 0000000..30d4a60 > >> > --- /dev/null > >> > +++ b/include/linux/stackvalidate.h > >> > @@ -0,0 +1,38 @@ > >> > +#ifndef _LINUX_STACKVALIDATE_H > >> > +#define _LINUX_STACKVALIDATE_H > >> > + > >> > +#ifndef __ASSEMBLY__ > >> > + > >> > +/* > >> > + * This C macro tells the stack validation script to ignore the function. It > >> > + * should only be used in special cases where you're 100% sure it won't affect > >> > + * the reliability of frame pointers and kernel stack traces. > >> > + * > >> > + * For more information, see Documentation/stack-validation.txt. > >> > + */ > >> > +#define STACKVALIDATE_IGNORE_FUNC(_func) \ > >> > + void __attribute__((section("__stackvalidate_ignore_func,\"ae\"#"))) \ > >> > + *__stackvalidate_ignore_func_##_func = _func > >> > + > >> > >> static? Otherwise there's some risk that ignoring a static function > >> will cause a duplicate symbol. Alternatively you could generate a > >> more unique name. > >> > >> Also, should the linker script be updated to discard this section? > > > > It validates per individual object file, so there shouldn't be a risk of > > duplicate symbols. The 'e' flag in ,\"ae\"#" tells the linker to > > discard the section. > > > > (The ,\"ae\"# stuff is a horrible hack, but it's the only way I could > > figure out how to set the section flags from C code. The '#' is used to > > comment out gcc's default arguments to the .section directive in favor > > of the "ae" flags.) > > Oh, egads. FWIW, doing it in the linker script would probably be less hackish. Yeah. I'll try that. > Does the linker discard before noticing duplicate symbols in that section? I think it does, but I'll verify. I deliberately made it global so the compiler doesn't discard the symbol for being unused. But I can use the unused attribute to avoid that. -- Josh