Skip to content

fsmount: Fix selinux mount parameter parsing - #13754

Merged
mxpv merged 1 commit into
containerd:mainfrom
dgdegraaf:fix-fsmount-selinux
Jul 20, 2026
Merged

mxpv merged 1 commit into
containerd:mainfrom
dgdegraaf:fix-fsmount-selinux

Conversation

@dgdegraaf

@dgdegraaf dgdegraaf commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Because selinux contexts can contain commas, context strings may be quoted in the single-syscall mount API. This quoting is not permitted when using the fsconfig API, so strip the quotes when preparing the system call arguments.

Fix SELinux context mount parameter parsing when using the fsconfig API

Copilot AI review requested due to automatic review settings July 9, 2026 17:50
@github-project-automation github-project-automation Bot moved this to Needs Triage in Pull Request Review Jul 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates internal/fsmount to handle SELinux mount options that may be quoted when coming from the single-syscall mount API, ensuring values passed to the fsconfig() API are unquoted as required.

Changes:

  • Detect *context= mount options and strip surrounding double quotes from their values before calling unix.FsconfigSetString.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/fsmount/fsmount_linux.go Resolved
Copilot AI review requested due to automatic review settings July 9, 2026 17:53
@dgdegraaf
dgdegraaf force-pushed the fix-fsmount-selinux branch from dd83a29 to ab5eae0 Compare July 9, 2026 17:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

strings.HasSuffix(val, "\"") {
val, _ = strings.CutPrefix(val, "\"")
val, _ = strings.CutSuffix(val, "\"")
}

@mxpv mxpv Jul 14, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go has Unquote and UnquoteChar or strings.Trim.
Also can you introduce a small unit test for this.

Copilot AI review requested due to automatic review settings July 14, 2026 20:12
@dgdegraaf
dgdegraaf force-pushed the fix-fsmount-selinux branch from ab5eae0 to 76afad7 Compare July 14, 2026 20:12
@kubernetes-prow kubernetes-prow Bot added size/M and removed size/XS labels Jul 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread internal/fsmount/fsmount_linux.go Resolved
Comment thread internal/fsmount/fsmount_linux.go Resolved
Comment thread internal/fsmount/fsmount_linux_test.go Resolved
Copilot AI review requested due to automatic review settings July 16, 2026 13:30
@dgdegraaf
dgdegraaf force-pushed the fix-fsmount-selinux branch from 76afad7 to 2dce7ea Compare July 16, 2026 13:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread internal/fsmount/fsmount_linux_test.go Outdated
Comment on lines +52 to +68
mount := mount.Mount{
Type: "tmpfs",
Options: []string{"mode=0700", ml},
}

err = mount.Mount(tmp)
t.Cleanup(func() {
testutil.Unmount(t, tmp)
})
require.NoError(t, err)

newlabel, err := selinux.FileLabel(tmp)
require.NoError(t, err)
assert.Equal(t, label, newlabel)

err = fsmount.Fsmount(mount, tmp)
require.NoError(t, err)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good suggestion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, although there are a number of existing in-tree instances of mount used as the variable name for a mount.Mount object. Should I adjust it anyway?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually use mnt (or if it's really nearby m) to avoid shadowing. Not a hard blocker for me, unless you need to update (might prevent some code-churn).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, might as well adjust this location. I don't think we need to remain consistent with shadowing done elsewhere. m or mnt would be fine.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, might as well adjust this location. I don't think we need to remain consistent with shadowing done elsewhere. m or mnt would be fine.

@github-project-automation github-project-automation Bot moved this from Needs Triage to Review In Progress in Pull Request Review Jul 16, 2026
Comment thread internal/fsmount/fsmount_linux_test.go Outdated
Comment on lines +52 to +57
mount := mount.Mount{
Type: "tmpfs",
Options: []string{"mode=0700", ml},
}

err = mount.Mount(tmp)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a quick peek; looks like m is most popular 😅

git grep ':= mount.Mount{'
contrib/fuzz/diff_fuzz_test.go:                 m := mount.Mount{}
contrib/fuzz/diff_fuzz_test.go:                 m := mount.Mount{}
contrib/fuzz/diff_fuzz_test.go:                 m := mount.Mount{}
core/mount/manager/manager.go:  m := mount.Mount{
core/mount/manager/manager_linux_test.go:       m := mount.Mount{
core/mount/manager/mkdir_linux_test.go: m := mount.Mount{
core/unpack/unpacker.go:        m := mount.Mount{
pkg/archive/tar_linux_test.go:  m := mount.Mount{
plugins/mount/erofs/plugin_linux_test.go:       m := mount.Mount{
plugins/mount/erofs/plugin_linux_test.go:       m := mount.Mount{
plugins/mount/erofs/plugin_linux_test.go:               simpleMount := mount.Mount{
plugins/mount/erofs/plugin_linux_test.go:               manyOptionsMount := mount.Mount{
plugins/snapshots/erofs/erofs.go:       m := mount.Mount{
plugins/snapshots/erofs/erofs.go:       m := mount.Mount{
plugins/snapshots/overlay/overlayutils/check.go:        m := mount.Mount{
plugins/snapshots/overlay/overlayutils/check.go:        m := mount.Mount{

@thaJeztah

Copy link
Copy Markdown
Member

Change itself LGTM; but (per the discussion about) I think it's worth changing that variable name before merging.

Because selinux contexts can contain commas, context strings may be
quoted in the single-syscall mount API. This quoting is not permitted
when using the fsconfig API, so strip the quotes when preparing the
system call arguments.

Signed-off-by: Daniel De Graaf <[email protected]>
Copilot AI review requested due to automatic review settings July 17, 2026 12:51
@dgdegraaf
dgdegraaf force-pushed the fix-fsmount-selinux branch from 2dce7ea to dd2bcfc Compare July 17, 2026 12:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@thaJeztah thaJeztah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mxpv
mxpv added this pull request to the merge queue Jul 20, 2026
Merged via the queue into containerd:main with commit c792ddd Jul 20, 2026
51 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants