Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1179141 > unrolled thread

Re: [PATCH v6 4/4] stackvalidate: Add ignore macros

Started byJosh Poimboeuf <jpoimboe@redhat.com>
First post2015-07-08 01:00 +0200
Last post2015-07-08 01:40 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v6 4/4] stackvalidate: Add ignore macros Josh Poimboeuf <jpoimboe@redhat.com> - 2015-07-08 01:00 +0200
    Re: [PATCH v6 4/4] stackvalidate: Add ignore macros Andy Lutomirski <luto@amacapital.net> - 2015-07-08 01:10 +0200
      Re: [PATCH v6 4/4] stackvalidate: Add ignore macros Josh Poimboeuf <jpoimboe@redhat.com> - 2015-07-08 01:40 +0200

#1179141 — Re: [PATCH v6 4/4] stackvalidate: Add ignore macros

FromJosh Poimboeuf <jpoimboe@redhat.com>
Date2015-07-08 01:00 +0200
SubjectRe: [PATCH v6 4/4] stackvalidate: Add ignore macros
Message-ID<pJK0i-39I-9@gated-at.bofh.it>
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
--
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/

[toc] | [next] | [standalone]


#1179145

FromAndy Lutomirski <luto@amacapital.net>
Date2015-07-08 01:10 +0200
Message-ID<pJK9Y-3sj-1@gated-at.bofh.it>
In reply to#1179141
On Tue, Jul 7, 2015 at 3:59 PM, Josh Poimboeuf <jpoimboe@redhat.com> 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 <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.)

Oh, egads.  FWIW, doing it in the linker script would probably be less hackish.

Does the linker discard before noticing duplicate symbols in that section?

>
>> > +#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.

:)

--Andy
--
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/

[toc] | [prev] | [next] | [standalone]


#1179160

FromJosh Poimboeuf <jpoimboe@redhat.com>
Date2015-07-08 01:40 +0200
Message-ID<pJKCZ-3C7-5@gated-at.bofh.it>
In reply to#1179145
On Tue, Jul 07, 2015 at 04:00:54PM -0700, Andy Lutomirski wrote:
> On Tue, Jul 7, 2015 at 3:59 PM, Josh Poimboeuf <jpoimboe@redhat.com> 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 <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.)
> 
> 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
--
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/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web