nDPI/fuzz
Ivan Nardi ebcea42e2b
fuzz: improve fuzzers using pl7m (#2486)
For some unclear reasons, fuzzers using pl7m create huge corpus,
triggering OOM in oss-fuzz runs (where the memory RSS limit is set to
2560Mb). Example:

```
==25340== ERROR: libFuzzer: out-of-memory (used: 2564Mb; limit: 2560Mb)
To change the out-of-memory limit use -rss_limit_mb=<N>

Live Heap Allocations: 2364004039 bytes in 133791 chunks; quarantined: 60662293 bytes in 3664 chunks; 176432 other chunks; total chunks: 313887; showing top 95% (at most 8 unique contexts)
1285841683 byte(s) (54%) in 2956 allocation(s)
    #0 0x56f814ef4bde in __interceptor_malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
    #1 0x56f814e04416 in operator new(unsigned long) cxa_noexception.cpp:0
    #2 0x56f814de6b2d in assign<unsigned char *, 0> /work/llvm-stage2/runtimes/runtimes-bins/compiler-rt/lib/fuzzer/libcxx_fuzzer_x86_64/include/c++/v1/vector:1443:3
    #3 0x56f814de6b2d in operator= /work/llvm-stage2/runtimes/runtimes-bins/compiler-rt/lib/fuzzer/libcxx_fuzzer_x86_64/include/c++/v1/vector:1412:9
    #4 0x56f814de6b2d in fuzzer::InputCorpus::AddToCorpus(std::__Fuzzer::vector<unsigned char, std::__Fuzzer::allocator<unsigned char>> const&, unsigned long, bool, bool, bool, std::__Fuzzer::chrono::duration<long long, std::__Fuzzer::ratio<1l, 1000000l>>, std::__Fuzzer::vector<unsigned int, std::__Fuzzer::allocator<unsigned int>> const&, fuzzer::DataFlowTrace const&, fuzzer::InputInfo const*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerCorpus.h:221:10
    #5 0x56f814de60e5 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:539:16
    #6 0x56f814de7df2 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:829:7
    #7 0x56f814de8127 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:867:3
    #8 0x56f814dd6736 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:914:6
    #9 0x56f814e02c62 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
    #10 0x7fa11e2c3082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/libc-start.c:308:16

1031350683 byte(s) (43%) in 2468 allocation(s)
    #0 0x56f814ef4bde in __interceptor_malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
    #1 0x56f814e04416 in operator new(unsigned long) cxa_noexception.cpp:0
    #2 0x56f814de6b2d in assign<unsigned char *, 0> /work/llvm-stage2/runtimes/runtimes-bins/compiler-rt/lib/fuzzer/libcxx_fuzzer_x86_64/include/c++/v1/vector:1443:3
    #3 0x56f814de6b2d in operator= /work/llvm-stage2/runtimes/runtimes-bins/compiler-rt/lib/fuzzer/libcxx_fuzzer_x86_64/include/c++/v1/vector:1412:9
    #4 0x56f814de6b2d in fuzzer::InputCorpus::AddToCorpus(std::__Fuzzer::vector<unsigned char, std::__Fuzzer::allocator<unsigned char>> const&, unsigned long, bool, bool, bool, std::__Fuzzer::chrono::duration<long long, std::__Fuzzer::ratio<1l, 1000000l>>, std::__Fuzzer::vector<unsigned int, std::__Fuzzer::allocator<unsigned int>> const&, fuzzer::DataFlowTrace const&, fuzzer::InputInfo const*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerCorpus.h:221:10
    #5 0x56f814de60e5 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:539:16
    #6 0x56f814de7635 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:760:19
    #7 0x56f814de8425 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile>>&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:905:5
    #8 0x56f814dd6736 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:914:6
    #9 0x56f814e02c62 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10
    #10 0x7fa11e2c3082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/libc-start.c:308:16
```

See: https://oss-fuzz.com/testcase-detail/4717811415449600
See: https://oss-fuzz.com/testcase-detail/6164130982068224

Let's *try* the following workaround: set the parameter `-max-len` to
512K, to force the engine to not genereate inputs (i.e. pcap files...)
larger than 512K. Right now the value used is 1MB, i.e the default,
because we have file larger than 1MB in the initial seeds (i.e.
`/tests/pcaps/*`).

Let's hope than having smaller files lead to smaller corpus...

Update pl7m code (fix a Use-of-uninitialized-value error)
2024-06-29 18:01:05 +02:00
..
corpus fuzz: improve fuzzing coverage (#2474) 2024-06-17 13:45:47 +02:00
bd_param.txt fuzz: extend coverage (#2073) 2023-08-20 15:18:19 +02:00
dictionary.dict Add HL7 protocol dissector (#2240) 2024-01-02 20:57:05 +01:00
dictionary_tls_certificate.dict fuzz: add a new fuzzer to test TLS certificates (#1901) 2023-03-20 17:00:46 +01:00
fuzz_alg_bins.cpp fuzz: some improvements and add two new fuzzers (#1881) 2023-02-09 20:02:12 +01:00
fuzz_alg_bytestream.c fuzz: extend fuzz coverage (#1888) 2023-02-16 18:04:34 +01:00
fuzz_alg_crc32_md5.c fuzz: improve fuzzing coverage (#2309) 2024-02-09 19:19:03 +01:00
fuzz_alg_hll.cpp fuzz: some improvements and add two new fuzzers (#1881) 2023-02-09 20:02:12 +01:00
fuzz_alg_hw_rsi_outliers_da.cpp fuzz: improve fuzzing coverage (#2239) 2024-01-02 15:22:44 +01:00
fuzz_alg_hw_rsi_outliers_da.options fuzz: extend fuzzing coverage (#2205) 2023-12-11 12:48:50 +01:00
fuzz_alg_jitter.cpp fuzz: some improvements and add two new fuzzers (#1881) 2023-02-09 20:02:12 +01:00
fuzz_alg_ses_des.cpp fuzz: improve fuzzing coverage (#2239) 2024-01-02 15:22:44 +01:00
fuzz_alg_shoco.cpp fuzz: improve fuzzing coverage (#2474) 2024-06-17 13:45:47 +02:00
fuzz_binaryfusefilter.cpp fuzz: extend fuzzing coverage 2023-09-16 11:26:11 +02:00
fuzz_common_code.c Allow multiple struct ndpi_detection_module_struct to share some state (#2271) 2024-02-01 15:33:11 +01:00
fuzz_common_code.h Allow multiple struct ndpi_detection_module_struct to share some state (#2271) 2024-02-01 15:33:11 +01:00
fuzz_community_id.cpp Add some fuzzers to test other data structures. (#1870) 2023-01-25 11:44:59 +01:00
fuzz_config.cpp fuzz: improve fuzzing coverage (#2474) 2024-06-17 13:45:47 +02:00
fuzz_config.options fuzz: fuzz_config: we need bigegr inputs (#2285) 2024-01-25 09:58:20 +01:00
fuzz_dga.c Allow multiple struct ndpi_detection_module_struct to share some state (#2271) 2024-02-01 15:33:11 +01:00
fuzz_ds_ahocorasick.cpp fuzz: improve fuzzing coverage (#2474) 2024-06-17 13:45:47 +02:00
fuzz_ds_ahocorasick.options fuzz: improve fuzzing coverage (#2239) 2024-01-02 15:22:44 +01:00
fuzz_ds_bitmap64_fuse.cpp Added support for roaring bitmap v3 (#2355) 2024-03-25 08:15:19 +01:00
fuzz_ds_cmsketch.cpp fuzz: extend fuzzing coverage (#2052) 2023-07-18 07:41:56 +02:00
fuzz_ds_domain_classify.cpp fuzz: improve fuzzing coverage (#2474) 2024-06-17 13:45:47 +02:00
fuzz_ds_hash.cpp fuzz: improvements (#2400) 2024-04-20 18:15:23 +02:00
fuzz_ds_libcache.cpp Add some fuzzers to test other data structures. (#1870) 2023-01-25 11:44:59 +01:00
fuzz_ds_patricia.cpp fuzz: extend fuzzing coverage (#2281) 2024-01-24 21:16:58 +01:00
fuzz_ds_ptree.cpp Small fixes after API cleanup done in c63446e59 (#2449) 2024-05-20 19:06:24 +02:00
fuzz_ds_tree.cpp Disable -Wno-unused-parameter -Wno-unused-function. (#2358) 2024-04-03 14:10:21 +02:00
fuzz_filecfg_categories.c Allow multiple struct ndpi_detection_module_struct to share some state (#2271) 2024-02-01 15:33:11 +01:00
fuzz_filecfg_category.c Allow multiple struct ndpi_detection_module_struct to share some state (#2271) 2024-02-01 15:33:11 +01:00
fuzz_filecfg_config.c Allow multiple struct ndpi_detection_module_struct to share some state (#2271) 2024-02-01 15:33:11 +01:00
fuzz_filecfg_malicious_ja3.c Allow multiple struct ndpi_detection_module_struct to share some state (#2271) 2024-02-01 15:33:11 +01:00
fuzz_filecfg_malicious_sha1.c Allow multiple struct ndpi_detection_module_struct to share some state (#2271) 2024-02-01 15:33:11 +01:00
fuzz_filecfg_protocols.c Allow multiple struct ndpi_detection_module_struct to share some state (#2271) 2024-02-01 15:33:11 +01:00
fuzz_filecfg_risk_domains.c Allow multiple struct ndpi_detection_module_struct to share some state (#2271) 2024-02-01 15:33:11 +01:00
fuzz_gcrypt_aes.cpp fuzz: extend fuzzing coverage (#2205) 2023-12-11 12:48:50 +01:00
fuzz_gcrypt_cipher.cpp fuzz: improve fuzzing coverage (#2474) 2024-06-17 13:45:47 +02:00
fuzz_gcrypt_gcm.cpp fuzz: extend fuzzing coverage (#2205) 2023-12-11 12:48:50 +01:00
fuzz_gcrypt_light.cpp fuzz: improve fuzzing coverage (#2309) 2024-02-09 19:19:03 +01:00
fuzz_is_stun.c Allow multiple struct ndpi_detection_module_struct to share some state (#2271) 2024-02-01 15:33:11 +01:00
fuzz_libinjection.c fuzz: extend fuzzing coverage 2023-10-15 12:00:26 +02:00
fuzz_ndpi_reader.c fuzz: pl7m: add a custom mutator for better fuzzing of pcap files (#2483) 2024-06-27 18:07:43 +02:00
fuzz_ndpi_reader_payload_analyzer.options fuzz: extend fuzzing coverage 2023-10-15 12:00:26 +02:00
fuzz_ndpi_reader_pl7m.options fuzz: improve fuzzers using pl7m (#2486) 2024-06-29 18:01:05 +02:00
fuzz_ndpi_reader_pl7m_64k.options fuzz: improve fuzzers using pl7m (#2486) 2024-06-29 18:01:05 +02:00
fuzz_ndpi_reader_pl7m_internal.options fuzz: improve fuzzers using pl7m (#2486) 2024-06-29 18:01:05 +02:00
fuzz_ndpi_reader_pl7m_internal_simplest.options fuzz: improve fuzzers using pl7m (#2486) 2024-06-29 18:01:05 +02:00
fuzz_ndpi_reader_pl7m_simplest.options fuzz: improve fuzzers using pl7m (#2486) 2024-06-29 18:01:05 +02:00
fuzz_process_packet.c Allow multiple struct ndpi_detection_module_struct to share some state (#2271) 2024-02-01 15:33:11 +01:00
fuzz_quic_get_crypto_data.c Allow multiple struct ndpi_detection_module_struct to share some state (#2271) 2024-02-01 15:33:11 +01:00
fuzz_readerutils_parseprotolist.cpp example: rework code between ndpiReader.c and reader_util.c (#2273) 2024-01-22 18:12:06 +01:00
fuzz_readerutils_workflow.cpp wireshark: lua: export some metadata 2024-06-25 16:39:45 +02:00
fuzz_serialization.cpp fuzz: improve fuzzing coverage (#2474) 2024-06-17 13:45:47 +02:00
fuzz_tls_certificate.c Allow multiple struct ndpi_detection_module_struct to share some state (#2271) 2024-02-01 15:33:11 +01:00
ipv4_addresses.txt fuzz: extend fuzzing coverage (#2281) 2024-01-24 21:16:58 +01:00
ipv6_addresses.txt Fix/improve fuzzing (#2426) 2024-05-08 11:46:02 +02:00
Makefile.am fuzz: pl7m: add a custom mutator for better fuzzing of pcap files (#2483) 2024-06-27 18:07:43 +02:00
random_list.list fuzz: extend fuzzing coverage 2023-09-16 11:26:11 +02:00
splt_param.txt fuzz: extend coverage (#2073) 2023-08-20 15:18:19 +02:00