[cfe-dev] AddressSanitizer suppressions enhancement

Alexey Samsonov vonosmas at gmail.com
Mon May 11 15:47:55 PDT 2015


Hi Gaurav,

Yes, I think this change makes sense. Please follow the process described
in http://llvm.org/docs/Phabricator.html.
You can list me (samsonov) as a reviewer, and cc llvm-commits in the
review. Make sure to add a test case.


On Mon, May 11, 2015 at 7:09 AM, Gaurav Malhotra <malhotrag at gmail.com>
wrote:

> 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); \
> +      }                                                                 \
>

Looks like a lot of this code is copied from the ACCESS_MEMORY_RANGE
implementation. You would
probably want to reduce a copy-paste by pulling out functionality to a
separate macro.


>    } \
>  } while (0)
>
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>


-- 
Alexey Samsonov
vonosmas at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150511/7db85d44/attachment.html>


More information about the cfe-dev mailing list