public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* --enable-stack-protector for glibc, v5
@ 2016-03-08 13:51 Nix
  2016-03-08 13:51 ` [PATCH 02/18] Initialize the stack guard earlier when linking statically Nix
                   ` (17 more replies)
  0 siblings, 18 replies; 42+ messages in thread
From: Nix @ 2016-03-08 13:51 UTC (permalink / raw)
  To: libc-alpha

This is version 5 of the stack-protected glibc patch, incorporating all review
comments to date (unless I missed some), and finally clearing up the long-
standing mystery surrounding __pthread_mutex_unlock_usercnt() et al.

It's not rebased and is still against glibc head as of a few weeks 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
--disable-stack-protector
--enable-stack-protector=no

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

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

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

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

No failures are observed that are not also observed on an unpatched glibc with
the same flag combinations. (There is one intermittent failure on arm: a
segfault from nptl/tst-cancelx17. However, it intermittently fails for me on the
unpatched baseline too, so I'm not making it any worse!)

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. (Patch 11 is
in Adhemerval's name, but obviously there's no assignment problem there either.)

The only remaining question I really have is what to do instead of patch 14,
which I really do expect to be rejected.  Another configure argument to set the
stack-protection level of externally-facing components, perhaps, or simply a
wiring-in that if --enable-stack-protector is not passed, that -fstack-protector
is passed in for these external components anyway?  What I do think is that the
level set via --enable-stack-protector should be a minimum: that libresolv, nscd
et al should never be protected *less* than libc.so and the rest are.  Patch 14
was a nice simple way to do that, but it is probably *too* simple...

Overview of changes in this posting:

 - Do not call __stack_chk_fail through the PLT for calls within libc itself,
   and calls within libc_nonshared.a as well.

 - Do not build __stack_chk_fail or __stack_chk_fail_local with stack-protection
   to avoid the (very unlikely) possibility of recursion.

 - Fix the comment describing of inhibit_stack_protector, which was
   incomprehensible.

 - Solve the great __pthread_mutex_unlock_usercnt() mystery: see patch N in the
   series.  Stack protection wasn't breaking anything, it was just legitimately
   clobbering a register it was allowed to clobber, and the i386 assembly
   implementation of pthread_cond_wait() et al were assuming it was not
   clobbered across calls.  All of the non-assembly parts of threading other
   than ifunc resolvers and a one-line initialization function in nptl-init.c
   are now stack-protected.

 - Stack-protect brk() and sbrk() in the shared library: they only need to be
   unprotected in the three varieties of static libc, where they are used in
   early init.

 - Reshuffle the series so that it is always compilable (I think).  (This was
   once true, but commits had crept in after the commit that wired up the
   --enable-stack-protector configure flag into a -fstack-protector compiler
   flag.)

 - Changelogs for everything.

Remaining mysteries:

 - None!
 

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

end of thread, other threads:[~2016-03-10 15:14 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-08 13:51 --enable-stack-protector for glibc, v5 Nix
2016-03-08 13:51 ` [PATCH 02/18] Initialize the stack guard earlier when linking statically Nix
2016-03-09 22:38   ` Mike Frysinger
2016-03-09 22:47     ` Nix
2016-03-08 13:51 ` [PATCH 01/18] Configury support for --enable-stack-protector Nix
2016-03-09 22:37   ` Mike Frysinger
2016-03-09 23:29     ` Nix
2016-03-10  1:02       ` Nix
2016-03-08 13:51 ` [PATCH 03/18] Do not stack-protect ifunc resolvers Nix
2016-03-09 22:40   ` Mike Frysinger
2016-03-09 23:33     ` Nix
2016-03-10  0:23     ` Joseph Myers
2016-03-09 22:47   ` Mike Frysinger
2016-03-09 23:48     ` Nix
2016-03-10  2:24       ` Mike Frysinger
2016-03-08 13:53 ` [PATCH 18/18] Enable -fstack-protector=* when requested by configure Nix
2016-03-08 13:53 ` [PATCH 11/18] De-PLTize __stack_chk_fail internal calls within libc.so Nix
2016-03-08 13:53 ` [PATCH 13/18] Prohibit stack-protection if the compiler is not capable Nix
2016-03-08 13:54 ` [PATCH 14/18] Drop explicit stack-protection of pieces of the system Nix
2016-03-08 13:54 ` [PATCH 07/18] Compile the entire dynamic linker with -fno-stack-protector Nix
2016-03-08 13:54 ` [PATCH 16/18] sparc: do not stack-protect the sigreturn handler Nix
2016-03-08 13:54 ` [PATCH 06/18] Allow overriding of CFLAGS as well as CPPFLAGS for rtld Nix
2016-03-08 13:54 ` [PATCH 08/18] Prevent the rtld mapfile computation from dragging in __stack_chk_fail Nix
2016-03-08 13:55 ` [PATCH 17/18] x86, pthread_cond_*wait: Do not depend on %eax not being clobbered Nix
2016-03-10 13:03   ` Florian Weimer
2016-03-08 13:55 ` [PATCH 04/18] Mark all machinery needed in early static-link init as -fno-stack-protector Nix
2016-03-08 13:55 ` [PATCH 10/18] Link libc.so with libc_nonshared.a to pull in __stack_chk_fail_local Nix
2016-03-08 14:48   ` Andreas Schwab
2016-03-08 21:51     ` Nix
2016-03-09  8:13       ` Andreas Schwab
2016-03-09 16:00         ` Nix
2016-03-08 13:55 ` [PATCH 15/18] Avoid stack-protecting signal-handling functions sibcalled from assembly Nix
2016-03-08 13:55 ` [PATCH 05/18] Open-code the memcpy() at static TLS initialization time Nix
2016-03-09 22:43   ` Mike Frysinger
2016-03-10  1:01     ` Nix
2016-03-10  2:29       ` Mike Frysinger
2016-03-10  3:02         ` Adhemerval Zanella
2016-03-10 10:20           ` Nix
2016-03-10 10:29         ` Nix
2016-03-10 15:14           ` Nix
2016-03-08 13:55 ` [PATCH 12/18] Link various tests with -fno-stack-protector Nix
2016-03-08 13:56 ` [PATCH 09/18] Work even with compilers hacked to enable -fstack-protector by default 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).