Repository navigation
fuzz: add ipc round-trip fuzz target - #35118
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35118. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsNo conflicts as of last run. |
cbc7f45 to
32ad9f4
Compare
c5a1192 to
aa53fdf
Compare
|
While testing this PR with The cause is in the top-level CMakeLists.txt:234: when BUILD_FOR_FUZZING=ON, ENABLE_IPC is unconditionally forced OFF, which makes the if(ENABLE_IPC) guard in src/test/fuzz/CMakeLists.txt skip ipc.cpp. So the target added by this PR can't actually be exercised through the standard fuzz preset. I believe the fix is to drop set(ENABLE_IPC OFF) from CMakeLists.txt:234. |
|
Three of the four methods (passOutPoint, passVectorUint8, passScript) are identity round-trips. add(a, b) is stronger because the server has to actually decode a and b to compute the sum and the client then checks against the original inputs. With identity, the server never has to understand the value it received, so a broken deserialization can be re-serialized as the same garbage and still compare equal. A small deterministic transform on the server side would close that gap, e.g.: std::vector<uint8_t> passVectorUint8(std::vector<uint8_t> v) {
std::reverse(v.begin(), v.end());
return v;
}
CScript passScript(CScript s) { s << OP_NOP; return s; }
COutPoint passOutPoint(COutPoint o) { return COutPoint{o.hash, o.n ^ 0xFFFFFFFFu}; }and then comparing against the reproduced transform on the client just like add(a, b). This matches the "transform, reverse, or shift" idea from #23015. |
a726d49 to
fc26ea1
Compare
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
a04c31a to
580adc5
Compare
|
Thanks for the review @ViniciusCestarii
The fix is indeed to remove set(ENABLE_IPC OFF) from the BUILD_FOR_FUZZING block, that line was added in af4156a to work around missing capnp in fuzzing builds, but since
Good point. Updated the three identity methods to use deterministic transforms instead:
The client-side asserts now reproduce the same transform and compare against that |
a46f70e to
c1fcd53
Compare
c1fcd53 to
3d042d7
Compare
|
Updated the branch to keep the IPC fuzz target opt-in instead of enabling IPC for all fuzz builds. The issue was that The current approach preserves the existing default behavior:
I also removed the unrelated fuzz target linking cleanup from this PR. The remaining diff is focused on making IPC fuzzing explicitly buildable and adding the initial |
3d042d7 to
f534980
Compare
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
marcofleon
left a comment
There was a problem hiding this comment.
Nice, good to see an IPC fuzz test. Here's the coverage after fuzzing for a while.
Left a question.
| }, | ||
| [&] { | ||
| std::vector<uint8_t> value = ConsumeRandomLengthByteVector<uint8_t>(fuzzed_data_provider, 512); | ||
| if (value.empty()) value.push_back(0); |
There was a problem hiding this comment.
I'm not quite seeing why we need this line. Is an empty vector not a case we should be covering?
There was a problem hiding this comment.
This is a workaround to empty input, because of a libmultiprocess sanitizer issue
There was a problem hiding this comment.
Removing this causes the UBSan job to find that the empty std::vector<uint8_t> case currently trips an invalid-null-argument in libmultiprocess' byte-span serializer.
For an empty vector, data() may be null, and libmultiprocess currently calls memcpy(result.begin(), data.data(), data.size()). Even with size 0, UBSan flags the null pointer argument.
So I restored the guard, but added a comment explaining why it is there. This is not because the IPC round-trip cannot logically handle empty data; it is to avoid a known sanitizer issue in libmultiprocess, which I do not think this PR should change.
There was a problem hiding this comment.
So it is real UB? This isn't a blocker, more just trying to understand. Would it make sense in a followup to address it (in type-data.h I'm assuming) and then remove this line at some point?
There was a problem hiding this comment.
IIUC this is a GCC bug, see #32016 (comment)
Maybe fixed in GCC-16?
Thanks for giving this a look @marcofleon. Will update the PR description with this coverage report |
sedited
left a comment
There was a problem hiding this comment.
ACK cf2c65e0cc3e75d7ba70e0b78a1515a48f39df76
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
Add an ipc fuzz target behind ENABLE_IPC. Set up an in-process two-way pipe and use a small reflected interface to exercise libmultiprocess client/server calls. Round-trip COutPoint, CScript, std::vector<uint8_t>, UniValue, and transactions. Add bitcoin_ipc_fuzz static library and link it to the fuzz target via a new src/ipc/test/fuzz/CMakeLists.txt.
marcofleon
left a comment
There was a problem hiding this comment.
ACK 037ad77
Non-blocking suggestion for a potential followup.
|
Opened #35916 to improve the fuzz coverage for this target |
As discussed in #23015, this PR adds an IPC fuzz target to exercise the Cap'n Proto/libmultiprocess serialization bridge using an in-process two-way pipe and a reflected test interface.
It covers round-trip serialization for
COutPoint,CScript,std::vector<uint8_t>,UniValue, and transactions, and exercises libmultiprocess proxy/server interaction. The target guarantees at least one IPC operation per input and is included by default when IPC is enabled in fuzz buildsCoverage report provided by marcofleon