summary refs log tree commit diff
path: root/nixos/tests/hardened.nix
diff options
context:
space:
mode:
authorJoachim Fasting <joachifm@fastmail.fm>2019-04-23 22:24:16 +0200
committerJoachim Fasting <joachifm@fastmail.fm>2019-05-07 13:45:42 +0200
commit10d3a0e10b0ecf4789c2d3e538aadbb71a27e0db (patch)
tree0e9b910018afc0459e296389d92aacfe16b5aa93 /nixos/tests/hardened.nix
parent48ff4f119735dc60c3e2794a71b00757b838d877 (diff)
downloadnixpkgs-10d3a0e10b0ecf4789c2d3e538aadbb71a27e0db.tar
nixpkgs-10d3a0e10b0ecf4789c2d3e538aadbb71a27e0db.tar.gz
nixpkgs-10d3a0e10b0ecf4789c2d3e538aadbb71a27e0db.tar.bz2
nixpkgs-10d3a0e10b0ecf4789c2d3e538aadbb71a27e0db.tar.lz
nixpkgs-10d3a0e10b0ecf4789c2d3e538aadbb71a27e0db.tar.xz
nixpkgs-10d3a0e10b0ecf4789c2d3e538aadbb71a27e0db.tar.zst
nixpkgs-10d3a0e10b0ecf4789c2d3e538aadbb71a27e0db.zip
nixos/tests/hardened: test hardened 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 07bd10963ba..9e60d93e738 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");
 
@@ -83,5 +97,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");
+      };
     '';
 })