Repository navigation
Reject serialized query plan steps without their inputs - #131736
Conversation
The number of children of a step in a serialized query plan comes from the stream, but the step deserializers read their input headers (`ctx.input_headers.front()` and similar) without checking it, so a plan with a step lacking its children made the server read out of bounds. Make `QueryPlanStepDeserialization::input_headers` a checked view that throws `INCORRECT_DATA` for a missing input, which covers all steps at once, and reject a `UnionStep` without inputs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [a932375] Summary: ✅
AI ReviewSummaryThe PR rejects serialized query plan steps with missing inputs, extra children, or children without output streams using Missing context / blind spots
Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units57 translation units recompiled, 438 s compile time in total, 57 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.11 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
`DeserializedInputHeaders` stores a reference, so the temporary `SharedHeaders{header}`
used to initialize the deserialization context in the gtest was destroyed right after the
initialization. This made `LimitByStepSerialization` fail in unit tests, with
`stack-use-after-scope` under ASan. Use a named vector, and delete the rvalue constructor
of `DeserializedInputHeaders` so other callers cannot get the same dangling reference.
Address review feedback.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A step may take fewer inputs than its node has children, e.g. `Extremes` with two children stores one input header, while optimizations iterate over the children and read the input header of each of them out of bounds. Check that the number of input headers of each deserialized step equals the number of its children. Also replace the `chassert` in `BlocksMarshallingStep::deserialize` with an `INCORRECT_DATA` exception: a childless step aborted debug and sanitizer servers. Extend the test with both cases. Address review feedback. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A sink such as `GatherSend` has no output header, so calling `getOutputHeader` on it while collecting the input headers of its parent raised a `LOGICAL_ERROR` exception. Throw `INCORRECT_DATA` instead, and extend the test with a sink beneath another step. Also mark the accessors of `DeserializedInputHeaders` `[[nodiscard]]` as required by `modernize-use-nodiscard`. Address review: #131736 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolved the test conflict by keeping the remote's `buildNode` helper and the new cases, and adding the `Extremes` over `GatherSend` case on top of it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve conflicts of the cherry-pick of #131736 onto 26.3: - `Serialization.cpp`: keep the input-count and sink-child checks; 26.3 has no `MAX_QUERY_PLAN_STEP_CHILDREN`, step versions, or the relaxed header check. - `UnionStep.cpp`: keep the empty-input check; 26.3's `UnionStep::deserialize` reads no flags. - `BlocksMarshallingStep.cpp`: keep the input-count check; 26.3 has no `contextAllowsBlocksMarshalling` here. - Drop `gtest_limit_by_step_serialization.cpp`, which does not exist on 26.3. - Adapt the test `05775_query_plan_step_missing_inputs`: 26.3 does not register `ReadNothing`, `GatherSend`, or `BlocksMarshalling` steps, so use `ReadFromTable` children and drop the cases with the missing steps. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cherry pick #131736 to 26.3: Reject serialized query plan steps without their inputs
Cherry pick #131736 to 26.8: Reject serialized query plan steps without their inputs
Cherry pick #131736 to 26.9: Reject serialized query plan steps without their inputs
Cherry pick #131736 to 26.10: Reject serialized query plan steps without their inputs
Backport #131736 to 26.10: Reject serialized query plan steps without their inputs
Backport #131736 to 26.9: Reject serialized query plan steps without their inputs
Backport #131736 to 26.8: Reject serialized query plan steps without their inputs
Backport #131736 to 26.3: Reject serialized query plan steps without their inputs
The number of children of a step in a serialized query plan comes from the stream, but the step deserializers read their input headers (
ctx.input_headers.front()and similar) without checking it, so a plan with a step lacking its children made the server read out of bounds. MakeQueryPlanStepDeserialization::input_headersa checked view that throwsINCORRECT_DATAfor a missing input, which covers all steps at once, and reject aUnionStepwithout inputs. Also check that every deserialized step has exactly as many inputs as its node has children (a step with extra children made plan optimizations read out of bounds), and replace thechassertinBlocksMarshallingStep::deserializewith an exception.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix out-of-bounds reads when deserializing a query plan with a step lacking some of its inputs or having extra children. Now such a plan is rejected with
INCORRECT_DATA.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/131736]
Version info
26.11.1.2542-master(included in26.11and later)26.10.5.57,26.9.31.20,26.8.39.17,26.3.66.13