bitcoin/src
MarcoFalke f1064c1b0d
Merge #17989: tests: Add fuzzing harness for ProcessMessage(...). Enables high-level fuzzing of the P2P layer.
9220a0fdd0 tests: Add one specialized ProcessMessage(...) fuzzing binary per message type for optimal results when using coverage-guided fuzzing (practicalswift)
fd1dae10b4 tests: Add fuzzing harness for ProcessMessage(...) (practicalswift)

Pull request description:

  Add fuzzing harness for `ProcessMessage(...)`. Enables high-level fuzzing of the P2P layer.

  All code paths reachable from this fuzzer can be assumed to be reachable for an untrusted peer.

  Seeded from thin air (an empty corpus) this fuzzer reaches roughly 20 000 lines of code.

  To test this PR:

  ```
  $ make distclean
  $ ./autogen.sh
  $ CC=clang CXX=clang++ ./configure --enable-fuzz \
        --with-sanitizers=address,fuzzer,undefined
  $ make
  $ src/test/fuzz/process_message
  …
  ```

  Worth noting about this fuzzing harness:
  * To achieve a reasonable number of executions per seconds the state of the fuzzer is unfortunately not entirely reset between `test_one_input` calls. The set-up (`FuzzingSetup` ctor) and tear-down (`~FuzzingSetup`) work is simply too costly to be run on every iteration. There is a trade-off to handle here between a.) achieving high executions/second and b.) giving the fuzzer a totally blank slate for each call. Please let me know if you have any suggestion on how to improve this situation while maintaining >1000 executions/second.
  * To achieve optimal results when using coverage-guided fuzzing I've chosen to create one specialised fuzzing binary per message type (`process_message_addr`, `process_message_block`, `process_message_blocktxn `, etc.) and one general fuzzing binary (`process_message`) which handles all messages types. The latter general fuzzer can be seeded with inputs generated by the former specialised fuzzers.

  Happy fuzzing friends!

ACKs for top commit:
  MarcoFalke:
    ACK 9220a0fdd0 🏊

Tree-SHA512: c314ef12b0db17b53cbf3abfb9ecc10ce420fb45b17c1db0b34cabe7c30e453947b3ae462020b0c9f30e2c67a7ef1df68826238687dc2479cd816f0addb530e5
2020-03-11 08:51:24 -04:00
..
bench Merge #16117: util: Replace boost sleep with std sleep 2020-03-06 15:41:00 +08:00
compat scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
config
consensus Templatize ValidationState instead of subclassing 2020-02-27 17:59:21 -08:00
crc32c Import crc32c using subtree merge as as 'src/crc32c' 2020-01-28 17:00:01 +01:00
crypto Merge #17691: doc: Add missed copyright headers 2020-01-16 15:58:35 -05:00
index make BlockUntilSyncedToCurrentChain() const 2020-03-02 17:26:30 +09:00
interfaces Replace GetSigningProvider with GetSolvingProvider 2020-03-09 11:16:20 -04:00
leveldb Update to leveldb upstream using subtree merge 2020-01-28 16:59:07 +01:00
logging doc: Correct spelling errors in comments 2020-03-02 23:07:21 -08:00
node doc: Correct spelling errors in comments 2020-03-02 23:07:21 -08:00
policy scripted-diff: Bump copyright of files changed in 2020 2020-01-15 02:18:00 +07:00
primitives scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
qt Move direct calls to MessageSign into new SignMessage functions in CWallet and ScriptPubKeyMan 2020-03-09 11:16:20 -04:00
rpc Refactor rawtransaction's SignTransaction into generic SignTransaction function 2020-03-08 12:26:27 -04:00
script Clear any input_errors for an input after it is signed 2020-03-09 11:16:20 -04:00
secp256k1 Update the secp256k1 subtree to the latest upstream version 2019-03-31 11:41:05 -07:00
support scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
test Merge #17989: tests: Add fuzzing harness for ProcessMessage(...). Enables high-level fuzzing of the P2P layer. 2020-03-11 08:51:24 -04:00
univalue Update univalue subtree 2020-02-09 07:44:29 -08:00
util Move direct calls to MessageSign into new SignMessage functions in CWallet and ScriptPubKeyMan 2020-03-09 11:16:20 -04:00
wallet Merge #18115: wallet: Pass in transactions and messages for signing instead of exporting the private keys 2020-03-10 09:02:12 +13:00
zmq rpc: Auto-format RPCResult 2020-02-25 22:35:58 +07:00
.clang-format util: Add AllowShortCaseLabelsOnASingleLine option 2019-10-14 13:24:54 +03:00
addrdb.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
addrdb.h Convert addrdb/addrman to new serialization 2020-01-02 11:05:36 -08:00
addrman.cpp logging: asmap logging and #include fixups 2020-03-04 14:24:19 +01:00
addrman.h logging: asmap logging and #include fixups 2020-03-04 14:24:19 +01:00
amount.h Update copyright headers to 2018 2018-12-29 10:15:01 +01:00
arith_uint256.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
arith_uint256.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
attributes.h
banman.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
banman.h scripted-diff: Bump copyright of files changed in 2020 2020-01-15 02:18:00 +07:00
base58.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
base58.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
bech32.cpp Add some general std::vector utility functions 2019-10-16 08:56:57 -07:00
bech32.h Assert that the HRP is lowercase in Bech32::Encode 2019-09-05 13:25:11 +12:00
bitcoin-cli-res.rc
bitcoin-cli.cpp scripted-diff: Replace MilliSleep with UninterruptibleSleep 2020-02-21 10:06:21 -08:00
bitcoin-tx-res.rc
bitcoin-tx.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
bitcoin-wallet-res.rc [tools] Add wallet inspection and modification tool 2019-01-30 16:26:52 -05:00
bitcoin-wallet.cpp bitcoin-wallet: Use PACKAGE_NAME in usage help 2020-01-14 18:19:00 +00:00
bitcoind-res.rc
bitcoind.cpp scripted-diff: Replace MilliSleep with UninterruptibleSleep 2020-02-21 10:06:21 -08:00
blockencodings.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
blockencodings.h Convert blockencodings.h to new serialization framework 2020-02-25 14:10:44 -08:00
blockfilter.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
blockfilter.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
bloom.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
bloom.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
chain.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
chain.h Get rid of VARINT default argument 2020-02-10 12:00:10 -08:00
chainparams.cpp [test] add chainparams property to indicate chain allows time mocking 2020-02-13 08:59:51 -08:00
chainparams.h [test] add chainparams property to indicate chain allows time mocking 2020-02-13 08:59:51 -08:00
chainparamsbase.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
chainparamsbase.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
chainparamsseeds.h contrib: Remove invalid nodes from seeds list 2019-10-02 08:51:12 +02:00
checkqueue.h refactor: Remove redundant conditional 2020-01-21 14:07:42 +00:00
clientversion.cpp
clientversion.h
coins.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
coins.h Convert compression.h to new serialization framework 2020-01-21 20:29:11 -08:00
compat.h windows: Set _WIN32_WINNT to 0x0601 (Windows 7) 2019-01-23 16:28:27 +08:00
compressor.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
compressor.h Merge #17917: tests: Add amount compression/decompression fuzzing to existing fuzzing harness 2020-03-05 15:25:36 -05:00
core_io.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
core_memusage.h
core_read.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
core_write.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
cuckoocache.h Use correct C++11 header for std::swap() 2019-11-29 21:23:25 +02:00
dbwrapper.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
dbwrapper.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
dummywallet.cpp scripted-diff: Bump copyright of files changed in 2020 2020-01-15 02:18:00 +07:00
flatfile.cpp Style cleanup. 2019-02-22 17:38:45 -08:00
flatfile.h Get rid of VARINT default argument 2020-02-10 12:00:10 -08:00
fs.cpp scripted-diff: Add missed copyright headers 2020-01-04 20:18:28 +02:00
fs.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
hash.cpp
hash.h Squashed 'src/secp256k1/' changes from 0b70241850..b19c000063 2019-03-31 11:41:05 -07:00
httprpc.cpp scripted-diff: Replace MilliSleep with UninterruptibleSleep 2020-02-21 10:06:21 -08:00
httprpc.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
httpserver.cpp httpserver: use own HTTP status codes 2020-02-18 08:29:35 +01:00
httpserver.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
indirectmap.h Add missing includes 2020-01-31 12:36:13 +00:00
init.cpp scheduler: don't rely on boost interrupt on shutdown 2020-03-06 23:13:31 +10:00
init.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
key.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
key.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
key_io.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
key_io.h
limitedmap.h
logging.cpp scripted-diff: Bump copyright of files changed in 2020 2020-01-15 02:18:00 +07:00
logging.h scripted-diff: Bump copyright of files changed in 2020 2020-01-15 02:18:00 +07:00
Makefile.am Move FillPSBT to be a member of CWallet 2020-03-09 11:16:17 -04:00
Makefile.bench.include [test] move wallet helper functions into test library 2019-11-25 16:40:09 +01:00
Makefile.crc32c.include build: CRC32C build system integration 2020-01-28 17:01:48 +01:00
Makefile.leveldb.include build: CRC32C build system integration 2020-01-28 17:01:48 +01:00
Makefile.qt.include Merge #17513: refactor, qt: Nuke some circular dependencies 2019-11-21 19:38:39 +01:00
Makefile.qt_locale.include Restore English translation option 2020-01-06 22:58:47 -05:00
Makefile.qttest.include build: Create test utility library from src/test/util/ 2019-11-21 21:13:08 +01:00
Makefile.test.include Merge #17989: tests: Add fuzzing harness for ProcessMessage(...). Enables high-level fuzzing of the P2P layer. 2020-03-11 08:51:24 -04:00
Makefile.test_util.include [test] move wallet helper functions into test library 2019-11-25 16:40:09 +01:00
memusage.h Add missing includes 2020-01-31 12:36:13 +00:00
merkleblock.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
merkleblock.h
miner.cpp Refactor FormatStateMessage into ValidationState 2020-02-27 17:59:07 -08:00
miner.h rpc: Remove mempool global from miner 2019-12-23 06:12:10 +07:00
net.cpp refactor: Convert ping wait time from double to int64_t 2020-03-04 13:45:29 -05:00
net.h refactor: Convert ping wait time from double to int64_t 2020-03-04 13:45:29 -05:00
net_permissions.cpp net: Avoid using C-style NUL-terminated strings as arguments in the netbase interface 2020-01-08 12:35:59 +00:00
net_permissions.h net: Remove forcerelay of rejected txs 2020-02-11 07:44:12 -08:00
net_processing.cpp tests: Add fuzzing harness for ProcessMessage(...) 2020-03-11 06:57:55 +00:00
net_processing.h Use rolling bloom filter of recent block tx's for AlreadyHave() check 2020-01-29 09:37:21 -05:00
net_types.h refactor: Remove addrdb.h dependency from node.h 2019-10-29 11:30:12 +02:00
netaddress.cpp net: extract conditional to bool CNetAddr::IsHeNet 2020-03-04 14:31:31 +01:00
netaddress.h net: extract conditional to bool CNetAddr::IsHeNet 2020-03-04 14:31:31 +01:00
netbase.cpp Merge #17754: net: Don't allow resolving of std::string with embedded NUL characters. Add tests. 2020-01-22 20:20:45 +01:00
netbase.h net: Avoid using C-style NUL-terminated strings as arguments in the netbase interface 2020-01-08 12:35:59 +00:00
netmessagemaker.h
noui.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
noui.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
optional.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
outputtype.cpp Revert "Store p2sh scripts in AddAndGetDestinationForScript" 2020-02-12 11:48:30 -05:00
outputtype.h List output types in an array in order to be iterated over 2020-01-23 16:35:06 -05:00
pow.cpp
pow.h
prevector.h Make VectorFormatter support stateful formatters 2020-02-15 19:49:24 -08:00
protocol.cpp p2p: Remove BIP61 reject messages 2019-10-02 10:39:14 -04:00
protocol.h Merge #17474: Bugfix: GUI: Recognise NETWORK_LIMITED in formatServicesStr 2019-12-11 17:00:27 -05:00
psbt.cpp Merge #17156: psbt: check that various indexes and amounts are within bounds 2020-01-29 19:39:50 +08:00
psbt.h Fix doxygen errors 2020-01-16 18:25:11 -08:00
pubkey.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
pubkey.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
random.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
random.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
randomenv.cpp Drop unused mach time headers 2020-02-28 14:56:49 -08:00
randomenv.h [MOVEONLY] Move perfmon data gathering to new randomenv module 2019-11-12 14:50:44 -08:00
rest.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
reverse_iterator.h
scheduler.cpp scheduler: switch from boost to std 2020-03-06 23:14:08 +10:00
scheduler.h scheduler: switch from boost to std 2020-03-06 23:14:08 +10:00
serialize.h Merge #18112: Serialization improvements step 5 (blockencodings) 2020-03-05 19:56:26 +01:00
shutdown.cpp
shutdown.h
span.h
streams.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
sync.cpp sync.h: add REVERSE_LOCK 2020-03-06 23:13:31 +10:00
sync.h sync.h: add REVERSE_LOCK 2020-03-06 23:13:31 +10:00
threadinterrupt.cpp
threadinterrupt.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
threadsafety.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
timedata.cpp scripted-diff: Bump copyright of files changed in 2020 2020-01-15 02:18:00 +07:00
timedata.h
tinyformat.h util: Update tinyformat to upstream 2019-12-06 10:02:08 +01:00
torcontrol.cpp net: Avoid using C-style NUL-terminated strings as arguments in the netbase interface 2020-01-08 12:35:59 +00:00
torcontrol.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
txdb.cpp Get rid of VARINT default argument 2020-02-10 12:00:10 -08:00
txdb.h scripted-diff: Bump copyright of files changed in 2020 2020-01-15 02:18:00 +07:00
txmempool.cpp Make UpdateTransactionsFromBlock use Epochs 2020-01-14 19:30:13 -08:00
txmempool.h doc: Correct spelling errors in comments 2020-03-02 23:07:21 -08:00
ui_interface.cpp scripted-diff: Bump copyright of files changed in 2020 2020-01-15 02:18:00 +07:00
ui_interface.h scripted-diff: Bump copyright of files changed in 2020 2020-01-15 02:18:00 +07:00
uint256.cpp refactor: define a UINT256_ONE global constant 2020-01-23 16:35:08 -05:00
uint256.h refactor: define a UINT256_ONE global constant 2020-01-23 16:35:08 -05:00
undo.h Convert undo.h to new serialization framework 2020-02-06 19:08:11 -08:00
validation.cpp Refactor FormatStateMessage into ValidationState 2020-02-27 17:59:07 -08:00
validation.h scripted-diff: Bump copyright of files changed in 2020 2020-01-15 02:18:00 +07:00
validationinterface.cpp Refactor FormatStateMessage into ValidationState 2020-02-27 17:59:07 -08:00
validationinterface.h scripted-diff: Bump copyright of files changed in 2020 2020-01-15 02:18:00 +07:00
version.h
versionbits.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
versionbits.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
versionbitsinfo.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
versionbitsinfo.h
walletinitinterface.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
warnings.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
warnings.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00