net processing: clamp PeerManager::Options user input#28149
Merged
glozow merged 3 commits intobitcoin:masterfrom Aug 9, 2023
Merged
net processing: clamp PeerManager::Options user input#28149glozow merged 3 commits intobitcoin:masterfrom
glozow merged 3 commits intobitcoin:masterfrom
Conversation
Contributor
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
glozow
reviewed
Jul 25, 2023
Member
glozow
left a comment
There was a problem hiding this comment.
utACK 128ad03792cd4aeeaf32807d07f01e3f85adaf28
Thanks for the followup
Also changes max_extra_txs into a uint32_t to avoid platform-specific behaviour
128ad03 to
547fa52
Compare
dergoegge
approved these changes
Aug 7, 2023
maflcko
reviewed
Aug 7, 2023
|
|
||
| if (auto value{argsman.GetIntArg("-maxorphantx")}) { | ||
| options.max_orphan_txs = uint32_t(std::max(int64_t{0}, *value)); | ||
| options.max_orphan_txs = uint32_t((std::clamp<int64_t>(*value, 0, std::numeric_limits<uint32_t>::max()))); |
Member
There was a problem hiding this comment.
unrelated: May be good to write a clang-tidy plugin to enforce the limits are compile-time constants and in range to avoid silent UB at runtime?
The in-range one can be submitted to upstream and the other check can be done in this repo.
maflcko
reviewed
Aug 7, 2023
|
|
||
| if (auto value{argsman.GetIntArg("-maxorphantx")}) { | ||
| options.max_orphan_txs = uint32_t(std::max(int64_t{0}, *value)); | ||
| options.max_orphan_txs = uint32_t((std::clamp<int64_t>(*value, 0, std::numeric_limits<uint32_t>::max()))); |
Member
There was a problem hiding this comment.
Suggested change
| options.max_orphan_txs = uint32_t((std::clamp<int64_t>(*value, 0, std::numeric_limits<uint32_t>::max()))); | |
| options.max_orphan_txs = uint32_t(std::clamp<int64_t>(*value, 0, std::numeric_limits<uint32_t>::max())); |
nit, if you re-touch?
glozow
reviewed
Aug 9, 2023
sidhujag
pushed a commit
to syscoin/syscoin
that referenced
this pull request
Aug 9, 2023
Fabcien
pushed a commit
to Bitcoin-ABC/bitcoin-abc
that referenced
this pull request
Jul 12, 2024
Summary: Document PeerManager::Options members. Clamp -maxorphantx to uint32_t bounds. Clamp -blockreconstructionextratxn to uint32_t bounds. Also changes max_extra_txs into a uint32_t to avoid platform-specific behaviour. -maxaddrtosend is hidden option used only for tests, so we only do minimal boundary checks. This is a backport of [[ bitcoin/bitcoin#28149 | core#28149 ]] Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D16456
roqqit
pushed a commit
to doged-io/doged
that referenced
this pull request
Aug 1, 2024
Summary: Document PeerManager::Options members. Clamp -maxorphantx to uint32_t bounds. Clamp -blockreconstructionextratxn to uint32_t bounds. Also changes max_extra_txs into a uint32_t to avoid platform-specific behaviour. -maxaddrtosend is hidden option used only for tests, so we only do minimal boundary checks. This is a backport of [[ bitcoin/bitcoin#28149 | core#28149 ]] Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D16456
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Avoid out-of-bounds user input for
PeerManager::Optionsby safely clamping-maxorphantxand-blockreconstructionextratxn, and avoid platform-specific behaviour by changingPeerManager::Options::max_extra_txsfromsize_tto auint32_t. Addresses #27499 (review).Also documents all
PeerManager::Optionsmembers, addressing #27499 (comment).