cc-wrapper: add support for shadowstack hardening flag

Changed files
+23 -1
nixos
doc
manual
release-notes
pkgs
build-support
cc-wrapper
development
compilers
gcc
llvm
common
clang
stdenv
darwin
generic
linux
bootstrap-tools
bootstrap-tools-musl
top-level
+2
nixos/doc/manual/release-notes/rl-2411.section.md
···
- Nemo is now built with gtk-layer-shell support, note that for now it will be expected to see nemo-desktop
listed as a regular entry in Cinnamon Wayland session's window list applet.
+
- The `shadowstack` hardening flag has been added, though disabled by default.
+
- Support for *runner registration tokens* has been [deprecated](https://gitlab.com/gitlab-org/gitlab/-/issues/380872)
in `gitlab-runner` 15.6 and is expected to be removed in `gitlab-runner` 18.0. Configuration of existing runners
should be changed to using *runner authentication tokens* by configuring
+5 -1
pkgs/build-support/cc-wrapper/add-hardening.sh
···
fi
if (( "${NIX_DEBUG:-0}" >= 1 )); then
-
declare -a allHardeningFlags=(fortify fortify3 stackprotector stackclashprotection pie pic strictoverflow format trivialautovarinit zerocallusedregs)
+
declare -a allHardeningFlags=(fortify fortify3 shadowstack stackprotector stackclashprotection pie pic strictoverflow format trivialautovarinit zerocallusedregs)
declare -A hardeningDisableMap=()
# Determine which flags were effectively disabled so we can report below.
···
# Ignore unsupported.
;;
esac
+
;;
+
shadowstack)
+
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling shadowstack >&2; fi
+
hardeningCFlagsBefore+=('-fcf-protection=return')
;;
stackprotector)
if (( "${NIX_DEBUG:-0}" >= 1 )); then echo HARDENING: enabling stackprotector >&2; fi
+6
pkgs/development/compilers/gcc/default.nix
···
) "stackclashprotection"
++ optional (!atLeast11) "zerocallusedregs"
++ optionals (!atLeast12) [ "fortify3" "trivialautovarinit" ]
+
++ optional (!(
+
atLeast8
+
&& targetPlatform.isLinux
+
&& targetPlatform.isx86_64
+
&& targetPlatform.libc == "glibc"
+
)) "shadowstack"
++ optionals (langFortran) [ "fortify" "format" ];
};
+5
pkgs/development/compilers/llvm/common/clang/default.nix
···
hardeningUnsupportedFlagsByTargetPlatform = targetPlatform:
[ "fortify3" ]
++ lib.optional (
+
(lib.versionOlder release_version "7")
+
|| !targetPlatform.isLinux
+
|| !targetPlatform.isx86_64
+
) "shadowstack"
+
++ lib.optional (
(lib.versionOlder release_version "11")
|| (targetPlatform.isAarch64 && (lib.versionOlder release_version "18.1"))
|| (targetPlatform.isFreeBSD && (lib.versionOlder release_version "15"))
+1
pkgs/stdenv/darwin/default.nix
···
isFromBootstrapFiles = true;
hardeningUnsupportedFlags = [
"fortify3"
+
"shadowstack"
"stackclashprotection"
"zerocallusedregs"
];
+1
pkgs/stdenv/generic/make-derivation.nix
···
"format"
"fortify"
"fortify3"
+
"shadowstack"
"pic"
"pie"
"relro"
+1
pkgs/stdenv/linux/bootstrap-tools-musl/default.nix
···
isGNU = true;
hardeningUnsupportedFlags = [
"fortify3"
+
"shadowstack"
"stackclashprotection"
"trivialautovarinit"
"zerocallusedregs"
+1
pkgs/stdenv/linux/bootstrap-tools/default.nix
···
isGNU = true;
hardeningUnsupportedFlags = [
"fortify3"
+
"shadowstack"
"stackclashprotection"
"trivialautovarinit"
"zerocallusedregs"
+1
pkgs/top-level/stage.nix
···
pkgsExtraHardening = super';
stdenv = super'.withDefaultHardeningFlags (
super'.stdenv.cc.defaultHardeningFlags ++ [
+
"shadowstack"
"stackclashprotection"
"trivialautovarinit"
]