about summary refs log tree commit diff
path: root/nixos/tests/hardened.nix
diff options
context:
space:
mode:
authorJoachim F <joachifm@users.noreply.github.com>2019-05-12 15:18:07 +0000
committerGitHub <noreply@github.com>2019-05-12 15:18:07 +0000
commitb4a43a278b725b85996f3d02335c9ba7b85b9bcb (patch)
tree60395bacba756ee0d7c6c0a851cec92c6aa8a819 /nixos/tests/hardened.nix
parent428ddf0619184d1e1d8e5e05a5b4639edc50507e (diff)
parent10d3a0e10b0ecf4789c2d3e538aadbb71a27e0db (diff)
Merge pull request #60187 from joachifm/feat/configurable-malloc
nixos: configurable system-wide malloc
Diffstat (limited to 'nixos/tests/hardened.nix')
-rw-r--r--nixos/tests/hardened.nix27
1 files changed, 27 insertions, 0 deletions
diff --git a/nixos/tests/hardened.nix b/nixos/tests/hardened.nix
index 614889c4d73c4..1ff329bd98dee 100644
--- a/nixos/tests/hardened.nix
+++ b/nixos/tests/hardened.nix
@@ -27,6 +27,20 @@ import ./make-test.nix ({ pkgs, ...} : {
     };
 
   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");
 
@@ -93,5 +107,18 @@ import ./make-test.nix ({ pkgs, ...} : {
         $machine->fail("systemctl hibernate");
         $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");
+      };
     '';
 })