1 | // REQUIRES: target={{x86_64-.*}} |
2 | // RUN: %clang_dfsan -gmlt -mllvm -dfsan-track-origins=1 %s -o %t && \ |
3 | // RUN: %run %t >%t.out 2>&1 |
4 | // RUN: FileCheck %s < %t.out |
5 | |
6 | #include <sanitizer/dfsan_interface.h> |
7 | |
8 | int main(int argc, char *argv[]) { |
9 | uint64_t a = 10; |
10 | dfsan_set_label(label: 1, addr: &a, size: sizeof(a)); |
11 | |
12 | // Manually compute origin address for &a. |
13 | // See x86 MEM_TO_ORIGIN macro for logic to replicate here. |
14 | // Alignment is also needed after to MEM_TO_ORIGIN. |
15 | uint64_t origin_addr = |
16 | (((uint64_t)&a ^ 0x500000000000ULL) + 0x100000000000ULL) & ~0x3ULL; |
17 | |
18 | // Take the address we computed, and store 0 in it to mess it up. |
19 | asm("mov %0, %%rax" : :"r" (origin_addr)); |
20 | asm("movq $0, (%rax)" ); |
21 | dfsan_print_origin_trace(addr: &a, description: "invalid" ); |
22 | } |
23 | |
24 | // CHECK: Taint value 0x1 (at {{.*}}) origin tracking (invalid) |
25 | // CHECK: Taint value 0x1 (at {{.*}}) has invalid origin tracking. This can be a DFSan bug. |
26 | |