blob: 426099073cfa3d9421a1dd5a9422cc5520a693bf [file] [log] [blame]
Peter Collingbourne2eeed712013-08-07 22:47:34 +00001=================
2DataFlowSanitizer
3=================
4
5.. contents::
6 :local:
7
8Introduction
9============
10
11DataFlowSanitizer is a generalised dynamic data flow analysis.
12
13Unlike other Sanitizer tools, this tool is not designed to detect a
14specific class of bugs on its own. Instead, it provides a generic
15dynamic data flow analysis framework to be used by clients to help
16detect application-specific issues within their own code.
17
18Usage
19=====
20
21With no program changes, applying DataFlowSanitizer to a program
22will not alter its behavior. To use DataFlowSanitizer, the program
23uses API functions to apply tags to data to cause it to be tracked, and to
24check the tag of a specific data item. DataFlowSanitizer manages
25the propagation of tags through the program according to its data flow.
26
27The APIs are defined in the header file ``sanitizer/dfsan_interface.h``.
28For further information about each function, please refer to the header
29file.
30
31Example
32=======
33
34The following program demonstrates label propagation by checking that
35the correct labels are propagated.
36
37.. code-block:: c++
38
39 #include <sanitizer/dfsan_interface.h>
40 #include <assert.h>
41
42 int main(void) {
43 int i = 1;
44 dfsan_label i_label = dfsan_create_label("i", 0);
45 dfsan_set_label(i_label, &i, sizeof(i));
46
47 int j = 2;
48 dfsan_label j_label = dfsan_create_label("j", 0);
49 dfsan_set_label(j_label, &j, sizeof(j));
50
51 int k = 3;
52 dfsan_label k_label = dfsan_create_label("k", 0);
53 dfsan_set_label(k_label, &k, sizeof(k));
54
55 dfsan_label ij_label = dfsan_get_label(i + j);
56 assert(dfsan_has_label(ij_label, i_label));
57 assert(dfsan_has_label(ij_label, j_label));
58 assert(!dfsan_has_label(ij_label, k_label));
59
60 dfsan_label ijk_label = dfsan_get_label(i + j + k);
61 assert(dfsan_has_label(ijk_label, i_label));
62 assert(dfsan_has_label(ijk_label, j_label));
63 assert(dfsan_has_label(ijk_label, k_label));
64
65 return 0;
66 }
67
68Current status
69==============
70
71DataFlowSanitizer is a work in progress, currently under development for
72x86\_64 Linux.
73
74Design
75======
76
77Please refer to the :doc:`design document<DataFlowSanitizerDesign>`.