Skip to content

Commit

Permalink
WIP - fix sa vs hardening
Browse files Browse the repository at this point in the history
Alternative to NixOS#353131
  • Loading branch information
Ma27 committed Nov 2, 2024
1 parent d32fe41 commit c84bb84
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkgs/build-support/cc-wrapper/add-hardening.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ declare -A hardeningEnableMap=()
# Intentionally word-split in case 'NIX_HARDENING_ENABLE' is defined in Nix. The
# array expansion also prevents undefined variables from causing trouble with
# `set -u`.
for flag in ${NIX_HARDENING_ENABLE_@suffixSalt@-}; do
hardeningEnableMap["$flag"]=1
done
if [[ -z "${__structuredAttrs-}" ]]; then
for flag in ${NIX_HARDENING_ENABLE_@suffixSalt@-}; do
hardeningEnableMap["$flag"]=1
done
else
for flag in "${NIX_HARDENING_ENABLE_@suffixSalt@[@]}"; do
hardeningEnableMap["$flag"]=1
done
fi

# fortify3 implies fortify enablement - make explicit before
# we filter unsupported flags because unsupporting fortify3
Expand Down
7 changes: 7 additions & 0 deletions pkgs/test/cc-wrapper/hardening.nix
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ in nameDrvAfterAttrName ({
ignorePie = false;
});

pieExplicitEnabledStructuredAttrs = brokenIf stdenv.hostPlatform.isStatic (checkTestBin (f2exampleWithStdEnv stdenv {
hardeningEnable = [ "pie" ];
__structuredAttrs = true;
}) {
ignorePie = false;
});

relROExplicitEnabled = checkTestBin (f2exampleWithStdEnv stdenv {
hardeningEnable = [ "relro" ];
}) {
Expand Down

0 comments on commit c84bb84

Please sign in to comment.