Repository navigation
[release/2.3] Fix input mutation in mount option helpers - #14192
Merged
Merged
Conversation
The custom copyMounts helper is equivalent to stdlib's slices.Clone. Signed-off-by: Paweł Gronowski <[email protected]> (cherry picked from commit 35e919f) Signed-off-by: Paweł Gronowski <[email protected]>
readonlyMounts was modifying the caller's mounts slice in place by writing directly to mounts[i].Options. This caused WithReadonlyTempMount to mutate the caller's mount data. Clone the mounts slice before modification so the original is preserved. Signed-off-by: Paweł Gronowski <[email protected]> (cherry picked from commit 70cfd77) Signed-off-by: Paweł Gronowski <[email protected]>
…IDMapOption slices.Clone only shallow-copies the []Mount slice, so cloned entries still share their Options backing arrays with the originals. Clone each mount's Options slice before modifying it. Also fix the tests: the previous no-mutation assertions used slices.Clone for the "original" snapshot, which has the same shallow copy problem. Signed-off-by: Paweł Gronowski <[email protected]> (cherry picked from commit b73b82f) Signed-off-by: Paweł Gronowski <[email protected]>
RemoveVolatileOption and RemoveIDMapOption both need to drop selected mount options without mutating caller input. Extract the lazy copy and filtering loop into a shared helper so both paths keep the same behavior and future fixes apply consistently. Signed-off-by: Paweł Gronowski <[email protected]> (cherry picked from commit 79455dd) Signed-off-by: Paweł Gronowski <[email protected]>
The filtered mount helpers documented copy semantics, but no-op inputs could return the original mount and option slices. That made the caller observe different aliasing behavior depending on whether an option was removed. Always build a copied result for filtered mount options and cover the no-alias contract in the mount helper tests. Signed-off-by: Paweł Gronowski <[email protected]> (cherry picked from commit 674c3a1) Signed-off-by: Paweł Gronowski <[email protected]>
Filtered mount option helpers only need to allocate when they remove an option. No-op inputs can safely return the original slices because the observable contract is that inputs are not mutated. Document that behavior and keep the no-alias assertions scoped to cases where the returned mounts differ from the input. Signed-off-by: Paweł Gronowski <[email protected]> (cherry picked from commit 165abaf) Signed-off-by: Paweł Gronowski <[email protected]>
estesp
approved these changes
Sep 23, 2026
mxpv
approved these changes
Sep 24, 2026
1 task
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.
readonlyMounts,RemoveVolatileOption,RemoveIDMapOptionhelpers operated on their input slices directly, unexpectedly mutating the caller's data.The existing no-mutation test assertions also suffered from the same shallow-copy problem, so they could not detect the corruption.