Repository navigation
fix: stale metadata leaks in legacy xl.meta headers and pooled NSScanner responses - #233
Conversation
The legacy header decode paths zeroed EcN twice (z.EcN, z.EcN = 0, 0) instead of EcN and EcM, so EcM retained its previous value when the same structure was reused across decodes. Decoding an xl.meta written by an older release would then leak the erasure metadata (data/parity block counts) of a previously decoded object into it, potentially corrupting quorum and healing decisions. Also zero the fields on the V1 header path, which had no reset at all. Signed-off-by: Julien Laurenceau <[email protected]>
NSScanner responses stream either a dataUsageEntry update or the final dataUsageCache. The grid framework recycles stream responses into a pool without resetting them, and the handler set only one field per response - so a recycled response still carried the Final (or Update) payload of an earlier scan. A remote node reading such a response accepted the stale final cache, corrupting bucket usage data across scanner cycles. Honor Recycler types when pooling stream responses, implement it for nsScannerResp, and clear the unset field at the response construction sites for defense in depth. Signed-off-by: Julien Laurenceau <[email protected]>
The V1 header wire format has no Signature field, so decoding into a reused header leaked the previous object's signature. Reset it along with EcN/EcM so a decode fully replaces the header contents. Signed-off-by: Julien Laurenceau <[email protected]>
Vonng
left a comment
There was a problem hiding this comment.
Both fixes are useful. I reproduced the stale EcM and NSScanner response fields against current main (0d3ba5d), then verified that this PR fixes them. I also checked the legacy DecodeMsg path and reuse through loadIndexed. The storage and wire formats remain unchanged.
One change needs revision before merging: StreamTypeHandler.PutResponse now treats Recycler as a reset hook, then pools the same object again. That is not the interface's ownership contract. The inline comment includes a reproducer that passes on main and fails with this PR. The simplest option is to retain the explicit Update/Final clearing in NSScannerHandler and keep that fix local. If the general stream recycler change is retained, it needs the same constructor/recycler ownership handling as SingleHandler and its own regression coverage.
Two related review notes:
- The statement that no existing stream response implements Recycler is incorrect. consoleLogRPC and listenRPC use *grid.Bytes. I exercised that stream type with both response recycling and forwarded buffers under -race; those cases passed. This is a generic-handler contract regression, not an observed Console/event stream failure.
- TestNSScannerRespPooling can pass without reusing the dirty object because sync.Pool may discard entries. Please make the regression check deterministic or test the actual scanner response variants. The DecodeMsg change also deserves a direct test.
Local validation on Go 1.27.2, darwin/arm64, with this PR merged into current main:
- go build ./... and go vet ./... passed.
- make verifiers passed (lint, generated files, and compatibility/rebrand checks; optional typos check was skipped because the binary is absent).
- Relevant xl.meta, scanner, data-usage, healing, walk, and response serialization tests passed.
- The full internal/grid suite passed under -race.
- Supplemental legacy decoder, repeated scanner stream, and *grid.Bytes stream tests passed under -race.
- The new Recycler contract reproducer passed on main and failed with this PR on the second NewResponse call.
All three commits have matching DCO sign-offs. GitHub currently reports no check runs for this PR head; the results above are local verification. I recommend merging after the recycler change is corrected.
…er-fix Signed-off-by: Feng Ruohang <[email protected]>
Keep the legacy header resets and clear the unused NSScanner response field at each construction site. Remove the generic stream Recycler call: Recycler transfers resource ownership and cannot be treated as a reset hook followed by another insertion into the handler's pool. Exercise the actual NSScanner handler across repeated scans with dirty response allocations, so the regression test does not depend on sync.Pool reusing an object. Check both response variants after wire serialization. Cover legacy DecodeMsg and reused indexed metadata headers as well. Retain the original contributor's commits and DCO sign-offs. Signed-off-by: Feng Ruohang <[email protected]>
Addressed in maintainer follow-up 86c5a92. The generic stream Recycler change is removed; scanner resets stay local. Deterministic handler and legacy decoder tests pass, with negative controls against main. Proceeding with GitHub CI before merge.
Reused metadata headers and scanner responses can retain fields from an earlier object or scan. This PR clears the fields that are absent from the next decoded header or response.
EcNandEcM; previously they resetEcNtwice. The V1 decoder also clears its absentSignature,EcN, andEcMfields.NSScannerHandlerclearsFinalwhen sending an update and clearsUpdatewhen sending the final cache. The fix stays in the scanner handler; the grid framework'sRecyclerand pooling behavior are unchanged.Storage formats, RPC encodings, and dependency versions are unchanged by these fixes.
Validation on Go 1.27.2:
-race.-race.make verifiersandmake buildpass locally. The optionaltyposcheck is skipped because the binary is unavailable.Original fixes and initial tests by Julien Laurenceau. The maintainer follow-up keeps the scanner reset local and strengthens regression coverage. All original commits and DCO sign-offs are preserved.