[PATCH] D14341: Asan: utility function to determine first wrongly poisoned byte in container.
Mike Aizatsky via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 4 11:24:57 PST 2015
aizatsky updated this revision to Diff 39226.
aizatsky added a comment.
- done
http://reviews.llvm.org/D14341
Files:
include/sanitizer/common_interface_defs.h
lib/asan/asan_poisoning.cc
lib/sanitizer_common/sanitizer_interface_internal.h
Index: lib/sanitizer_common/sanitizer_interface_internal.h
===================================================================
--- lib/sanitizer_common/sanitizer_interface_internal.h
+++ lib/sanitizer_common/sanitizer_interface_internal.h
@@ -53,6 +53,9 @@
SANITIZER_INTERFACE_ATTRIBUTE
int __sanitizer_verify_contiguous_container(const void *beg, const void *mid,
const void *end);
+ SANITIZER_INTERFACE_ATTRIBUTE
+ const void* __sanitizer_contiguous_container_find_bad_address(
+ const void *beg, const void *mid, const void *end);
} // extern "C"
#endif // SANITIZER_INTERFACE_INTERNAL_H
Index: lib/asan/asan_poisoning.cc
===================================================================
--- lib/asan/asan_poisoning.cc
+++ lib/asan/asan_poisoning.cc
@@ -375,10 +375,9 @@
}
}
-int __sanitizer_verify_contiguous_container(const void *beg_p,
- const void *mid_p,
- const void *end_p) {
- if (!flags()->detect_container_overflow) return 1;
+const void* __sanitizer_contiguous_container_find_bad_address(
+ const void *beg_p, const void *mid_p, const void *end_p) {
+ if (!flags()->detect_container_overflow) return nullptr;
uptr beg = reinterpret_cast<uptr>(beg_p);
uptr end = reinterpret_cast<uptr>(end_p);
uptr mid = reinterpret_cast<uptr>(mid_p);
@@ -395,17 +394,24 @@
uptr r3_end = end;
for (uptr i = r1_beg; i < r1_end; i++)
if (AddressIsPoisoned(i))
- return 0;
+ return reinterpret_cast<const void*>(i);
for (uptr i = r2_beg; i < mid; i++)
if (AddressIsPoisoned(i))
- return 0;
+ return reinterpret_cast<const void*>(i);
for (uptr i = mid; i < r2_end; i++)
if (!AddressIsPoisoned(i))
- return 0;
+ return reinterpret_cast<const void*>(i);
for (uptr i = r3_beg; i < r3_end; i++)
if (!AddressIsPoisoned(i))
- return 0;
- return 1;
+ return reinterpret_cast<const void*>(i);
+ return nullptr;
+}
+
+int __sanitizer_verify_contiguous_container(const void *beg_p,
+ const void *mid_p,
+ const void *end_p) {
+ return __sanitizer_contiguous_container_find_bad_address(beg_p, mid_p, end_p)
+ == nullptr;
}
extern "C" SANITIZER_INTERFACE_ATTRIBUTE
Index: include/sanitizer/common_interface_defs.h
===================================================================
--- include/sanitizer/common_interface_defs.h
+++ include/sanitizer/common_interface_defs.h
@@ -105,7 +105,14 @@
int __sanitizer_verify_contiguous_container(const void *beg, const void *mid,
const void *end);
- // Print the stack trace leading to this call. Useful for debugging user code.
+ // Similar to __sanitizer_verify_contiguous_container but the address of the
+ // first improperly poisoned byte otherwise. Returns null if the area is
+ // poisoned properly.
+ const void* __sanitizer_contiguous_container_find_bad_address(
+ const void *beg, const void *mid, const void *end);
+
+
+// Print the stack trace leading to this call. Useful for debugging user code.
void __sanitizer_print_stack_trace();
// Sets the callback to be called right before death on error.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14341.39226.patch
Type: text/x-patch
Size: 3353 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151104/6cce4235/attachment.bin>
More information about the llvm-commits
mailing list