Skip to content

Fix xattr copy failures on SELinux systems #6015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kaovilai
Copy link

@kaovilai kaovilai commented Jun 5, 2025

Summary

  • Fix xattr copy failures when copying buildkit-qemu-emulator on SELinux-enabled systems
  • Add XAttrErrorHandler to ignore ENOTSUP errors during copy operation

Description

When copying the buildkit-qemu-emulator binary on systems with SELinux enabled, the copy operation fails with "operation not supported" errors when attempting to copy security.selinux xattrs.

This PR adds an XAttrErrorHandler to the copy.Copy call that ignores ENOTSUP errors, allowing the copy to succeed on SELinux-enabled systems.

Related Issues

Fixes #5544

Test plan

  • Tested on SELinux-enabled system
  • Existing tests pass
  • No regression on non-SELinux systems

🤖 Generated with Claude Code

@AkihiroSuda
Copy link
Member

🤖 Generated with Claude Code

How did you test this?

@kaovilai
Copy link
Author

I won't be able to test this as I do not have time to build all the associated components I require. I am simply PR'ing the root cause of the issues I am having, and leaning on this project maintainers to get it merged.

@@ -64,6 +65,15 @@ func (m *staticEmulatorMount) Mount() ([]mount.Mount, func() error, error) {
if err := copy.Copy(context.TODO(), filepath.Dir(m.path), filepath.Base(m.path), tmpdir, qemuMountName, func(ci *copy.CopyInfo) {
m := 0555
ci.Mode = &m
ci.XAttrErrorHandler = func(dst, src, xattrKey string, err error) error {
Copy link
Member

Choose a reason for hiding this comment

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

Looks like there's also functional arguments for this;

func WithXAttrErrorHandler(h XAttrErrorHandler) Opt {
return func(ci *CopyInfo) {
ci.XAttrErrorHandler = h
}
}
func AllowXAttrErrors(ci *CopyInfo) {
h := func(string, string, string, error) error {
return nil
}
WithXAttrErrorHandler(h)(ci)
}

(but not sure if we can unconditionally ignore all syscall.ENOTSUP errors)

Copy link
Author

Choose a reason for hiding this comment

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

done.

@kaovilai kaovilai force-pushed the fix-5544-xattr-selinux branch from 69482ed to 12d70b7 Compare June 13, 2025 16:51
kaovilai and others added 3 commits June 13, 2025 13:15
When copying the buildkit-qemu-emulator binary on systems with SELinux
enabled, the copy operation fails with "operation not supported" errors
when attempting to copy security.selinux xattrs.

This change adds an XAttrErrorHandler to the copy.Copy call that ignores
ENOTSUP errors, allowing the copy to succeed on SELinux-enabled systems.

Fixes moby#5544

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Tiger Kaovilai <passawit.kaovilai@gmail.com>
…ndler function

Signed-off-by: Tiger Kaovilai <passawit.kaovilai@gmail.com>
Signed-off-by: Tiger Kaovilai <passawit.kaovilai@gmail.com>
@kaovilai kaovilai force-pushed the fix-5544-xattr-selinux branch from e65bc1c to b613010 Compare June 13, 2025 17:16
Signed-off-by: Tiger Kaovilai <passawit.kaovilai@gmail.com>
@kaovilai kaovilai force-pushed the fix-5544-xattr-selinux branch from b613010 to ca8238c Compare June 13, 2025 17:17
@kaovilai kaovilai requested a review from thaJeztah June 13, 2025 17:17
@cokybit cokybit linked an issue Jun 22, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.github/dependabot.yml Copy of buildkit-qemu-emulator should ignore xattr failures
3 participants