[cfe-dev] AddressSanitizer suppressions enhancement

Gaurav Malhotra malhotrag at gmail.com
Mon May 11 07:09:29 PDT 2015


Hi,

I've very recently started looking at clang+ASan to sanitize my
application. I discovered that the run time suppressions support added by
http://reviews.llvm.org/D6280 does not suppress memcpy-param-overlap (and
other *-param-overlap) errors. I want to suppress these errors from a
library that I cannot recompile.

I looked at the code in asan_interceptors.cc and it seems to me that the
suppressions mechanism used for ASAN_READ_RANGE and ASAN_WRITE_RANGE can
easily be extended to CHECK_RANGES_OVERLAP. I made those code changes and
recompiled clang and everything seems to be working as I expected. The
essence of my changes is listed at the bottom of this email.

Is this change appropriate? If yes, what is the process to get this code
committed?

Thanks and Regards,
Gaurav Malhotra

P.S. Here is the code change I made to CHECK_RANGES_OVERLAP. This was
accompanied by changes to all the callers of this macro to pass the
AsanInterceptorContext pointer that they already have.

--- a/lib/asan/asan_interceptors.cc
+++ b/lib/asan/asan_interceptors.cc
@@ -82,13 +82,24 @@ static inline bool RangesOverlap(const char *offset1,
uptr length1,
                                  const char *offset2, uptr length2) {
   return !((offset1 + length1 <= offset2) || (offset2 + length2 <=
offset1));
 }
-#define CHECK_RANGES_OVERLAP(name, _offset1, length1, _offset2, length2)
do { \
+#define CHECK_RANGES_OVERLAP(ctx, name, _offset1, length1, _offset2,
length2) do { \
   const char *offset1 = (const char*)_offset1; \
   const char *offset2 = (const char*)_offset2; \
   if (RangesOverlap(offset1, length1, offset2, length2)) { \
-    GET_STACK_TRACE_FATAL_HERE; \
-    ReportStringFunctionMemoryRangesOverlap(name, offset1, length1, \
-                                            offset2, length2, &stack); \
+      AsanInterceptorContext *_ctx = (AsanInterceptorContext *)ctx;     \
+      bool suppressed = false;                                          \
+      if (_ctx) {                                                       \
+        suppressed = IsInterceptorSuppressed(_ctx->interceptor_name);   \
+        if (!suppressed && HaveStackTraceBasedSuppressions()) {         \
+          GET_STACK_TRACE_FATAL_HERE;                                   \
+          suppressed = IsStackTraceSuppressed(&stack);                  \
+        }                                                               \
+      }                                                                 \
+      if (!suppressed) {                                                \
+        GET_STACK_TRACE_FATAL_HERE;                                     \
+        ReportStringFunctionMemoryRangesOverlap(name, offset1, length1, \
+                                             offset2, length2, &stack); \
+      }                                                                 \
   } \
 } while (0)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150511/7ddfe83b/attachment.html>


More information about the cfe-dev mailing list