mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Michal Marek <mmarek@suse.cz>,
	Peter Zijlstra <peterz@infradead.org>,
	Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@alien8.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andi Kleen <andi@firstfloor.org>, Pedro Alves <palves@redhat.com>,
	X86 ML <x86@kernel.org>,
	live-patching@vger.kernel.org,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v6 4/4] stackvalidate: Add ignore macros
Date: Tue, 7 Jul 2015 17:59:31 -0500	[thread overview]
Message-ID: <20150707225931.GB31294@treble.redhat.com> (raw)
In-Reply-To: <CALCETrV4EDyJZ9me3VpeHN86oFs1DkMS6ZbiMznK6AmOS0fu3g@mail.gmail.com>

On Tue, Jul 07, 2015 at 03:00:38PM -0700, Andy Lutomirski wrote:
> On Tue, Jul 7, 2015 at 7:54 AM, Josh Poimboeuf <jpoimboe@redhat.com> 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 <jpoimboe@redhat.com>
> > ---
> >  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.)

> > +#else /* __ASSEMBLY__ */
> > +
> > +/*
> > + * This asm macro tells the stack validation script to ignore the instruction
> > + * immediately after the macro.  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.
> > + */
> > +.macro STACKVALIDATE_IGNORE_INSN
> > +       .if CONFIG_STACK_VALIDATION
> > +               163:
> 
> Some day we should come up with a better way to do this than using a
> random three-digit number.  I wonder if something like .Ltemp_\@ could
> be used for this purpose.

Agreed.  And .Ltemp_\@ sounds like a good idea.  I'll try it.

-- 
Josh

  reply	other threads:[~2015-07-07 22:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-07 14:54 [PATCH v6 0/4] Compile-time stack validation Josh Poimboeuf
2015-07-07 14:54 ` [PATCH v6 1/4] x86/asm: Frame pointer macro cleanup Josh Poimboeuf
2015-07-07 14:54 ` [PATCH v6 2/4] x86/stackvalidate: Compile-time stack validation Josh Poimboeuf
2015-07-07 22:57   ` Andy Lutomirski
2015-07-07 23:29     ` Josh Poimboeuf
2015-07-07 23:35       ` Andy Lutomirski
2015-07-07 23:48         ` Josh Poimboeuf
2015-07-09 21:31         ` Josh Poimboeuf
2015-07-07 14:54 ` [PATCH v6 3/4] x86/stackvalidate: Add file and directory ignores Josh Poimboeuf
2015-07-07 14:54 ` [PATCH v6 4/4] stackvalidate: Add ignore macros Josh Poimboeuf
2015-07-07 22:00   ` Andy Lutomirski
2015-07-07 22:59     ` Josh Poimboeuf [this message]
2015-07-07 23:00       ` Andy Lutomirski
2015-07-07 23:38         ` Josh Poimboeuf
2015-07-07 15:06 ` [PATCH v6 0/4] Compile-time stack validation Josh Poimboeuf
2015-07-07 22:35 ` Josh Poimboeuf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150707225931.GB31294@treble.redhat.com \
    --to=jpoimboe@redhat.com \
    --cc=andi@firstfloor.org \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=mmarek@suse.cz \
    --cc=palves@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome