llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-compiler-rt-sanitizer Author: Vitaly Buka (vitalybuka) <details> <summary>Changes</summary> Update the test to use more robust argument passing for offsets and sizes. --- Full diff: https://github.com/llvm/llvm-project/pull/195667.diff 1 Files Affected: - (modified) compiler-rt/test/asan/TestCases/use-after-poison-history-size-partial-granule.cpp (+18-11) ``````````diff diff --git a/compiler-rt/test/asan/TestCases/use-after-poison-history-size-partial-granule.cpp b/compiler-rt/test/asan/TestCases/use-after-poison-history-size-partial-granule.cpp index e5fecbb9573fe..cd66cb8d3a373 100644 --- a/compiler-rt/test/asan/TestCases/use-after-poison-history-size-partial-granule.cpp +++ b/compiler-rt/test/asan/TestCases/use-after-poison-history-size-partial-granule.cpp @@ -1,41 +1,48 @@ // Check that __asan_poison_memory_region and ASAN_OPTIONS=poison_history_size work for partial granules. // -// RUN: %clangxx_asan -O0 %s -o %t && env ASAN_OPTIONS=poison_history_size=1000 not %run %t 20 2>&1 | FileCheck %s +// RUN: %clangxx_asan -O0 %s -o %t && env ASAN_OPTIONS=poison_history_size=1000 not %run %t 10 20 10 2>&1 | FileCheck %s // // Partial granule -// RUN: %clangxx_asan -O0 %s -o %t && env ASAN_OPTIONS=poison_history_size=1000 not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan -O0 %s -o %t && env ASAN_OPTIONS=poison_history_size=1000 not %run %t 10 20 20 2>&1 | FileCheck %s // TODO // REQUIRES: linux // UNSUPPORTED: android +#include <cassert> #include <stdio.h> #include <stdlib.h> -extern "C" void __asan_poison_memory_region(void *, size_t); -extern "C" void __asan_unpoison_memory_region(void *, size_t); +#include <sanitizer/asan_interface.h> -void honey_ive_poisoned_the_memory(char *x) { - __asan_poison_memory_region(x + 10, 20); +void honey_ive_poisoned_the_memory(char *x, size_t poison_offset, + size_t poison_size) { + __asan_poison_memory_region(x + poison_offset, poison_size); } -void foo(char *x) { honey_ive_poisoned_the_memory(x); } +void foo(char *x, size_t poison_offset, size_t poison_size) { + honey_ive_poisoned_the_memory(x, poison_offset, poison_size); +} int main(int argc, char **argv) { + assert(argc > 3); + size_t poison_offset = atoi(argv[1]); + size_t poison_size = atoi(argv[2]); + size_t access_offset = atoi(argv[3]); char *x = new char[64]; x[10] = 0; - foo(x); + foo(x, poison_offset, poison_size); // Bytes [0, 9]: addressable // Bytes [10, 31]: poisoned by A // Bytes [32, 63]: addressable - int res = x[argc * 10]; // BOOOM + int res = x[access_offset]; // BOOOM // CHECK: ERROR: AddressSanitizer: use-after-poison // CHECK: main{{.*}}use-after-poison-history-size-partial-granule.cpp:[[@LINE-2]] // CHECK: Memory was manually poisoned by thread T0: - // CHECK: honey_ive_poisoned_the_memory{{.*}}use-after-poison-history-size-partial-granule.cpp:[[@LINE-18]] - // CHECK: foo{{.*}}use-after-poison-history-size-partial-granule.cpp:[[@LINE-16]] + // CHECK: honey_ive_poisoned_the_memory{{.*}}use-after-poison-history-size-partial-granule.cpp:[[@LINE-24]] + // CHECK: foo{{.*}}use-after-poison-history-size-partial-granule.cpp:[[@LINE-21]] // CHECK: main{{.*}}use-after-poison-history-size-partial-granule.cpp:[[@LINE-12]] delete[] x; `````````` </details> https://github.com/llvm/llvm-project/pull/195667 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
