Skip to content

SELinux: fix ENOTSUP errors not being detected when relabeling#40945

Merged
cpuguy83 merged 1 commit intomoby:masterfrom
thaJeztah:fix_selinux_enotsup
May 11, 2020
Merged

SELinux: fix ENOTSUP errors not being detected when relabeling#40945
cpuguy83 merged 1 commit intomoby:masterfrom
thaJeztah:fix_selinux_enotsup

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

Commit 12c7541 (#40546) updated the opencontainers/selinux dependency to v1.3.1, which had a breaking change in the errors that were returned.

Before v1.3.1, the "raw" syscall.ENOTSUP was returned if the underlying filesystem did not support xattrs, but later versions wrapped the error, which caused our detection to fail.

This patch uses errors.Is() to check for the underlying error. This requires github.com/pkg/errors v0.9.1 or above (older versions could use errors.Cause(), but are not compatible with "native" wrapping of errors in Go 1.13 and up, and could potentially cause these errors to not being detected again.

Addresses #40944 for master

- Description for the changelog

Fix Mounting Docker NFS Volume with selinux enabled failing with "operation not supported"

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah
Copy link
Copy Markdown
Member Author

ping @cpuguy83 @AkihiroSuda ptal

/cc @cquon @adamparco

Commit 12c7541 updated the
opencontainers/selinux dependency to v1.3.1, which had a breaking
change in the errors that were returned.

Before v1.3.1, the "raw" `syscall.ENOTSUP` was returned if the
underlying filesystem did not support xattrs, but later versions
wrapped the error, which caused our detection to fail.

This patch uses `errors.Is()` to check for the underlying error.
This requires github.com/pkg/errors v0.9.1 or above (older versions
could use `errors.Cause()`, but are not compatible with "native"
wrapping of errors in Go 1.13 and up, and could potentially cause
these errors to not being detected again.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah changed the title SELinux: fix ENOENT errors not being detected when relabeling SELinux: fix ENOTSUP errors not being detected when relabeling May 10, 2020
@thaJeztah thaJeztah force-pushed the fix_selinux_enotsup branch from 725ddf3 to 49f8a42 Compare May 10, 2020 15:07
Copy link
Copy Markdown

@adamparco adamparco left a comment

Choose a reason for hiding this comment

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

LGTM

}
}()
if err := label.Relabel(path, container.MountLabel, true); err != nil && err != unix.ENOTSUP {
if err := label.Relabel(path, container.MountLabel, true); err != nil && !errors.Is(err, syscall.ENOTSUP) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note; I picked syscall here, to be consistent with ignoreUnsupportedXAttrs. Both unix. and syscall. work (same error type under the hood)

Copy link
Copy Markdown
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM

@cpuguy83 cpuguy83 merged commit a93e9eb into moby:master May 11, 2020
@thaJeztah thaJeztah deleted the fix_selinux_enotsup branch May 11, 2020 15:41
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.

4 participants