Add fuzzing harness for BanMan.
See doc/fuzzing.md for information on how to fuzz Bitcoin Core. Don't forget to contribute any coverage increasing inputs you find to the Bitcoin Core fuzzing corpus repo.
Happy fuzzing :)
Add fuzzing harness for BanMan.
See doc/fuzzing.md for information on how to fuzz Bitcoin Core. Don't forget to contribute any coverage increasing inputs you find to the Bitcoin Core fuzzing corpus repo.
Happy fuzzing :)
Now fuzzing BanMan::Discourage(…) too: the commit from #19219 is now part of this PR.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
33 | +{ 34 | + FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; 35 | + const fs::path banlist_file = GetDataDir() / "fuzzed_banlist.dat"; 36 | + fs::remove(banlist_file); 37 | + { 38 | + BanMan ban_man{banlist_file, nullptr, ConsumeBanTimeOffset(fuzzed_data_provider)};
@practicalswift Do you think adding random data to "fuzzed_banlist.dat", then calling BanMan ban_man{banlist_file, nullptr, ConsumeBanTimeOffset(fuzzed_data_provider)}; could be its own fuzz test? It would basically fuzz DeserializeFileDB in src/addrdb.cpp.
That is a good idea that can be tackled in a follow-up PR, but instead of writing files to disk I think we should use a mocked/fuzzed filesystem interface like the one that will be introduced as part of #19143. Please consider reviewing that PR :)
Tested ACK :)
Ran against ad953a2 for about 18 hours on a Ubuntu VM with 2 core and 2g RAM. It was pretty slow even for a weak VM, probably because of file io when dumping the banlist.
start_time : 1594037321
last_update : 1594098196
fuzzer_pid : 16179
cycles_done : 0
execs_done : 379262
execs_per_sec : 6.20
paths_total : 341
paths_favored : 108
paths_found : 340
paths_imported : 0
max_depth : 4
cur_path : 134
pending_favs : 81
pending_total : 301
variable_paths : 329
stability : 98.81%
bitmap_cvg : 13.03%
unique_crashes : 0
unique_hangs : 0
last_path : 1594098172
last_crash : 0
last_hang : 0
execs_since_crash : 379262
exec_timeout : 320
afl_banner : banman
afl_version : 2.57b
target_mode : no_forksrv
command_line : afl/afl-fuzz -i inputs/ -o outputs/ -m500 -- src/test/fuzz/banman
slowest_exec_ms : 320
peak_rss_mb : 53
Coverage for banman.cpp here: https://crypt-iq.github.io/btc/fuzz-cov/src/banman.cpp.gcov.html
21 | #include <test/fuzz/FuzzedDataProvider.h>
22 | #include <test/fuzz/fuzz.h>
23 | +#include <test/util/setup_common.h>
24 | #include <txmempool.h>
25 | #include <uint256.h>
26 | #include <version.h>
instead of having a fuzz header which is included in all fuzz test, and itself includes all of bitcoin core, what about moving the implementations to a cpp file or maybe even a fuzz/util/net etc
Sounds like a plan! :)
@Crypt-iQ Thanks a lot for testing and reviewing. Great to have you on board as one of the actively reviewing fuzzing enthusiasts of the project! :)