Repository navigation
Fix use-after-free and reading of long values in complex key ssd_cache dictionaries - #126553
Merged
Merged
Conversation
`SSDCacheFileBuffer::readKeys` read the blocks into a local `Memory<>` buffer, and for complex keys `SSDCacheBlock::readComplexKeys` returned `std::string_view`s pointing into that buffer. The buffer was freed on return, while the caller in `SSDCacheDictionaryStorage::insertCell` (the branch that starts reusing old partitions) used these keys for `index.find` and `eraseKeyFromIndex`. Now the caller owns the read buffer and keeps it alive while it uses the keys. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e test faster The size of the buffer to deserialize the values read from the file was taken from `read_buffer_blocks_size`, which is a number of blocks, not bytes, so values longer than a few bytes failed with `CANNOT_READ_ALL_DATA`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
Workflow [PR], commit [94b3cd4] Summary: ✅
AI ReviewSummaryThe PR fixes the lifetime of complex keys during Final VerdictStatus: ✅ Approve |
… MemorySanitizer The function was not covered by tests before, and MemorySanitizer does not know that the kernel fills the buffer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 20, 2026
clickhouse-gh Bot
added a commit
that referenced
this pull request
Oct 20, 2026
Backport #126553 to 26.10: Fix use-after-free and reading of long values in complex key `ssd_cache` dictionaries
clickhouse-gh Bot
added a commit
that referenced
this pull request
Oct 20, 2026
Backport #126553 to 26.8: Fix use-after-free and reading of long values in complex key `ssd_cache` dictionaries
clickhouse-gh Bot
added a commit
that referenced
this pull request
Oct 20, 2026
Backport #126553 to 26.9: Fix use-after-free and reading of long values in complex key `ssd_cache` dictionaries
clickhouse-gh Bot
added a commit
that referenced
this pull request
Oct 20, 2026
Backport #126553 to 26.7: Fix use-after-free and reading of long values in complex key `ssd_cache` dictionaries
alexey-milovidov
added a commit
that referenced
this pull request
Oct 20, 2026
Backport #126553 to 26.3: Fix use-after-free and reading of long values in complex key `ssd_cache` dictionaries
strtgbb
pushed a commit
to Altinity/ClickHouse
that referenced
this pull request
Oct 22, 2026
… long values in complex key `ssd_cache` dictionaries
opensource-fork-sync Bot
pushed a commit
to cla7aye15I4nd/opensource-ClickHouse__ClickHouse
that referenced
this pull request
Nov 13, 2026
…ed as paths, two readings of one input Blind reviews of the pull requests that introduced nine bugs fixed later (ported in ClickHouse#131294-ClickHouse#131302) showed these gaps: - Data the server wrote itself and reads back (parts, patch parts, packed-file indexes, `ssd_cache` files) was treated as trusted, so out-of-bounds reads on it were dismissed or rated as Nits (ClickHouse#126553, ClickHouse#116007, ClickHouse#86095). - No prompt for overflow of sizes computed from user-controlled counts (`ColumnString::replicate`, ClickHouse#61075). - No prompt for names read from data that become paths (packed archive index, ClickHouse#93414). - A security check that reads its input differently from the consumer (first vs last repeated key, Boolean spellings), which the real review of ClickHouse#106855 missed. Also ask for a separate pass over parsers and security decisions in large pull requests. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Two fixes in
SSDCacheDictionaryStorage:ssd_cachedictionary wraps around its partitions, it reads the old keys back from the file to remove them from the index.SSDCacheFileBuffer::readKeysreturned keys pointing into a local buffer that was freed on return, so the following lookups in the index read freed memory. Now the caller owns the buffer.read_buffer_blocks_size, which is a number of blocks, not bytes, so reading values longer than a few bytes from the file failed withCANNOT_READ_ALL_DATA.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix use-after-free in complex key
ssd_cachedictionaries when the cache file wraps around its partitions. FixCANNOT_READ_ALL_DATAwhen reading long values ofssd_cachedictionaries from the cache file.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/126553]
Version info
26.11.1.338-master(included in26.11and later)26.10.2.49,26.9.24.4,26.8.33.6,26.7.36.7,26.3.58.5