Consume the defaults mount option instead of passing it as data - #5502
Open
wangyusheng1985 wants to merge 1 commit into
Open
wangyusheng1985 wants to merge 1 commit into
wangyusheng1985 wants to merge 1 commit into
Conversation
defaults is a recognized mount option with a zero flag. The parser treated a zero flag as unknown and appended it to filesystem data, so tmpfs mounts received defaults as a data option. Consume recognized zero-flag options and keep unknown options in the data string. Fixes opencontainers#5500 Signed-off-by: 玉升 <wyshdiy@163.com>
Contributor
|
@wangyusheng1985, please fix your |
kolyshkin
reviewed
Sep 30, 2026
Comment on lines
-1144
to
+1158
| // If the option does not exist in the mountFlags table, | ||
| // or the flag is not supported on the platform, | ||
| // then it is a data value for a specific fs type. | ||
| if f, exists := mountFlags[o]; exists && f.flag != 0 { | ||
| // Options absent from the mountFlags table are data for a specific fs type. | ||
| // A recognized option is consumed even when its flag is zero: "defaults" | ||
| // is a no-op and must not be forwarded as filesystem data (for example to tmpfs). | ||
| if f, exists := mountFlags[o]; exists { | ||
| // FIXME: The *atime flags are special (they are more of an enum | ||
| // with quite hairy semantics) and thus arguably setting some of | ||
| // them should clear unrelated flags. | ||
| if f.clear { | ||
| m.Flags &= ^f.flag | ||
| m.ClearedFlags |= f.flag | ||
| } else { | ||
| m.Flags |= f.flag | ||
| m.ClearedFlags &= ^f.flag | ||
| if f.flag != 0 { | ||
| if f.clear { | ||
| m.Flags &= ^f.flag | ||
| m.ClearedFlags |= f.flag | ||
| } else { | ||
| m.Flags |= f.flag | ||
| m.ClearedFlags &= ^f.flag | ||
| } |
Contributor
There was a problem hiding this comment.
This is too much of a fix. What's sufficient is:
@@ -1141,10 +1141,9 @@ func parseMountOptions(options []string) *configs.Mount {
initMaps()
for _, o := range options {
- // If the option does not exist in the mountFlags table,
- // or the flag is not supported on the platform,
- // then it is a data value for a specific fs type.
- if f, exists := mountFlags[o]; exists && f.flag != 0 {
+ // If the option does not exist in the mountFlags table,
+ // then it is a data value for a specific fs type.
+ if f, exists := mountFlags[o]; exists {
// FIXME: The *atime flags are special (they are more of an enum
// with quite hairy semantics) and thus arguably setting some of
// them should clear unrelated flags.and maybe add defaults to the table, for clarity:
"defaults": {false, 0}, // no-op, must not be passed as data
Contributor
There was a problem hiding this comment.
(The above also removes the obsoleted "flags is not supported on the platform" as modern x/sys/unix have all the flags defined).
kolyshkin
reviewed
Sep 30, 2026
| if strings.Contains(m.Data, "defaults") { | ||
| t.Errorf("defaults must not be passed as mount data, got %q", m.Data) | ||
| } | ||
| if !strings.Contains(m.Data, "size=1m") || !strings.Contains(m.Data, "mode=777") { |
Contributor
There was a problem hiding this comment.
I would rather check for a specific string here:
if m.Data != "size=1m,mode=777" {
kolyshkin
requested changes
Sep 30, 2026
Contributor
|
@wangyusheng1985 PTAL ^^^ |
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.
defaultsis a recognized mount option, but its flag value is zero. The parser only consumed options with a nonzero flag, sodefaultswas appended to the filesystem data string and forwarded to tmpfs.Recognized options are now consumed even when the flag is zero. Unknown options are still passed through as data, and nonzero flags keep their set and clear behavior.
Fixes #5500