-
Notifications
You must be signed in to change notification settings - Fork 37.7k
net: Make DNS lookup mockable, add fuzzing harness #19415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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. |
0f3c9dc
to
3fac214
Compare
Concept ACK |
3fac214
to
836ff14
Compare
836ff14
to
60a8427
Compare
60a8427
to
426617a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested ACK 426617a.
Coverage for ~48 hours of libfuzzer fuzzing here: https://crypt-iq.github.io/netbase_dns_cov_outs/src/netbase.cpp.gcov.html
426617a
to
954fbb7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 522b3b4
Some nits below.
Ran this for some time and submitted the generated seeds at bitcoin-core/qa-assets#50.
522b3b4
to
24e3ce3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 24e3ce3
24e3ce3
to
173272b
Compare
Concept ACK, will review.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments, will test again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested approach ACK, a few comments below.
$ FUZZ=netbase_dns_lookup src/test/fuzz/fuzz ../qa-assets/fuzz_seed_corpus/
INFO: Seed: 3479425365
INFO: Loaded 1 modules (643152 inline 8-bit counters): 643152 [0x555d231dc188, 0x555d232791d8),
INFO: Loaded 1 PC tables (643152 PCs): 643152 [0x555d232791d8,0x555d23c496d8),
INFO: 129774 files found in ../qa-assets/fuzz_seed_corpus/
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 1048576 bytes
INFO: seed corpus: files: 129774 min: 1b max: 3986616b total: 1875939121b rss: 231Mb
#8192 pulse cov: 970 ft: 1825 corp: 59/244b exec/s: 4096 rss: 337Mb
#16384 pulse cov: 1763 ft: 3612 corp: 98/809b exec/s: 4096 rss: 436Mb
#32768 pulse cov: 2090 ft: 6274 corp: 158/2458b exec/s: 4681 rss: 590Mb
#65536 pulse cov: 2121 ft: 7423 corp: 192/5608b exec/s: 5041 rss: 593Mb
#129775 INITED cov: 2235 ft: 10320 corp: 297/984Kb exec/s: 3415 rss: 1271Mb
#129813 REDUCE cov: 2235 ft: 10320 corp: 297/984Kb lim: 286065 exec/s: 3416 rss: 1271Mb L: 62/286047 MS: 3 ChangeBit-ChangeBit-EraseBytes-
.../...
#113401432 REDUCE cov: 2669 ft: 12318 corp: 458/295Kb lim: 1048576 exec/s: 1595 rss: 1271Mb L: 942/16122 MS: 4 CMP-ChangeBit-ChangeBit-EraseBytes- DE: "\x9e\xff\xff\xff"-
#113449634 REDUCE cov: 2669 ft: 12318 corp: 458/295Kb lim: 1048576 exec/s: 1595 rss: 1271Mb L: 2682/16122 MS: 2 ShuffleBytes-EraseBytes-
#113480169 REDUCE cov: 2669 ft: 12318 corp: 458/295Kb lim: 1048576 exec/s: 1595 rss: 1271Mb L: 7438/16122 MS: 5 ChangeBit-EraseBytes-PersAutoDict-InsertRepeatedBytes-InsertRepeatedBytes- DE: "\x00\x00bP\x01_\x86\xac"-
d29e3f8
to
77123b3
Compare
…ric(...)/LookupSubNet(...)
77123b3
to
e528075
Compare
cr ACK e528075 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK e528075
#include <vector> | ||
|
||
namespace { | ||
FuzzedDataProvider* fuzzed_data_provider_ptr = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style-nit: Any reason for this namespace and pointer? Looks like a lambda should be able to do the same in less code and smaller scope
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a lambda here is a good idea: less code, smaller scope and overall beautiful :)
TBH I don't remember why I didn't do it that way nine months ago when this code was written: a lambda is strictly better AFAICT :)
Address in PR #21443.
ACK e528075 Thanks for the update and |
e528075 tests: Add fuzzing harness for Lookup(...)/LookupHost(...)/LookupNumeric(...)/LookupSubNet(...) (practicalswift) c6b4bfb net: Make DNS lookup code testable (practicalswift) Pull request description: Make DNS lookup mockable/testable/fuzzable. Add fuzzing harness for `Lookup(…)`/`LookupHost(…)`/`LookupNumeric(…)`/`LookupSubNet(…)`. See [`doc/fuzzing.md`](https://github.com/bitcoin/bitcoin/blob/master/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](https://github.com/bitcoin-core/qa-assets). Happy fuzzing :) ACKs for top commit: Crypt-iQ: cr ACK e528075 vasild: ACK e528075 Tree-SHA512: 9984c2e2fedc3c1e1c3dbd701bb739ebd2f01766e6e83543dae5ae43eb8646c452bba0e101dd2f06079e5258bd5846c7d27a60ed5d77c1682b54c9544ffad443
7c8c140 fuzz: Implement fuzzed_dns_lookup_function as lambda (practicalswift) Pull request description: Implement `fuzzed_dns_lookup_function` as a lambda. As wisely suggested by MarcoFalke in bitcoin/bitcoin#19415 (comment). Thanks! :) ACKs for top commit: MarcoFalke: cr ACK 7c8c140 vasild: ACK 7c8c140 Tree-SHA512: b175f2ad42e9a2be1f769ac677b2872e73ae621731d27e9a24bedadc14d9a6682c7fd1946a0df436d37e7b0cc0d212c1eef69f0409fb975cf9c460cd45f6e4ac
Summary: This is a partial backport of [[bitcoin/bitcoin#19415 | core#19415]] bitcoin/bitcoin@c6b4bfb Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D11067
Make DNS lookup mockable/testable/fuzzable.
Add fuzzing harness for
Lookup(…)
/LookupHost(…)
/LookupNumeric(…)
/LookupSubNet(…)
.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 :)