mirror of
https://github.com/intel/llvm.git
synced 2026-01-25 19:44:38 +08:00
[dfsan] Add runtime function for aborting on indirect calls to
uninstrumented vararg functions. llvm-svn: 221364
This commit is contained in:
@@ -147,6 +147,15 @@ extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __dfsan_nonzero_label() {
|
||||
Report("WARNING: DataFlowSanitizer: saw nonzero label\n");
|
||||
}
|
||||
|
||||
// Indirect call to an uninstrumented vararg function. We don't have a way of
|
||||
// handling these at the moment.
|
||||
extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
|
||||
__dfsan_vararg_wrapper(const char *fname) {
|
||||
Report("FATAL: DataFlowSanitizer: unsupported indirect call to vararg "
|
||||
"function %s\n", fname);
|
||||
Die();
|
||||
}
|
||||
|
||||
// Like __dfsan_union, but for use from the client or custom functions. Hence
|
||||
// the equality comparison is done here before calling __dfsan_union.
|
||||
SANITIZER_INTERFACE_ATTRIBUTE dfsan_label
|
||||
|
||||
24
compiler-rt/test/dfsan/vararg.c
Normal file
24
compiler-rt/test/dfsan/vararg.c
Normal file
@@ -0,0 +1,24 @@
|
||||
// RUN: %clang_dfsan -m64 %s -o %t
|
||||
// RUN: not %run %t 2>&1 | FileCheck %s
|
||||
// RUN: %run %t foo
|
||||
// RUN: %clang_dfsan -mllvm -dfsan-args-abi -m64 %s -o %t
|
||||
// RUN: not %run %t 2>&1 | FileCheck %s
|
||||
// RUN: %run %t foo
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int do_nothing(const char *format, ...) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int (*fp)(const char *, ...);
|
||||
|
||||
if (argc > 1)
|
||||
fp = do_nothing;
|
||||
else
|
||||
fp = printf;
|
||||
|
||||
// CHECK: FATAL: DataFlowSanitizer: unsupported indirect call to vararg function printf
|
||||
fp("hello %s\n", "world");
|
||||
}
|
||||
Reference in New Issue
Block a user