Playing around with address sanitizer
Devon H. O'Dell
dho at fastly.com
Mon Feb 1 20:26:56 CET 2016
I have some patches to enable msan / asan / tsan / ubsan, as well as
test code coverage metrics. (The latter of these isn't super useful
for tsan because total code coverage doesn't guarantee you've caught
concurrent interactions between any two tested bits, but it's still a
start).
I've seen problems with using asan even without jemalloc as some libc
functions don't have asan overrides. I forget which; it's been a while
since I did a test with it, but there may be cases where it's not
useful for some tests unless the libc was built with it.
(Alternatively, this may have been fixed in more recent versions).
I'll send patches for this later today.
--dho
On Mon, Feb 1, 2016 at 10:58 AM, Dag Haavi Finstad
<daghf at varnish-software.com> wrote:
> Hi
>
> Inspired by a talk at FOSDEM this weekend [1], I tried building
> Varnish with -fsanitize=address enabled.
>
> This exposed a few buffer overflow situations, mainly in varnishtest.
> Patches w/ fixes attached.
>
> This was done with ASan's leak checker disabled, since varnishtest has
> intentional memory leaks and I haven't yet investigated if specific
> allocations can be annotated to make ASan disregard individual leaks.
>
> In addition, there is a use-after-free situation in current master
> related to ESI (not present in 4.1.1). I'm about to file a bug for
> that one.
>
> In order to build varnish w/ -fsanitize=address, you can do
> ./autogen.des --without-jemalloc CFLAGS="-fno-omit-frame-pointer
> -fsanitize=address"
> export ASAN_OPTIONS=detect_leaks=0
> followed by the regular make/make check/etc.
>
> This requires clang >= 3.1 or gcc >= 4.8. Disabling jemalloc is
> required as ASan only works with the system allocator.
>
> Note the third patch attached may be a false positive, but I think it
> could be an issue on platforms where memcmp does 64 bit word
> comparisons at a time.
>
> Regards,
> Dag
>
>
> [1]: https://fosdem.org/2016/schedule/event/csafecode/attachments/slides/1131/export/events/attachments/csafecode/slides/1131/fosdem_gentoo_asan.pdf
>
> --
> Dag Haavi Finstad
> Software Developer | Varnish Software
> Mobile: +47 476 64 134
> We Make Websites Fly!
>
> _______________________________________________
> varnish-dev mailing list
> varnish-dev at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
More information about the varnish-dev
mailing list