mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] sanitizers and musl
@ 2020-12-29  6:15 Fangrui Song
  2020-12-29  7:44 ` Dmitry Golovin
  0 siblings, 1 reply; 5+ messages in thread
From: Fangrui Song @ 2020-12-29  6:15 UTC (permalink / raw)
  To: musl

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [musl] sanitizers and musl
  2020-12-29  6:15 [musl] sanitizers and musl Fangrui Song
@ 2020-12-29  7:44 ` Dmitry Golovin
  2020-12-29  8:36   ` Ray
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Golovin @ 2020-12-29  7:44 UTC (permalink / raw)
  To: musl

29.12.2020, 08:15, "Fangrui Song" <i@maskray.me>:
> 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.

Hi Fangrui,

Did I understand correctly that your patches this one is rendered useless?

https://github.com/tpimh/ngtc/blob/docker/root/patch/compiler-rt-01-sanitizer-nongnu.patch

If your changes make it to LLVM 12, patching for musl won't be necessary anymore?

Regards,
Dima

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [musl] sanitizers and musl
  2020-12-29  7:44 ` Dmitry Golovin
@ 2020-12-29  8:36   ` Ray
  2020-12-29 16:58     ` Dmitry Golovin
  0 siblings, 1 reply; 5+ messages in thread
From: Ray @ 2020-12-29  8:36 UTC (permalink / raw)
  To: musl

On Mon, Dec 28, 2020 at 11:44 PM Dmitry Golovin <dima@golovin.in> wrote:
>
> 29.12.2020, 08:15, "Fangrui Song" <i@maskray.me>:
> > 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.
>
> Hi Fangrui,
>
> Did I understand correctly that your patches this one is rendered useless?
>
> https://github.com/tpimh/ngtc/blob/docker/root/patch/compiler-rt-01-sanitizer-nongnu.patch
>
> If your changes make it to LLVM 12, patching for musl won't be necessary anymore?
>
> Regards,
> Dima

Thanks for the link! I was not aware of the other attempts. I'll check
whether your patch includes anything I'm missing.

(My patch hasn't sorted out the ioctl issues.)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [musl] sanitizers and musl
  2020-12-29  8:36   ` Ray
@ 2020-12-29 16:58     ` Dmitry Golovin
  2020-12-31 17:04       ` Fangrui Song
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Golovin @ 2020-12-29 16:58 UTC (permalink / raw)
  To: musl; +Cc: anarchy

29.12.2020, 10:37, "Ray" <emacsray@gmail.com>:
> On Mon, Dec 28, 2020 at 11:44 PM Dmitry Golovin <dima@golovin.in> wrote:
>>  29.12.2020, 08:15, "Fangrui Song" <i@maskray.me>:
>>  > 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.
>>
>>  Hi Fangrui,
>>
>>  Did I understand correctly that your patches this one is rendered useless?
>>
>>  https://github.com/tpimh/ngtc/blob/docker/root/patch/compiler-rt-01-sanitizer-nongnu.patch
>>
>>  If your changes make it to LLVM 12, patching for musl won't be necessary anymore?
>>
>>  Regards,
>>  Dima
>
> Thanks for the link! I was not aware of the other attempts. I'll check
> whether your patch includes anything I'm missing.
>
> (My patch hasn't sorted out the ioctl issues.)

Hi Ray,

I'm not quite sure now who is the original author of this patch. Maybe Jory Pratt?

Anyway I was updating the patch for recent LLVM releases, most up-to-date code should be in version-11.0.0 branch.

Regards,
Dima

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [musl] sanitizers and musl
  2020-12-29 16:58     ` Dmitry Golovin
@ 2020-12-31 17:04       ` Fangrui Song
  0 siblings, 0 replies; 5+ messages in thread
From: Fangrui Song @ 2020-12-31 17:04 UTC (permalink / raw)
  To: musl; +Cc: anarchy

On 2020-12-29, Dmitry Golovin wrote:
>29.12.2020, 10:37, "Ray" <emacsray@gmail.com>:
>> On Mon, Dec 28, 2020 at 11:44 PM Dmitry Golovin <dima@golovin.in> wrote:
>>>  29.12.2020, 08:15, "Fangrui Song" <i@maskray.me>:
>>>  > 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.
>>>
>>>  Hi Fangrui,
>>>
>>>  Did I understand correctly that your patches this one is rendered useless?
>>>
>>>  https://github.com/tpimh/ngtc/blob/docker/root/patch/compiler-rt-01-sanitizer-nongnu.patch
>>>
>>>  If your changes make it to LLVM 12, patching for musl won't be necessary anymore?
>>>
>>>  Regards,
>>>  Dima
>>
>> Thanks for the link! I was not aware of the other attempts. I'll check
>> whether your patch includes anything I'm missing.
>>
>> (My patch hasn't sorted out the ioctl issues.)
>
>Hi Ray,
>
>I'm not quite sure now who is the original author of this patch. Maybe Jory Pratt?
>
>Anyway I was updating the patch for recent LLVM releases, most up-to-date code should be in version-11.0.0 branch.
>
>Regards,
>Dima

https://reviews.llvm.org/D93848 will be available in the upcoming LLVM 12.0.0.
I have figured out and fixed the CMake libc++ problem.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-31 17:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-29  6:15 [musl] sanitizers and musl Fangrui Song
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

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).