[compiler-rt] r221364 - [dfsan] Add runtime function for aborting on indirect calls to
Peter Collingbourne
peter at pcc.me.uk
Wed Nov 5 09:21:11 PST 2014
Author: pcc
Date: Wed Nov 5 11:21:11 2014
New Revision: 221364
URL: http://llvm.org/viewvc/llvm-project?rev=221364&view=rev
Log:
[dfsan] Add runtime function for aborting on indirect calls to
uninstrumented vararg functions.
Added:
compiler-rt/trunk/test/dfsan/vararg.c
Modified:
compiler-rt/trunk/lib/dfsan/dfsan.cc
Modified: compiler-rt/trunk/lib/dfsan/dfsan.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/dfsan/dfsan.cc?rev=221364&r1=221363&r2=221364&view=diff
==============================================================================
--- compiler-rt/trunk/lib/dfsan/dfsan.cc (original)
+++ compiler-rt/trunk/lib/dfsan/dfsan.cc Wed Nov 5 11:21:11 2014
@@ -147,6 +147,15 @@ extern "C" SANITIZER_INTERFACE_ATTRIBUTE
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
Added: compiler-rt/trunk/test/dfsan/vararg.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/dfsan/vararg.c?rev=221364&view=auto
==============================================================================
--- compiler-rt/trunk/test/dfsan/vararg.c (added)
+++ compiler-rt/trunk/test/dfsan/vararg.c Wed Nov 5 11:21:11 2014
@@ -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");
+}
More information about the llvm-commits
mailing list