mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Fangrui Song <i@maskray.me>
To: musl@lists.openwall.com
Subject: [musl] sanitizers and musl
Date: Mon, 28 Dec 2020 22:15:00 -0800	[thread overview]
Message-ID: <20201229061500.7eksavfiobh326lk@gmail.com> (raw)

With https://reviews.llvm.org/D93848 (and various random fixes I pushed
separately), many sanitizers will build and work on a musl based distribution.
A maintainer said the patch is in a pretty good shape and is very likely
accepted.

For folks who want to play with sanitizers ( https://github.com/llvm/llvm-project )

cmake -GNinja -Hllvm -BRelease -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS='clang;lld;libunwind;compiler-rt;libcxx;libcxxabi' -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-alpine-linux-musl -DLLVM_TARGETS_TO_BUILD=X86 -DLIBCXX_HAS_MUSL_LIBC=On -DLLVM_APPEND_VC_REV=OFF
ninja -C Release asan cfi msan tsan ubsan

Release/bin/clang -fsanitize=address
Release/bin/clang -fsanitize=memory
Release/bin/clang -fsanitize=thread
Release/bin/clang -fsanitize=undefined
Release/bin/clang -fsanitize=cfi -flto -fvisibility=default

Hopefully this can be available before LLVM 12.0 is branched.

There is currently a CMake issue making check-msan/check-tsan fail to build
with libc++. I filed https://bugs.llvm.org/show_bug.cgi?id=48618 Hope someone
with CMake experience can figure out the solution:) 

(
Are interceptors poking into internals brittle?

Yes and no. sanitizer_platform_limits_posix.h has many structures which assume specific struct layouts.
Functions using them are surely less reliable. For asan (which tracks
addressability)/tsan (which detects concurrency issues in libc functions),
failure to intercept libc functions in many cases just increase false
negatives, which is not an insurmountable problem. For msan (initialized bits),
smaller interception coverage can increase false positives, which is a big problem.)

% ninja check-asan
(known issues:
* ASAN_OPTIONS=fast_unwind_on_malloc=0 odr-violations hangs
)
...
Testing Time: 332.62s
   Unsupported      : 185
   Passed           : 511
   Expectedly Failed:   1
   Failed           :  13

% ninja check-ubsan check-ubsan-minimal check-memprof # all passed

% ninja check-cfi
( all cross-dso/)
...
Testing Time: 8.68s
   Unsupported      : 264
   Passed           :  80
   Expectedly Failed:   8
   Failed           :  32

% ninja check-msan
(Work around a CMake problem (https://bugs.llvm.org/show_bug.cgi?id=48618))
Testing Time: 23.48s
   Unsupported      :   6
   Passed           : 756
   Expectedly Failed:   2
   Failed           :  66

% ninja check-tsan
(Work around a CMake problem (https://bugs.llvm.org/show_bug.cgi?id=48618))
Testing Time: 23.21s
   Unsupported      :  86
   Passed           : 295
   Expectedly Failed:   1
   Failed           :  25

             reply	other threads:[~2020-12-29  6:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-29  6:15 Fangrui Song [this message]
2020-12-29  7:44 ` Dmitry Golovin
2020-12-29  8:36   ` Ray
2020-12-29 16:58     ` Dmitry Golovin
2020-12-31 17:04       ` Fangrui Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201229061500.7eksavfiobh326lk@gmail.com \
    --to=i@maskray.me \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).