Open llvmbot opened 7 years ago
The demangler uses a recursive descent parser, and is processing untrusted user input. This results in a terrible failure mode. If we could use C++20, coroutines would be the natural way to implement a non-stack-recursive parser.
Extended Description
Dear All,
This bug was found with AFLGo, a directed version of AFL/AFLFast. Thanks also to Marcel Böhme and Van-Thuan Pham.
First, you need to build the project (https://github.com/llvm-mirror/libcxxabi/blob/master/fuzz/cxa_demangle_fuzzer.cpp) to obtain the binary file.
To reproduce: $ printf "DTc" > test $ for o in $(seq 1 15000); do printf "o"; done >> test; echo "" >> test; cat test | ./cxa_demangle_fuzzer Segmentation fault
ASAN says: ==30344==ERROR: AddressSanitizer: stack-overflow on address 0x7fffe25c2700 (pc 0x0000006c554e bp 0x7fffe25c4eb0 sp 0x7fffe25c2700 T0)
0 0x6c554d in char const __cxxabiv1::(anonymous namespace)::parse_expression<__cxxabiv1::(anonymous namespace)::Db>(char const, char const*, __cxxabiv1::(anonymous namespace)::Db&) /src/llvm_libcxxabi/src/cxa_demangle.cpp:3321
Regards, Manh-Dung Nguyen