@@ -27,6 +27,10 @@ typedef uint32_t dfsan_origin;
27
27
// / Signature of the callback argument to dfsan_set_write_callback().
28
28
typedef void (*dfsan_write_callback_t )(int fd, const void *buf, size_t count);
29
29
30
+ // / Signature of the callback argument to dfsan_set_conditional_callback().
31
+ typedef void (*dfsan_conditional_callback_t )(dfsan_label label,
32
+ dfsan_origin origin);
33
+
30
34
// / Computes the union of \c l1 and \c l2, resulting in a union label.
31
35
dfsan_label dfsan_union (dfsan_label l1, dfsan_label l2);
32
36
@@ -54,6 +58,10 @@ dfsan_origin dfsan_get_origin(long data);
54
58
// / Retrieves the label associated with the data at the given address.
55
59
dfsan_label dfsan_read_label (const void *addr, size_t size);
56
60
61
+ // / Return the origin associated with the first taint byte in the size bytes
62
+ // / from the address addr.
63
+ dfsan_origin dfsan_read_origin_of_first_taint (const void *addr, size_t size);
64
+
57
65
// / Returns whether the given label label contains the label elem.
58
66
int dfsan_has_label (dfsan_label label, dfsan_label elem);
59
67
@@ -70,6 +78,19 @@ void dfsan_flush(void);
70
78
// / callback executes. Pass in NULL to remove any callback.
71
79
void dfsan_set_write_callback (dfsan_write_callback_t labeled_write_callback);
72
80
81
+ // / Sets a callback to be invoked on any conditional expressions which have a
82
+ // / taint label set. This can be used to find where tainted data influences
83
+ // / the behavior of the program.
84
+ // / These callbacks will only be added when -dfsan-conditional-callbacks=true.
85
+ void dfsan_set_conditional_callback (dfsan_conditional_callback_t callback);
86
+
87
+ // / Conditional expressions occur during signal handlers.
88
+ // / Making callbacks that handle signals well is tricky, so when
89
+ // / -dfsan-conditional-callbacks=true, conditional expressions used in signal
90
+ // / handlers will add the labels they see into a global (bitwise-or together).
91
+ // / This function returns all label bits seen in signal handler conditions.
92
+ dfsan_label dfsan_get_labels_in_signal_conditional ();
93
+
73
94
// / Interceptor hooks.
74
95
// / Whenever a dfsan's custom function is called the corresponding
75
96
// / hook is called it non-zero. The hooks should be defined by the user.
@@ -87,6 +108,9 @@ void dfsan_weak_hook_strncmp(void *caller_pc, const char *s1, const char *s2,
87
108
// / prints description at the beginning of the trace. If origin tracking is not
88
109
// / on, or the address is not labeled, it prints nothing.
89
110
void dfsan_print_origin_trace (const void *addr, const char *description);
111
+ // / As above, but use an origin id from dfsan_get_origin() instead of address.
112
+ // / Does not include header line with taint label and address information.
113
+ void dfsan_print_origin_id_trace (dfsan_origin origin);
90
114
91
115
// / Prints the origin trace of the label at the address \p addr to a
92
116
// / pre-allocated output buffer. If origin tracking is not on, or the address is
@@ -124,6 +148,10 @@ void dfsan_print_origin_trace(const void *addr, const char *description);
124
148
// / return value is not less than \p out_buf_size.
125
149
size_t dfsan_sprint_origin_trace (const void *addr, const char *description,
126
150
char *out_buf, size_t out_buf_size);
151
+ // / As above, but use an origin id from dfsan_get_origin() instead of address.
152
+ // / Does not include header line with taint label and address information.
153
+ size_t dfsan_sprint_origin_id_trace (dfsan_origin origin, char *out_buf,
154
+ size_t out_buf_size);
127
155
128
156
// / Prints the stack trace leading to this call to a pre-allocated output
129
157
// / buffer.
@@ -150,8 +178,7 @@ int dfsan_get_track_origins(void);
150
178
#ifdef __cplusplus
151
179
} // extern "C"
152
180
153
- template <typename T>
154
- void dfsan_set_label (dfsan_label label, T &data) { // NOLINT
181
+ template <typename T> void dfsan_set_label (dfsan_label label, T &data) {
155
182
dfsan_set_label (label, (void *)&data, sizeof (T));
156
183
}
157
184
0 commit comments