kernel: make the RANDSTRUCT seed deterministic
This commit is contained in:
@@ -88,7 +88,10 @@ let
|
||||
|
||||
inherit src;
|
||||
|
||||
patches = map (p: p.patch) kernelPatches;
|
||||
patches =
|
||||
map (p: p.patch) kernelPatches
|
||||
# Required for deterministic builds along with some postPatch magic.
|
||||
++ optional (stdenv.lib.versionAtLeast version "4.13") ./randstruct-provide-seed.patch;
|
||||
|
||||
prePatch = ''
|
||||
for mf in $(find -name Makefile -o -name Makefile.include -o -name install.sh); do
|
||||
@@ -99,6 +102,19 @@ let
|
||||
sed -i scripts/ld-version.sh -e "s|/usr/bin/awk|${buildPackages.gawk}/bin/awk|"
|
||||
'';
|
||||
|
||||
postPatch = ''
|
||||
# Set randstruct seed to a deterministic but diversified value. Note:
|
||||
# we could have instead patched gen-random-seed.sh to take input from
|
||||
# the buildFlags, but that would require also patching the kernel's
|
||||
# toplevel Makefile to add a variable export. This would be likely to
|
||||
# cause future patch conflicts.
|
||||
if [ -f scripts/gcc-plugins/gen-random-seed.sh ]; then
|
||||
substituteInPlace scripts/gcc-plugins/gen-random-seed.sh \
|
||||
--replace NIXOS_RANDSTRUCT_SEED \
|
||||
$(echo ${src} ${configfile} | sha256sum | cut -d ' ' -f 1 | tr -d '\n')
|
||||
fi
|
||||
'';
|
||||
|
||||
configurePhase = ''
|
||||
runHook preConfigure
|
||||
|
||||
|
||||
Reference in New Issue
Block a user