Skip to content

Commit 3ba99f8

Browse files
committed
glibc: enable stackprotection hardening
Enables previously manually disabled stackprotector and stackguard randomization. From https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=511811: If glibc is built with the --enable-stackguard-randomization option, each application gets a random canary value (at runtime) from /dev/urandom. If --enable-stackguard-randomization is absent, applications get a static canary value of "0xff0a0000". This is very unfortunate, because the attacker may be able to bypass the stack protection mechanism, by placing those 4 bytes in the canary word, before the actual canary check is performed (for example in memcpy-based buffer overflows).
1 parent e0b5eef commit 3ba99f8

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

pkgs/development/libraries/glibc/common.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ stdenv.mkDerivation ({
8282
"--enable-add-ons"
8383
"--enable-obsolete-rpc"
8484
"--sysconfdir=/etc"
85-
"libc_cv_ssp=no"
85+
"--enable-stackguard-randomization"
8686
(if linuxHeaders != null
8787
then "--with-headers=${linuxHeaders}/include"
8888
else "--without-headers")

pkgs/development/libraries/glibc/default.nix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ in
3333
makeFlagsArray+=("bindir=$bin/bin" "sbindir=$bin/sbin" "rootsbindir=$bin/sbin")
3434
'';
3535

36+
# The stackprotector and fortify hardening flags are autodetected by glibc
37+
# and enabled by default if supported. Setting it for every gcc invocation
38+
# does not work.
3639
hardeningDisable = [ "stackprotector" "fortify" ];
3740

3841
# When building glibc from bootstrap-tools, we need libgcc_s at RPATH for

0 commit comments

Comments
 (0)