You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a sanitizer like Address Sanitizer with luzer, it’s
necessary to LD_PRELOAD the sanitizer's shared object. ASan requires
that it be loaded first, before anything else; it must either be
preloaded, or statically linked into the executable (in this case, the
Lua interpreter). ASan and UBSan define many of the same code
coverage symbols as libFuzzer. In typical libFuzzer usage, this isn’t an
issue, since ASan/UBSan declare those symbols weak; the libFuzzer ones
take precedence. But when libFuzzer is loaded in a shared object later,
that doesn't work. The symbols from ASan/UBSan have already been loaded
via LD_PRELOAD, and coverage information therefore goes to those
libraries, leaving libFuzzer very broken.
The only good way to solve this is to link libFuzzer into Lua itself,
instead of luzer. Since it's therefore part of the proper executable
rather than a shared object that's dynamically loaded later, symbol
resolution works correctly and libFuzzer symbols take precedence.
```
cd build/lua-master/source
mkdir lf
cp /usr/lib/llvm-21/lib/clang/21/lib/linux/libclang_rt.fuzzer_no_main-x86_64.a lf/
cd lf/
ar x libclang_rt.fuzzer_no_main-x86_64.a
```
The patch make the following changes:
- rename cmake/SetClangLibRT.cmake to cmake/LibFuzzer.cmake
- bump luzer version to the latest
- add a CMake function that unpacks LibFuzzer
- update PUC Rio Lua and LuaJIT patches so their build systems
can link LibFuzzer object files with Lua runtime executable
binaries
1. https://security.googleblog.com/2020/12/how-atheris-python-fuzzer-works.html
2. https://github.com/google/atheris/blob/master/native_extension_fuzzing.md#option-b-linking-libfuzzer-into-python
3. https://github.com/google/atheris/blob/master/libfuzzer_mod/cpython-3.8.6-add-libFuzzer.patch
Follows up tarantool/tarantool#11884
0 commit comments