Skip to content

overlay: support "userxattr" option (kernel 5.11)#5076

Merged
dmcgowan merged 1 commit intocontainerd:masterfrom
AkihiroSuda:ovl-k511
Mar 9, 2021
Merged

overlay: support "userxattr" option (kernel 5.11)#5076
dmcgowan merged 1 commit intocontainerd:masterfrom
AkihiroSuda:ovl-k511

Conversation

@AkihiroSuda
Copy link
Copy Markdown
Member

The "userxattr" option is needed for mounting overlayfs inside a user namespace with kernel >= 5.11.

The "userxattr" option is NOT needed for the initial user namespace (aka "the host").

Also, Ubuntu (since circa 2015) and Debian (since 10) with kernel < 5.11 can mount the overlayfs in a user namespace without the "userxattr" option.

The corresponding kernel commit: torvalds/linux@2d2f2d7

ovl: user xattr

Optionally allow using "user.overlay." namespace instead of "trusted.overlay."
...
Disable redirect_dir and metacopy options, because these would allow privilege escalation through direct manipulation of the
"user.overlay.redirect" or "user.overlay.metacopy" xattrs.

Fix issue #5060

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Feb 24, 2021

Build succeeded.

Comment thread snapshots/overlay/userxattr.go Outdated
Comment thread snapshots/overlay/userxattr.go Outdated
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.

Why make this public and not put it in the checks.go file

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.

Expected to be imported by stargz-snapshotter.

Also perhaps by Moby: moby/moby#42068

Comment thread snapshots/overlay/userxattr.go Outdated
Comment thread snapshots/overlay/userxattr.go Outdated
Comment thread snapshots/overlay/overlay.go Outdated
Copy link
Copy Markdown
Member

@dmcgowan dmcgowan left a comment

Choose a reason for hiding this comment

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

Overall approach looks good

@theopenlab-ci
Copy link
Copy Markdown

theopenlab-ci Bot commented Feb 25, 2021

Build succeeded.

Comment thread snapshots/overlay/overlay.go Outdated
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.

Could we just ignore the error here to ensure that this is very safe?

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.

There is already quite a few errors ignored in the function and should only trigger errors if already in the user namespace.

@AkihiroSuda if we were to always ignore errors here, will it always error out on running containers in 5.11 and later? Plugin load errors are rare, but would that be less confusing than just having the mount errors later on.

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.

if we were to always ignore errors here, will it always error out on running containers in 5.11 and later?

  • rootful is unaffected
  • Yes for most rootless containers, but not "always"

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 think the cleanest solution here is to just have the NeedsUserXattr return errors if it wasn't able to make that determination then just warn about that error here. Considering it is just a flag which gets put on the mount, there shouldn't be a need to fail loading the whole overlay plugin. It is reasonable to log that at warn or error level though, since it shouldn't occur under normal circumstances.

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.

changed return err to logrus.Warn

The "userxattr" option is needed for mounting overlayfs inside a user namespace with kernel >= 5.11.

The "userxattr" option is NOT needed for the initial user namespace (aka "the host").

Also, Ubuntu (since circa 2015) and Debian (since 10) with kernel < 5.11 can mount the overlayfs in a user namespace without the "userxattr" option.

The corresponding kernel commit: 2d2f2d7322ff43e0fe92bf8cccdc0b09449bf2e1
> ovl: user xattr
>
> Optionally allow using "user.overlay." namespace instead of "trusted.overlay."
> ...
> Disable redirect_dir and metacopy options, because these would allow privilege escalation through direct manipulation of the
> "user.overlay.redirect" or "user.overlay.metacopy" xattrs.

Fix issue 5060

Signed-off-by: Akihiro Suda <[email protected]>
Comment thread snapshots/overlay/overlay_test.go
Copy link
Copy Markdown
Member

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Member

@dmcgowan dmcgowan left a comment

Choose a reason for hiding this comment

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

LGTM

@dmcgowan dmcgowan merged commit ddf6594 into containerd:master Mar 9, 2021
@AkihiroSuda AkihiroSuda added cherry-picked/1.4.x PR commits are cherry picked into the release/1.4 branch and removed cherry-pick/1.4.x labels Mar 10, 2021
AkihiroSuda added a commit to AkihiroSuda/buildkit_poc that referenced this pull request Mar 10, 2021
Required for rootless overlayfs on kernel 5.11
containerd/containerd#5076

Signed-off-by: Akihiro Suda <[email protected]>
AkihiroSuda added a commit to AkihiroSuda/buildkit_poc that referenced this pull request Mar 10, 2021
Required for rootless overlayfs on kernel 5.11
containerd/containerd#5076

Signed-off-by: Akihiro Suda <[email protected]>
AkihiroSuda added a commit to AkihiroSuda/buildkit_poc that referenced this pull request Mar 11, 2021
AkihiroSuda added a commit to AkihiroSuda/ktock-remote-snapshotter that referenced this pull request Mar 19, 2021
AkihiroSuda added a commit to AkihiroSuda/ktock-remote-snapshotter that referenced this pull request Mar 19, 2021
ktock pushed a commit to ktock/stargz-snapshotter that referenced this pull request Apr 29, 2021
uubk pushed a commit to vsk8s/containerd that referenced this pull request Sep 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/1.4.x PR commits are cherry picked into the release/1.4 branch impact/changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants