core/mount: copy options before mutating in prepareIDMappedOverlay - #14204
Open
zanarellidev wants to merge 3 commits into
Open
zanarellidev wants to merge 3 commits into
zanarellidev wants to merge 3 commits into
Conversation
zanarellidev
force-pushed
the
bugsweep-mount-copy
branch
from
September 27, 2026 13:27
e4dbaf8 to
0c540cf
Compare
prepareIDMappedOverlay removed the lowerdir= entry and appended its replacement directly on the slice it received, mutating the caller's backing array. Mount.mount passes m.Options straight in without cloning, so any caller retaining a reference to the original Mount (e.g. through mount.All) observed its Options silently rewritten to the temporary idmapped lowerdir path, which is removed again once the idmap cleanup function runs. compactLowerdirOption in the same file already avoids this by copying before mutating; apply the same guard here. Signed-off-by: zanarelli <zanarelli.dev@gmail.com>
zanarellidev
force-pushed
the
bugsweep-mount-copy
branch
from
October 1, 2026 21:20
0c540cf to
1e62572
Compare
Signed-off-by: Raphael Zanarelli <zanarelli.dev@gmail.com>
This branch has not been deployed
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.

What this PR does / why we need it
prepareIDMappedOverlayremoved thelowerdir=entry and appended its replacement directly on the slice it received, mutating the caller's backing array.Mount.mountpassesm.Optionsstraight intoprepareIDMappedOverlaywithout cloning, so any caller retaining a reference to the originalMount(for example throughmount.All) observed itsOptionssilently rewritten to the temporary idmapped lowerdir path, which is subsequently removed once the idmap cleanup function runs.compactLowerdirOptionin the same file already avoids this by copying before mutating viacopyOptions(opts); this PR applies the same defensive copy guard here.Includes regression test
TestPrepareIDMappedOverlayAliasesCallerOptionsasserting that caller options are not mutated.