[Bug c/94722] New: implement __attribute__((no_stack_protector)) function attribute

ndesaulniers at google dot com gcc-bugzilla@gcc.gnu.org
Wed Apr 22 21:03:40 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94722

            Bug ID: 94722
           Summary: implement __attribute__((no_stack_protector)) function
                    attribute
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ndesaulniers at google dot com
                CC: jakub at redhat dot com, mliska at suse dot cz
  Target Milestone: ---

There's a couple of places in the Linux kernel where the placement of stack
protector guards causes problems for functions that do some tricky things. 
We'd like to have the ability to keep -fstack-protector* protections throughout
the kernel, but have finer grain resolution to disable the placement and
checking of stack guards on a per function granularity.

clang-8 added support for the function attribute no_stack_protector.
https://clang.llvm.org/docs/AttributeReference.html#no-stack-protector

With this feature implemented, we could have a more portable solution for the
kernel.

Two examples in the kernel where we could make use of this are
[0] https://lore.kernel.org/lkml/20200422192113.GG26846@zn.tnic/T/#t (call to
cpu_startup_entry() in start_secondary() in arch/x86/kernel/smpboot.c after
calls to boot_init_stack_canary() which has modified the stack guard).
[1]
https://lore.kernel.org/lkml/20180621162324.36656-1-ndesaulniers@google.com/
(custom calling conventions)

[0] was worked around with an empty asm statement and a descriptive comment.
[1] was worked around with `extern inline` with gnu_inline semantics.

I would prefer to use a function attribute for both cases.


More information about the Gcc-bugs mailing list