Repository navigation
addrman: detect on-disk corrupted nNew and nTried during unserialization - #22455
Conversation
Negative `nNew` or `nTried` are not possible during normal operation. So, if we read such values during unserialize, report addrman corruption. Fixes bitcoin#22450
|
I don't think this is the right approach, and doesn't fix the underlying bug in #22450. It's addressing the symptom, rather than the fact that addrman's internal datastructures can get into an inconsistent state. |
|
cr ACK 816f29e can't hurt to check for corrupt data during deserialize |
|
@jnewbery, considering #22450 (comment), do you think that this PR fixes the underlying bug in #22450? |
|
It looks like an improvement, but it doesn't fix the other issue(s) in #22450: #22450 (comment) |
No. I agree with Marco that this may be an improvement, but it's not fixing the bugs in #22450. |
|
Maybe remove the "Fixes #22450" from OP to avoid closing the issue. We can then use it as meta issue for addrman deserialize bugs. |
|
I'm quite anxious about the fact that we're now modifying addrman in a way that apparently introduces inconsistencies. Would it be possible to just revert that part, and rely on the higher level code to not insert invalid I2P address/ports? That means existing nodes running master won't be able to connect to the I2P addresses existing in their addrman, but I don't think that's much of an issue as I2P support isn't in any release yet? |
I think it is better to report different problems as separate bug entries, so that none gets forgotten and the conversations do not mix in one bug report. So, now we have:
|
lsilva01
left a comment
There was a problem hiding this comment.
Code Review ACK 816f29e. This change provides a more accurate description of the error.
If I'm understanding the problem so far, I agree with @sipa.
I don't see a need for this logic to keep existing I2P connections when the support for them hasn't even been released yet.
It seems simpler to me not to change the logic of a critical component like CAddrMan and only accept I2P connections with port = 0.
|
Upgrading my review ACK to tested ACK using commit fa740252d2dcc272204b745906785fe26e9a0b77 from #22493 and the following diff: diff --git a/src/addrman.cpp b/src/addrman.cpp
index 8192b4eba6..4e21062444 100644
--- a/src/addrman.cpp
+++ b/src/addrman.cpp
@@ -468,6 +468,5 @@ int CAddrMan::Check_()
std::unordered_map<int, int> mapNew;
- if (vRandom.size() != (size_t)(nTried + nNew))
- return -7;
+ assert(vRandom.size() == (size_t)(nTried + nNew));
for (const auto& entry : mapInfo) {crash-ce5f3356346c37f5a1eb17cf252105a87f6264ea.log Before (commit fa740252d2dcc272204b745906785fe26e9a0b77 + patch): After (commit fa740252d2dcc272204b745906785fe26e9a0b77 + patch + 816f29e cherry-picked): |
…d during unserialization 816f29e addrman: detect on-disk corrupted nNew and nTried during unserialization (Vasil Dimov) Pull request description: Negative `nNew` or `nTried` are not possible during normal operation. So, if we read such values during unserialize, report addrman corruption. Fixes bitcoin#22450 ACKs for top commit: MarcoFalke: cr ACK 816f29e jonatack: ACK 816f29e lsilva01: Code Review ACK bitcoin@816f29e. This change provides a more accurate description of the error. Tree-SHA512: 01bdd72d2d86a0ef770a319fee995fd1e147b24a8db84ddb8cd121688e7f94fed73fddc0084758e7183c4f8d08e971f0b1b224f5adb10928a5aa4dbbc8709d74
…d during unserialization 816f29e addrman: detect on-disk corrupted nNew and nTried during unserialization (Vasil Dimov) Pull request description: Negative `nNew` or `nTried` are not possible during normal operation. So, if we read such values during unserialize, report addrman corruption. Fixes bitcoin#22450 ACKs for top commit: MarcoFalke: cr ACK 816f29e jonatack: ACK 816f29e lsilva01: Code Review ACK bitcoin@816f29e. This change provides a more accurate description of the error. Tree-SHA512: 01bdd72d2d86a0ef770a319fee995fd1e147b24a8db84ddb8cd121688e7f94fed73fddc0084758e7183c4f8d08e971f0b1b224f5adb10928a5aa4dbbc8709d74
Negative
nNewornTriedare not possible during normal operation.So, if we read such values during unserialize, report addrman
corruption.
Fixes #22450