Make it possible to build the fuzzers on "i386" #12608
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a proof of concept (that works to some degree) but basically a couple of popsicle sticks, duct tape and a little glue.
Inspired by google/oss-fuzz#2295.
It wouldn't be a PR about fuzzing :-) if I didn't show a backtrace so the first target that was confused when it was run in 32-bit mode was
fuzz-bus-message:==309==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf4ea3d10 at pc 0x08115419 bp 0xffbb25c8 sp 0xffbb21a0 READ of size 10 at 0xf4ea3d10 thread T0 #0 0x8115418 in memchr /src/llvm/projects/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:905:3 #1 0xf7b556a8 in validate_nul /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-message.c:3292:13 #2 0xf7b43ac0 in validate_string /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-message.c:3304:14 #3 0xf7b4d3c4 in message_peek_field_string /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-message.c:4935:22 #4 0xf7b4dddc in message_skip_fields /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-message.c:5022:29 #5 0xf7b2b311 in bus_message_parse_fields /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-message.c:5434:37 #6 0xf7b2a294 in bus_message_from_malloc /work/build/../../src/systemd/src/libsystemd/sd-bus/bus-message.c:559:13 #7 0x81a8806 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-bus-message.c:30:13 #8 0x80b25f9 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned int) /src/llvm/projects/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:553:15 #9 0x80b1f45 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned int, bool, fuzzer::InputInfo*, bool*) /src/llvm/projects/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:471:3 #10 0x80b3d90 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::Fuzzer::vector<std::Fuzzer::basic_string<char, std::Fuzzer::char_traits<char>, std::Fuzzer::allocator<char> >, fuzzer::fuzzer_allocator<std::Fuzzer::basic_string<char, std::Fuzzer::char_traits<char>, std::Fuzzer::allocator<char> > > > const&, std::Fuzzer::vector<std::Fuzzer::basic_string<char, std::Fuzzer::char_traits<char>, std::Fuzzer::allocator<char> >, fuzzer::fuzzer_allocator<std::Fuzzer::basic_string<char, std::Fuzzer::char_traits<char>, std::Fuzzer::allocator<char> > > > const&) /src/llvm/projects/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:781:7 #11 0x80b3f96 in fuzzer::Fuzzer::Loop(std::Fuzzer::vector<std::Fuzzer::basic_string<char, std::Fuzzer::char_traits<char>, std::Fuzzer::allocator<char> >, fuzzer::fuzzer_allocator<std::Fuzzer::basic_string<char, std::Fuzzer::char_traits<char>, std::Fuzzer::allocator<char> > > > const&, std::Fuzzer::vector<std::Fuzzer::basic_string<char, std::Fuzzer::char_traits<char>, std::Fuzzer::allocator<char> >, fuzzer::fuzzer_allocator<std::Fuzzer::basic_string<char, std::Fuzzer::char_traits<char>, std::Fuzzer::allocator<char> > > > const&) /src/llvm/projects/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:805:3 #12 0x80a4365 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned int)) /src/llvm/projects/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:787:6 #13 0x80c96a7 in main /src/llvm/projects/compiler-rt/lib/fuzzer/FuzzerMain.cpp:19:10 #14 0xf758e636 in __libc_start_main (/lib32/libc.so.6+0x18636) #15 0x80675c8 in _start (/out/fuzz-bus-message+0x80675c8) 0xf4ea3d10 is located 0 bytes to the right of 32-byte region [0xf4ea3cf0,0xf4ea3d10) allocated by thread T0 here: #0 0x8174175 in malloc /src/llvm/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:145:3 #1 0xf7a00865 in memdup /work/build/../../src/systemd/src/basic/alloc-util.c:16:15 #2 0x81a87bf in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-bus-message.c:28:9 #3 0x80b25f9 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned int) /src/llvm/projects/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:553:15 #4 0x80b1f45 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned int, bool, fuzzer::InputInfo*, bool*) /src/llvm/projects/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:471:3 #5 0x80b3d90 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::Fuzzer::vector<std::Fuzzer::basic_string<char, std::Fuzzer::char_traits<char>, std::Fuzzer::allocator<char> >, fuzzer::fuzzer_allocator<std::Fuzzer::basic_string<char, std::Fuzzer::char_traits<char>, std::Fuzzer::allocator<char> > > > const&, std::Fuzzer::vector<std::Fuzzer::basic_string<char, std::Fuzzer::char_traits<char>, std::Fuzzer::allocator<char> >, fuzzer::fuzzer_allocator<std::Fuzzer::basic_string<char, std::Fuzzer::char_traits<char>, std::Fuzzer::allocator<char> > > > const&) /src/llvm/projects/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:781:7 #6 0x80b3f96 in fuzzer::Fuzzer::Loop(std::Fuzzer::vector<std::Fuzzer::basic_string<char, std::Fuzzer::char_traits<char>, std::Fuzzer::allocator<char> >, fuzzer::fuzzer_allocator<std::Fuzzer::basic_string<char, std::Fuzzer::char_traits<char>, std::Fuzzer::allocator<char> > > > const&, std::Fuzzer::vector<std::Fuzzer::basic_string<char, std::Fuzzer::char_traits<char>, std::Fuzzer::allocator<char> >, fuzzer::fuzzer_allocator<std::Fuzzer::basic_string<char, std::Fuzzer::char_traits<char>, std::Fuzzer::allocator<char> > > > const&) /src/llvm/projects/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:805:3 #7 0x80a4365 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned int)) /src/llvm/projects/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:787:6 #8 0x80c96a7 in main /src/llvm/projects/compiler-rt/lib/fuzzer/FuzzerMain.cpp:19:10 #9 0xf758e636 in __libc_start_main (/lib32/libc.so.6+0x18636)