public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* --enable-stack-protector for glibc, v4, now with arm
@ 2016-02-28 16:42 Nix
  2016-02-28 16:41 ` [PATCH 02/16] Initialize the stack guard earlier when linking statically Nix
                   ` (16 more replies)
  0 siblings, 17 replies; 30+ messages in thread
From: Nix @ 2016-02-28 16:42 UTC (permalink / raw)
  To: libc-alpha

This is version 4 of the stack-protected glibc patch, incorporating all review
comments to date (unless I missed some), and adding a degree of arm support
(i.e. "I know nothing about the platform but the tests passed").

Still no changelog citing bug 7065: I'm not confident enough that things won't
change, but I'd be more confident if someone could look at patch 15 in this
series and tell me why on earth it's even necessary (which it definitely is).

It's not rebased and is still against glibc head as of a week ago,
a5df3210a641c17.

Tested with these flag combinations on {i686,x86_64)-pc-linux-gnu:

--enable-omitfp --enable-stack-protector=all
--enable-stack-protector
--enable-stack-protector=strong
--enable-stack-protector=all
--enable-stackguard-randomization --enable-stack-protector=all
--enable-omitfp --enable-stackguard-randomization --enable-stack-protector
--enable-omitfp --enable-stackguard-randomization --enable-stack-protector=strong
--enable-omitfp --enable-stackguard-randomization --enable-stack-protector=all
--without-stack-protector
--enable-stack-protector=no

Tested with with these flag combinations on sparc{32,64}-pc-linux-gnu:

--disable-stack-protector
--enable-stack-protector
--enable-stackguard-randomization --enable-stack-protector
--enable-stackguard-randomization --enable-stack-protector=strong
--enable-stackguard-randomization --enable-stack-protector=all

Tested with these flag combinations on armv7l-unknown-linux-gnueabihf (it
happened to have GCC 4.8, so -strong wasn't available):

--disable-stack-protector
--enable-stack-protector
--enable-stackguard-randomization --enable-stack-protector-all

No failures are observed that are not also observed on an unpatched glibc with
the same flag combinations, other than localplt (due to the new __stack_chk_fail
PLT, which I'd suggest is desirable: it seems like something people might
reasonably want to interpose, and interposing it will have no performance
implications).

On the copyright assignment front, I am informed that Oracle has a blanket
assignment on file for glibc work, so I don't need to do anything.


Overview of changes in this posting:

 - use inhibit_loop_to_libcall to prevent GCC folding our open-coded memcpy()
   in static TLS setup back into a (prohibited) libcall again

 - introduce new inhibit_stack_protector that turns off -fstack-protector for a
   single function, and use it to stack-protect only the necessary functions
   within nptl: most of nptl-init.c, pthread_mutex_cond_lock.c and
   pthread_mutex_unlock.c are now protected.

 - De-stack-protect all ifunc resolvers: they're called before the stack canary
   is initialized in the dynamic-linking case, so must never be stack-protected.
   (How it worked before on x86 and sparc I have no idea, but on arm, it fails.)

 - stack-protected glibc now passes its tests on armv7l-unknown-linux-gnueabihf
   (an odroid c1, because I already had one sitting upstairs being a home
   cinema).

Remaining mysteries:

 - In patch 15, I have no understanding of why __pthread_mutex_unlock_usercnt()
   and __pthread_mutex_cond_lock_adjust() are special: yes, they're called
   directly from assembler, but that shouldn't be a problem: -fstack-protector
   doesn't change the function-call ABI!  Nonetheless, it *is* a problem, and
   this is definitely necessary.  I just don't know what *else* might be
   necessary.  It is almost certain that this sort of thing will be the primary
   problem when making other arches happy with this change (it was the only real
   thing I had to do with sparc, in patch 14, -fno-sparc-protecting the
   sigreturn handler, and just as with the pthread functions I don't really know
   why -- but it is clearly necessary.)

   It *is* clear why we have to -fno-stack-protect setjmp/sigjmp.c: the thing is
   *sibcalled* from assembler, and the assembler has pre-built a stack frame,
   complete with lack of canary, so setjmp/sigjmp.c had better not introduce
   one.  (Even in the absence of local variables, -fstack-protector-all will add
   a canary to the lone function in that file.)

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2016-03-07 16:27 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-28 16:42 --enable-stack-protector for glibc, v4, now with arm Nix
2016-02-28 16:41 ` [PATCH 02/16] Initialize the stack guard earlier when linking statically Nix
2016-02-28 16:42 ` [PATCH 05/16] Open-code the memcpy() at static TLS initialization time Nix
2016-02-28 16:42 ` [PATCH 12/16] Work even with compilers hacked to enable -fstack-protector by default Nix
2016-02-28 16:42 ` [PATCH 10/16] Link various tests with -fno-stack-protector Nix
2016-02-28 16:42 ` [PATCH 09/16] Link libc.so with libc_nonshared.a to pull in __stack_chk_fail Nix
2016-02-28 16:42 ` [PATCH 14/16] Drop explicit stack-protection of pieces of the system Nix
2016-02-28 16:42 ` [PATCH 04/16] Mark all machinery needed in early static-link init as -fno-stack-protector Nix
2016-02-28 16:42 ` [PATCH 11/16] Enable -fstack-protector=* when requested by configure Nix
2016-02-29  7:53   ` Andreas Schwab
2016-02-29 15:40     ` Nix
2016-02-28 16:42 ` [PATCH 16/16] sparc: do not stack-protect the sigreturn handler Nix
2016-02-28 16:42 ` [PATCH 01/16] Configury support for --enable-stack-protector Nix
2016-02-28 16:42 ` [PATCH 06/16] Allow overriding of CFLAGS as well as CPPFLAGS for rtld Nix
2016-02-28 16:42 ` [PATCH 08/16] Prevent the rtld mapfile computation from dragging in __stack_chk_fail() Nix
2016-02-28 16:42 ` [PATCH 07/16] Compile the entire dynamic linker with -fno-stack-protector Nix
2016-02-28 16:42 ` [PATCH 13/16] Prohibit stack-protection if the compiler is not capable Nix
2016-02-28 16:42 ` [PATCH 03/16] Do not stack-protect ifunc resolvers Nix
2016-02-28 20:25 ` [PATCH 15/16] Avoid stack-protecting certain functions called from assembly Nix
2016-03-02 18:54   ` Szabolcs Nagy
2016-03-03 16:40     ` Nix
2016-03-03 16:55       ` Andreas Schwab
2016-03-03 17:41         ` Nix
2016-03-02 18:29 ` --enable-stack-protector for glibc, v4, now with arm Nix
2016-03-02 22:16   ` Adhemerval Zanella
2016-03-03 17:34     ` Nix
2016-03-03 18:25       ` Adhemerval Zanella
2016-03-03 19:45         ` Nix
2016-03-04 11:12       ` Nix
2016-03-07 16:27       ` Nix

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).