Skip to content

Conversation

@evverx
Copy link
Contributor

@evverx evverx commented May 18, 2019

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)

@evverx evverx added do-not-merge 💣 fuzzing Implementation of fuzzers and fixes for stuff found through fuzzing labels May 18, 2019
@evverx evverx force-pushed the turn-off-libmount-and-libcap branch from 565bb3d to 86a326b Compare May 18, 2019 18:50
Otherwise it will complain that
AD BUILD /out/fuzz-udev-database is not built for architecture: x86_64
file command output: /out/fuzz-udev-database: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-, for GNU/Linux 2.6.32, not stripped
check_mixed_sanitizers test will fail.
@evverx
Copy link
Contributor Author

evverx commented Jun 14, 2019

I'll go ahead and close this to make it more or less clear that I'm not working on it. It would be great if it was picked up though. PRs are welcome as usual :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge 💣 fuzzing Implementation of fuzzers and fixes for stuff found through fuzzing

Development

Successfully merging this pull request may close these issues.

1 participant