brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · c496d82 Raw
34 lines · cpp
1// Check that if mach_vm_region_recurse is disallowed by sandbox, we report a message saying so.2 3// RUN: %clangxx_asan -O0 %s -o %t4// RUN: not %run sandbox-exec -p '(version 1)(allow default)(deny syscall-mig (kernel-mig-routine mach_vm_region_recurse))' %t 2>&1 | FileCheck --check-prefix=CHECK-DENY %s5// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ALLOW %s6// RUN: %clangxx_asan -O3 %s -o %t7// RUN: not %run sandbox-exec -p '(version 1)(allow default)(deny syscall-mig (kernel-mig-routine mach_vm_region_recurse))' %t 2>&1 | FileCheck --check-prefix=CHECK-DENY %s8// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-ALLOW %s9 10// sandbox-exec isn't available on iOS11// UNSUPPORTED: ios12 13// x86_64 does not use ASAN_SHADOW_OFFSET_DYNAMIC14// UNSUPPORTED: x86_64-darwin || x86_64h-darwin15 16#include <stdlib.h>17 18int main() {19  char *x = (char *)malloc(10 * sizeof(char));20  free(x);21  return x[5];22  // CHECK-ALLOW: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}23  // CHECK-DENY-NOT: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}24  // CHECK-ALLOW: {{READ of size 1 at 0x.* thread T0}}25  // CHECK-ALLOW: {{    #0 0x.* in main}}26  // CHECK-ALLOW: {{freed by thread T0 here:}}27  // CHECK-ALLOW: {{    #0 0x.* in free}}28  // CHECK-ALLOW: {{    #1 0x.* in main}}29  // CHECK-ALLOW: {{previously allocated by thread T0 here:}}30  // CHECK-ALLOW: {{    #0 0x.* in malloc}}31  // CHECK-ALLOW: {{    #1 0x.* in main}}32  // CHECK-DENY: {{.*HINT: Ensure mach_vm_region_recurse is allowed under sandbox}}33}34