fix: reject large values over the 2 GiB on-disk length cap - #479
fix: reject large values over the 2 GiB on-disk length cap#479thweetkomputer wants to merge 2 commits into
Conversation
The very-large-value on-disk header encodes the length in 31 bits: bit 31 of word0 is the has-metadata flag and bits 30..0 hold actual_length (kLargeValueLengthMask = 2 GiB - 1). WriteLargeValue cast the caller's value size (size_t) straight to uint32 -- both the IoStringBuffer path (iosb->Size()) and the pinned path (pinned->second) -- with only a debug-only assert in EncodeLargeValueContent guarding the cap. A value in [2 GiB, 4 GiB) set the metadata flag and stored a wrong length; >= 4 GiB truncated outright. Either way the segment-id array no longer matches what DecodeLargeValueHeader derives, so every subsequent read returns Corrupted and a later delete dereferences a disengaged optional. EloqStore does not support values this large. Validate the length against kLargeValueLengthMask before the cast on both paths and return InvalidArgs when it is exceeded. The check runs before any memory is dereferenced. Adds a large_value_concurrency regression test: a pinned write with a declared length of 2 GiB (over a small real chunk) returns InvalidArgs instead of asserting/corrupting.
|
Warning Review limit reached
Next review available in: 59 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdded a size-cap validation in ChangesLarge-value size validation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
The very-large-value on-disk header encodes the length in 31 bits: bit 31 of
word0is the has-metadata flag and bits 30..0 holdactual_length(kLargeValueLengthMask = 0x7fffffff, i.e. 2 GiB − 1).WriteLargeValuecast the caller's value size (size_t) straight touint32:static_cast<uint32_t>(iosb->Size())static_cast<uint32_t>(size)with only a debug-only assert in
EncodeLargeValueContentguarding the cap. A value in [2 GiB, 4 GiB) sets the metadata flag and stores a wrong length; ≥ 4 GiB truncates outright. The segment-id array is sized from the true byte count, so the blob no longer matches whatDecodeLargeValueHeaderderives → every later read returnsCorrupted, and a subsequent delete dereferences a disengaged optional (release UB).Fix
EloqStore does not support values this large. Validate the length against
kLargeValueLengthMaskbefore the cast on both paths and returnInvalidArgswhen exceeded. The check runs before any memory is dereferenced.Test
large_value_concurrencycase: a pinned write with a declared length of 2 GiB (1 << 31) over a small real chunk returnsInvalidArgs. Before the fix this asserts inEncodeLargeValueContent(debug) / silently corrupts the blob (release).All tests passed (5 assertions).