llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.67k stars 11.86k forks source link

Provide a .so that overrides malloc/free with GWP-ASAN #43517

Open 24ae4267-5921-45a9-a006-c88f1b8f1b03 opened 4 years ago

24ae4267-5921-45a9-a006-c88f1b8f1b03 commented 4 years ago
Bugzilla Link 44172
Version unspecified
OS All
CC @hctim

Extended Description

It'd be very useful if GWP-ASAN included a .so that could trivially be LD_PRELOAD'd to override malloc/free to use GWP-ASAN + fallback to libc's malloc.

This would specifically make using GWP-ASAN in contexts such as server-software, where the person doing the deployment uses OS provided libraries such as OpenSSL or binaries like Python, and simply wants to easily apply GWP-ASAN across their fleet.

24ae4267-5921-45a9-a006-c88f1b8f1b03 commented 4 years ago

I'm unlikely to have the time for this in the short term -- for now, I'm just using Scudo's .so for this :-) I do think having a just-GWP-ASAN .so would be valuable though.

hctim commented 4 years ago

If you'd be interested in contributing by the way, more than happy to help with reviews :)

hctim commented 4 years ago

I agree - I think it's a worthwhile addition to have some c/c++ malloc wrappers and distribute a gwp_asan.so.

There is some increased performance overhead from interposing the symbols like this, we require a dlopen(RTLD_NEXT) on first call to malloc/free/etc., and indirect overhead from there, but that may be acceptable to users.

I can't promise anything at this stage unfortunately, but will definitely bear this in mind.