This is an archive of the discontinued LLVM Phabricator instance.

[hwasan] Add a (almost) no-interceptor mode.
ClosedPublic

Authored by eugenis on Aug 17 2018, 1:48 PM.

Details

Summary

The idea behind this change is to allow sanitization of libc. We are prototyping on Bionic,
but the tool interface will be general enough (or at least generalizable) to support any other libc.

When libc depends on libclang_rt.hwasan, the latter can not interpose libc functions.
In fact, majority of interceptors become unnecessary when libc code is instrumented.

This change gets rid of most hwasan interceptors and provides interface for libc to notify
hwasan about thread creation and destruction events. Some interceptors (pthread_create)
are kept under #ifdef to enable testing with uninstrumented libc. They are expressed in
terms of the new libc interface.

The new cmake switch, COMPILER_RT_HWASAN_WITH_INTERCEPTORS, ON by default, builds testing
version of the library with the aforementioned pthread_create interceptor.
With the OFF setting, the library becomes more of a libc plugin.

Event Timeline

eugenis created this revision.Aug 17 2018, 1:48 PM
kcc accepted this revision.Aug 20 2018, 1:45 PM

LGTM,
but please consider moving the code around (in a separate CL) to reduce the number of #ifdefs

This revision is now accepted and ready to land.Aug 20 2018, 1:45 PM

Sure. Eventually the entire hwasan_interceptors.cc would be under one big ifdef, if things go as planned.

This revision was automatically updated to reflect the committed changes.