quic: reject zero addressLRUSize - #65827
Open
christianaurichzm wants to merge 1 commit into
Open
Conversation
SocketAddressLRU::Upsert always inserts an entry before evicting down
to max_size_. With max_size_ == 0, it evicts the entry it just
inserted and then accesses the now-missing key via
map_[address]->second. operator[] recreates the key with a
default-constructed std::list iterator, which is then dereferenced.
This is undefined behavior, observed as a SIGSEGV in Endpoint::Receive
on the first UDP packet accepted by a QuicEndpoint constructed with
{ addressLRUSize: 0 }.
SocketAddressLRU has no useful semantics for a zero-capacity cache,
and Upsert's callers rely on it returning a valid pointer. Reject 0
(and 0n) at the options-parsing boundary instead of changing Upsert's
contract.
Signed-off-by: Christian Aurich <[email protected]>
Collaborator
|
Review requested:
|
jasnell
approved these changes
Sep 5, 2026
bjohansebas
approved these changes
Sep 5, 2026
Collaborator
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #65827 +/- ##
==========================================
- Coverage 90.18% 90.17% -0.01%
==========================================
Files 770 770
Lines 264410 264410
Branches 50230 50236 +6
==========================================
- Hits 238449 238439 -10
- Misses 16966 16975 +9
- Partials 8995 8996 +1 🚀 New features to boost your workflow:
|
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
new QuicEndpoint({ addressLRUSize: 0 })crashes with a SIGSEGV on the first UDP packet received by the endpoint.SocketAddressLRU<T>::Upsertinserts an entry and then evicts entries until the cache is withinmax_size_. Withmax_size_ == 0, the newly inserted entry is immediately removed. The finalmap_[address]->secondthen inserts a default-constructedstd::listiterator and dereferences it, resulting in undefined behavior.address_lru_sizecurrently accepts any non-negativeuint64_t, so both0and0ncan reachSocketAddressLRU. This changes the endpoint option validation to reject zero instead.I reproduced the crash with an
--experimental-quicbuild usinglisten()+connect(). The core dump goes throughEndpoint::ReceiveandEndpoint::UDP::Impl::OnReceive. With this change,addressLRUSize: 0throwsERR_INVALID_ARG_VALUE, whileaddressLRUSize: 1still completes the handshake.Added
0and0nto the existing invalidaddressLRUSizetest cases. Alltest/parallel/test-quic-*.mjstests pass.