nixos/tests/hardened: test hardened malloc
This commit is contained in:
parent
48ff4f1197
commit
10d3a0e10b
@ -27,6 +27,20 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||||||
};
|
};
|
||||||
|
|
||||||
testScript =
|
testScript =
|
||||||
|
let
|
||||||
|
hardened-malloc-tests = pkgs.stdenv.mkDerivation rec {
|
||||||
|
name = "hardened-malloc-tests-${pkgs.graphene-hardened-malloc.version}";
|
||||||
|
src = pkgs.graphene-hardened-malloc.src;
|
||||||
|
buildPhase = ''
|
||||||
|
cd test/simple-memory-corruption
|
||||||
|
make -j4
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
find . -type f -executable -exec install -Dt $out/bin '{}' +
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
''
|
''
|
||||||
$machine->waitForUnit("multi-user.target");
|
$machine->waitForUnit("multi-user.target");
|
||||||
|
|
||||||
@ -83,5 +97,18 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||||||
$machine->fail("systemctl hibernate");
|
$machine->fail("systemctl hibernate");
|
||||||
$machine->fail("systemctl kexec");
|
$machine->fail("systemctl kexec");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Test hardened memory allocator
|
||||||
|
sub runMallocTestProg {
|
||||||
|
my ($progName, $errorText) = @_;
|
||||||
|
my $text = "fatal allocator error: " . $errorText;
|
||||||
|
$machine->fail("${hardened-malloc-tests}/bin/" . $progName) =~ $text;
|
||||||
|
};
|
||||||
|
|
||||||
|
subtest "hardenedmalloc", sub {
|
||||||
|
runMallocTestProg("double_free_large", "invalid free");
|
||||||
|
runMallocTestProg("unaligned_free_small", "invalid unaligned free");
|
||||||
|
runMallocTestProg("write_after_free_small", "detected write after free");
|
||||||
|
};
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user