[PATCH] D63037: [dfsan] Introduce dfsan_flush().
Kostya Serebryany via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 13 13:09:11 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL363321: [dfsan] Introduce dfsan_flush(). (authored by kcc, committed by ).
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63037/new/
https://reviews.llvm.org/D63037
Files:
compiler-rt/trunk/include/sanitizer/dfsan_interface.h
compiler-rt/trunk/lib/dfsan/dfsan.cc
compiler-rt/trunk/lib/dfsan/done_abilist.txt
compiler-rt/trunk/test/dfsan/flush.c
Index: compiler-rt/trunk/include/sanitizer/dfsan_interface.h
===================================================================
--- compiler-rt/trunk/include/sanitizer/dfsan_interface.h
+++ compiler-rt/trunk/include/sanitizer/dfsan_interface.h
@@ -79,6 +79,12 @@
/// Returns the number of labels allocated.
size_t dfsan_get_label_count(void);
+/// Flushes the DFSan shadow, i.e. forgets about all labels currently associated
+/// with the application memory. Will work only if there are no other
+/// threads executing DFSan-instrumented code concurrently.
+/// Use this call to start over the taint tracking within the same procces.
+void dfsan_flush(void);
+
/// Sets a callback to be invoked on calls to write(). The callback is invoked
/// before the write is done. The write is not guaranteed to succeed when the
/// callback executes. Pass in NULL to remove any callback.
Index: compiler-rt/trunk/test/dfsan/flush.c
===================================================================
--- compiler-rt/trunk/test/dfsan/flush.c
+++ compiler-rt/trunk/test/dfsan/flush.c
@@ -0,0 +1,28 @@
+// Tests dfsan_flush().
+// RUN: %clang_dfsan %s -o %t && %run %t
+#include <sanitizer/dfsan_interface.h>
+#include <assert.h>
+#include <stdlib.h>
+
+int global;
+
+int main() {
+ int local;
+ int *heap = (int*)malloc(sizeof(int));
+
+ dfsan_set_label(10, &global, sizeof(global));
+ dfsan_set_label(20, &local, sizeof(local));
+ dfsan_set_label(30, heap, sizeof(*heap));
+
+ assert(dfsan_get_label(global) == 10);
+ assert(dfsan_get_label(local) == 20);
+ assert(dfsan_get_label(*heap) == 30);
+
+ dfsan_flush();
+
+ assert(dfsan_get_label(global) == 0);
+ assert(dfsan_get_label(local) == 0);
+ assert(dfsan_get_label(*heap) == 0);
+
+ free(heap);
+}
Index: compiler-rt/trunk/lib/dfsan/dfsan.cc
===================================================================
--- compiler-rt/trunk/lib/dfsan/dfsan.cc
+++ compiler-rt/trunk/lib/dfsan/dfsan.cc
@@ -421,6 +421,12 @@
}
}
+extern "C" void dfsan_flush() {
+ UnmapOrDie((void*)ShadowAddr(), UnusedAddr() - ShadowAddr());
+ if (!MmapFixedNoReserve(ShadowAddr(), UnusedAddr() - ShadowAddr()))
+ Die();
+}
+
static void dfsan_init(int argc, char **argv, char **envp) {
InitializeFlags();
Index: compiler-rt/trunk/lib/dfsan/done_abilist.txt
===================================================================
--- compiler-rt/trunk/lib/dfsan/done_abilist.txt
+++ compiler-rt/trunk/lib/dfsan/done_abilist.txt
@@ -26,6 +26,8 @@
fun:dfsan_has_label_with_desc=discard
fun:dfsan_set_write_callback=uninstrumented
fun:dfsan_set_write_callback=custom
+fun:dfsan_flush=uninstrumented
+fun:dfsan_flush=discard
###############################################################################
# glibc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63037.204618.patch
Type: text/x-patch
Size: 2771 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190613/d81ed3f8/attachment.bin>
More information about the llvm-commits
mailing list