xref: /aosp_15_r20/external/compiler-rt/test/asan/TestCases/Linux/syscalls.cc (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316
2*7c3d14c8STreehugger Robot // XFAIL: android
3*7c3d14c8STreehugger Robot //
4*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
5*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
6*7c3d14c8STreehugger Robot 
7*7c3d14c8STreehugger Robot #include <assert.h>
8*7c3d14c8STreehugger Robot #include <errno.h>
9*7c3d14c8STreehugger Robot #include <glob.h>
10*7c3d14c8STreehugger Robot #include <stdio.h>
11*7c3d14c8STreehugger Robot #include <string.h>
12*7c3d14c8STreehugger Robot 
13*7c3d14c8STreehugger Robot #include <sanitizer/linux_syscall_hooks.h>
14*7c3d14c8STreehugger Robot 
15*7c3d14c8STreehugger Robot /* Test the presence of __sanitizer_syscall_ in the tool runtime, and general
16*7c3d14c8STreehugger Robot    sanity of their behaviour. */
17*7c3d14c8STreehugger Robot 
main(int argc,char * argv[])18*7c3d14c8STreehugger Robot int main(int argc, char *argv[]) {
19*7c3d14c8STreehugger Robot   char buf[1000];
20*7c3d14c8STreehugger Robot   __sanitizer_syscall_pre_recvmsg(0, buf - 1, 0);
21*7c3d14c8STreehugger Robot   // CHECK: AddressSanitizer: stack-buffer-{{.*}}erflow
22*7c3d14c8STreehugger Robot   // CHECK: READ of size {{.*}} at {{.*}} thread T0
23*7c3d14c8STreehugger Robot   // CHECK: #0 {{.*}} in __sanitizer_syscall{{.*}}recvmsg
24*7c3d14c8STreehugger Robot   return 0;
25*7c3d14c8STreehugger Robot }
26