1 // RUN: %clangxx_msan -DPRE1 -O0 %s -o %t && not %run %t 2>&1
2 // RUN: %clangxx_msan -DPRE2 -O0 %s -o %t && not %run %t 2>&1
3 // RUN: %clangxx_msan -DPRE3 -O0 %s -o %t && not %run %t 2>&1
4 // RUN: %clangxx_msan -O0 %s -o %t && %run %t 2>&1
10 #include <sanitizer/linux_syscall_hooks.h>
11 #include <sanitizer/msan_interface.h>
13 struct my_kernel_sigaction
{
17 long handler
, flags
, restorer
;
19 uint64_t mask
[20]; // larger than any known platform
23 my_kernel_sigaction act
= {}, oldact
= {};
26 __msan_poison(&act
.handler
, sizeof(act
.handler
));
27 __sanitizer_syscall_pre_rt_sigaction(SIGUSR1
, &act
, &oldact
, 20 * 8);
29 __msan_poison(&act
.flags
, sizeof(act
.flags
));
30 __sanitizer_syscall_pre_rt_sigaction(SIGUSR1
, &act
, &oldact
, 20 * 8);
32 __msan_poison(&act
.mask
, 1);
33 __sanitizer_syscall_pre_rt_sigaction(SIGUSR1
, &act
, &oldact
, 20 * 8);
35 // Uninit past the end of the mask is ignored.
36 __msan_poison(((char *)&act
.mask
) + 5, 1);
37 __sanitizer_syscall_pre_rt_sigaction(SIGUSR1
, &act
, &oldact
, 5);
39 memset(&act
, 0, sizeof(act
));
40 __msan_poison(&oldact
, sizeof(oldact
));
41 __sanitizer_syscall_post_rt_sigaction(0, SIGUSR1
, &act
, &oldact
, 5);
43 assert(__msan_test_shadow(&oldact
, sizeof(oldact
)) == sizeof(long)*2 + 5);
45 assert(__msan_test_shadow(&oldact
, sizeof(oldact
)) == sizeof(long)*3 + 5);