Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Unified Diff: tests_lit/asan_tests/quarantine.ll

Issue 2227353002: Subzero: Added ASan quarantine for recently freed objects (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Added check for double free errors Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests_lit/asan_tests/doublefree.ll ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests_lit/asan_tests/quarantine.ll
diff --git a/tests_lit/asan_tests/quarantine.ll b/tests_lit/asan_tests/quarantine.ll
new file mode 100644
index 0000000000000000000000000000000000000000..91ff3a6f5c7261ad067a09685039a7b4b9274f0c
--- /dev/null
+++ b/tests_lit/asan_tests/quarantine.ll
@@ -0,0 +1,69 @@
+; Test that the quarantine for recently freed objects works
+
+; REQUIRES: no_minimal_build
+
+; Test with an illegal load from a freed block
+; RUN: llvm-as %s -o - | pnacl-freeze > %t.pexe && %S/../../pydir/szbuild.py \
+; RUN: --fsanitize-address --sz=-allow-externally-defined-symbols \
+; RUN: %t.pexe -o %t && %t 2>&1 | FileCheck --check-prefix=LOAD %s
+; RUN: llvm-as %s -o - | pnacl-freeze > %t.pexe && %S/../../pydir/szbuild.py \
+; RUN: --fsanitize-address --sz=-allow-externally-defined-symbols -O2 \
+; RUN: %t.pexe -o %t && %t 2>&1 | FileCheck --check-prefix=LOAD %s
+
+; Test with an illegal store to a freed block
+; RUN: llvm-as %s -o - | pnacl-freeze > %t.pexe && %S/../../pydir/szbuild.py \
+; RUN: --fsanitize-address --sz=-allow-externally-defined-symbols \
+; RUN: %t.pexe -o %t && %t 1 2>&1 | FileCheck --check-prefix=STORE %s
+; RUN: llvm-as %s -o - | pnacl-freeze > %t.pexe && %S/../../pydir/szbuild.py \
+; RUN: --fsanitize-address --sz=-allow-externally-defined-symbols -O2 \
+; RUN: %t.pexe -o %t && %t 1 2>&1 | FileCheck --check-prefix=STORE %s
+
+; Test that freed objects eventually get out of quarantine and are unpoisoned
+; RUN: llvm-as %s -o - | pnacl-freeze > %t.pexe && %S/../../pydir/szbuild.py \
+; RUN: --fsanitize-address --sz=-allow-externally-defined-symbols \
+; RUN: %t.pexe -o %t && %t 1 2 2>&1 | FileCheck --check-prefix=NONE %s \
+; RUN: --allow-empty
+; RUN: llvm-as %s -o - | pnacl-freeze > %t.pexe && %S/../../pydir/szbuild.py \
+; RUN: --fsanitize-address --sz=-allow-externally-defined-symbols -O2 \
+; RUN: %t.pexe -o %t && %t 1 2 2>&1 | FileCheck --check-prefix=NONE %s \
+; RUN: --allow-empty
+
+declare external i32 @malloc(i32)
+declare external void @free(i32)
+declare external void @exit(i32)
+
+; make three 100MB allocations
+define void @_start(i32 %arg) {
+ %argcaddr = add i32 %arg, 8
+ %argcptr = inttoptr i32 %argcaddr to i32*
+ %argc = load i32, i32* %argcptr, align 1
+ %alloc1addr = call i32 @malloc(i32 104857600)
+ %alloc2addr = call i32 @malloc(i32 104857600)
+ %alloc3addr = call i32 @malloc(i32 104857600)
+ %alloc1 = inttoptr i32 %alloc1addr to i32*
+ %alloc2 = inttoptr i32 %alloc2addr to i32*
+ %alloc3 = inttoptr i32 %alloc3addr to i32*
+ call void @free(i32 %alloc1addr)
+ call void @free(i32 %alloc2addr)
+ call void @free(i32 %alloc3addr)
+ switch i32 %argc, label %error [i32 1, label %bad_load
+ i32 2, label %bad_store
+ i32 3, label %no_err]
+bad_load:
+ %result_load = load i32, i32* %alloc2, align 1
+ br label %error
+bad_store:
+ store i32 42, i32* %alloc3, align 1
+ br label %error
+no_err:
+ %result_no_err = load i32, i32* %alloc1, align 1
+ call void @exit(i32 0)
+ unreachable
+error:
+ call void @exit(i32 1)
+ unreachable
+}
+
+; LOAD: Illegal 4 byte load from freed object at
+; STORE: Illegal 4 byte store to freed object at
+; NONE-NOT: Illegal
« no previous file with comments | « tests_lit/asan_tests/doublefree.ll ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698