Skip to content
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

[release/1.5 backport] cri: filter selinux xattr for image volumes #5104

Merged
merged 1 commit into from Oct 9, 2021

Conversation

dweomer
Copy link
Contributor

@dweomer dweomer commented Mar 1, 2021

Exclude the security.selinux xattr when copying content from layer
storage for image volumes. This allows for the already correct label at
the target location to be applied to the copied content, thus enabling
containers to write to volumes that they implicitly expect to be able to
write to.

@k8s-ci-robot
Copy link

Hi @dweomer. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@dweomer
Copy link
Contributor Author

dweomer commented Mar 1, 2021

@dmcgowan @AkihiroSuda @mikebrow: I've submitted this is a draft/WIP because it depends on the as-of-yet not merged containerd/continuity#178. Once it is merged I will update this PR. /cc @samuelkarp

@theopenlab-ci
Copy link

theopenlab-ci bot commented Mar 1, 2021

Build succeeded.

@dweomer
Copy link
Contributor Author

dweomer commented Mar 1, 2021

This SELinux/Integration failure, https://github.com/containerd/containerd/pull/5104/checks?check_run_id=2007903504, seems unrelated to this change but I will dig a bit further.

@dweomer
Copy link
Contributor Author

dweomer commented Mar 1, 2021

This SELinux/Integration failure, https://github.com/containerd/containerd/pull/5104/checks?check_run_id=2007903504, seems unrelated to this change but I will dig a bit further.

Seems like a flake, SELINUX=Enforcing vagrant up --provision-with=shell,selinux,test-integration runs successfully for me with:

  • vagrant 2.2.9
  • libvirt 6.0.0
  • ubuntu/focal 20.04.2

@samuelkarp
Copy link
Member

/ok-to-test

Copy link
Member

@samuelkarp samuelkarp left a comment

Choose a reason for hiding this comment

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

This LGTM pending the merge into continuity and removing the replace in go.mod.

dweomer added a commit to k3s-io/containerd that referenced this pull request Mar 9, 2021
Pull in a fix for containerd/cri that pulls in a fix for containerd/continuity: when copying directories for image volumes we should filter out the security.selinux xattr key because the target has been correctly relabeled already (and image volumes are copying from layer storage which has a read-only selinux context).

Upstream PR(s) for 1.5.x:
- containerd/continuity#178
- containerd#5104

Addresses:
- rancher/rke2#690

Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
dweomer added a commit to dweomer/rke2 that referenced this pull request Mar 9, 2021
Originally reported at rancher#690 against a v1.19.7 beta
pre-release, there is an issue with containerd versions 1.4+ that
prevented the correct selinux labels from being applied for image
volumes (volumes declared in the docker image that containerd/cri will
set up for you by default ... but they aren't visible to k8s).

Patches to fix this have been submitted upstream, see:
- containerd/containerd#5090
- containerd/containerd#5104
- containerd/continuity#178

Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
dweomer added a commit to dweomer/rke2 that referenced this pull request Mar 9, 2021
Originally reported at rancher#690 against a v1.19.7 beta
pre-release, there is an issue with containerd versions 1.4+ that
prevented the correct selinux labels from being applied for image
volumes (volumes declared in the docker image that containerd/cri will
set up for you by default ... but they aren't visible to k8s).

Patches to fix this have been submitted upstream, see:
- containerd/containerd#5090
- containerd/containerd#5104
- containerd/continuity#178

Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
dweomer added a commit to dweomer/rke2 that referenced this pull request Mar 9, 2021
Originally reported at rancher#690 against a v1.19.7 beta
pre-release, there is an issue with containerd versions 1.4+ that
prevented the correct selinux labels from being applied for image
volumes (volumes declared in the docker image that containerd/cri will
set up for you by default ... but they aren't visible to k8s).

Patches to fix this have been submitted upstream, see:
- containerd/containerd#5090
- containerd/containerd#5104
- containerd/continuity#178

Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
dweomer added a commit to rancher/rke2 that referenced this pull request Mar 13, 2021
Originally reported at #690 against a v1.19.7 beta
pre-release, there is an issue with containerd versions 1.4+ that
prevented the correct selinux labels from being applied for image
volumes (volumes declared in the docker image that containerd/cri will
set up for you by default ... but they aren't visible to k8s).

Patches to fix this have been submitted upstream, see:
- containerd/containerd#5090
- containerd/containerd#5104
- containerd/continuity#178

Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
dweomer added a commit to dweomer/rke2 that referenced this pull request Mar 13, 2021
Originally reported at rancher#690 against a v1.19.7 beta
pre-release, there is an issue with containerd versions 1.4+ that
prevented the correct selinux labels from being applied for image
volumes (volumes declared in the docker image that containerd/cri will
set up for you by default ... but they aren't visible to k8s).

Patches to fix this have been submitted upstream, see:
- containerd/containerd#5090
- containerd/containerd#5104
- containerd/continuity#178

Addresses rancher#690

Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
dweomer added a commit to rancher/rke2 that referenced this pull request Mar 13, 2021
Originally reported at #690 against a v1.19.7 beta
pre-release, there is an issue with containerd versions 1.4+ that
prevented the correct selinux labels from being applied for image
volumes (volumes declared in the docker image that containerd/cri will
set up for you by default ... but they aren't visible to k8s).

Patches to fix this have been submitted upstream, see:
- containerd/containerd#5090
- containerd/containerd#5104
- containerd/continuity#178

Addresses #690

Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
dweomer added a commit to k3s-io/containerd that referenced this pull request Mar 16, 2021
Pull in a fix for containerd/cri that pulls in a fix for containerd/continuity: when copying directories for image volumes we should filter out the security.selinux xattr key because the target has been correctly relabeled already (and image volumes are copying from layer storage which has a read-only selinux context).

Upstream PR(s) for 1.5.x:
- containerd/continuity#178
- containerd#5104

Addresses:
- rancher/rke2#690

Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
@kzys
Copy link
Member

kzys commented Jun 1, 2021

containerd/continuity#178 has been merged!

@dweomer Can you update the PR to remove the replace directive?

@AkihiroSuda @fuweid Are we going to release the continuity package to have the change in a released version?

@kzys kzys added the status/needs-update Awaiting contributor update label Jun 1, 2021
brandond pushed a commit to brandond/containerd that referenced this pull request Jul 19, 2021
Pull in a fix for containerd/cri that pulls in a fix for containerd/continuity: when copying directories for image volumes we should filter out the security.selinux xattr key because the target has been correctly relabeled already (and image volumes are copying from layer storage which has a read-only selinux context).

Upstream PR(s) for 1.5.x:
- containerd/continuity#178
- containerd#5104

Addresses:
- rancher/rke2#690

Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
brandond pushed a commit to brandond/containerd that referenced this pull request Jul 20, 2021
Pull in a fix for containerd/cri that pulls in a fix for containerd/continuity: when copying directories for image volumes we should filter out the security.selinux xattr key because the target has been correctly relabeled already (and image volumes are copying from layer storage which has a read-only selinux context).

Upstream PR(s) for 1.5.x:
- containerd/continuity#178
- containerd#5104

Addresses:
- rancher/rke2#690

Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
@dmcgowan dmcgowan added this to Needs Contributor Update in Code Review Jul 23, 2021
@bcressey
Copy link

@AkihiroSuda @fuweid Are we going to release the continuity package to have the change in a released version?

The xattr fix to continuity was in the v0.1.0 release, which came in before 1.5.0 from 3ef337a.

The change to pkg/cri/opts/container.go should be all that's still needed.

@bcressey
Copy link

The change to pkg/cri/opts/container.go should be all that's still needed.

I've tested a patch with just this change locally and confirmed that it fixes labeling for image volumes.

brandond pushed a commit to brandond/containerd that referenced this pull request Aug 13, 2021
Pull in a fix for containerd/cri that pulls in a fix for containerd/continuity: when copying directories for image volumes we should filter out the security.selinux xattr key because the target has been correctly relabeled already (and image volumes are copying from layer storage which has a read-only selinux context).

Upstream PR(s) for 1.5.x:
- containerd/continuity#178
- containerd#5104

Addresses:
- rancher/rke2#690

Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
@theopenlab-ci
Copy link

theopenlab-ci bot commented Aug 21, 2021

Build succeeded.

@dweomer dweomer changed the title [release/1.5] cri: filter selinux xattr for image volumes [release/1.5 backport] cri: filter selinux xattr for image volumes Aug 25, 2021
@dweomer dweomer marked this pull request as ready for review August 25, 2021 05:47
@theopenlab-ci
Copy link

theopenlab-ci bot commented Aug 25, 2021

Build succeeded.

@dweomer
Copy link
Contributor Author

dweomer commented Aug 25, 2021

/test pull-containerd-node-e2e

@AkihiroSuda
Copy link
Member

Could you use git cherry-pick -xs so that the original commit hash appears in the cherry-pick commit message?

@dweomer
Copy link
Contributor Author

dweomer commented Aug 25, 2021

Could you use git cherry-pick -xs so that the original commit hash appears in the cherry-pick commit message?

@AkihiroSuda thanks, I was looking for the magic that a cursory search through the contributing docs didn't make obvious for me.

Exclude the `security.selinux` xattr when copying content from layer
storage for image volumes. This allows for the already correct label
at the target location to be applied to the copied content, thus
enabling containers to write to volumes that they implicitly expect to be
able to write to.

- Fixes containerd#5090 for 1.5.x
- See rancher/rke2#690

Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
(cherry picked from commit c3609ff)
@theopenlab-ci
Copy link

theopenlab-ci bot commented Aug 25, 2021

Build succeeded.

Copy link
Member

@samuelkarp samuelkarp left a comment

Choose a reason for hiding this comment

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

LGTM

@samuelkarp samuelkarp removed the status/needs-update Awaiting contributor update label Sep 1, 2021
@dweomer
Copy link
Contributor Author

dweomer commented Sep 29, 2021

While we do carry this for the k3s fork of containerd, we would like to get this merged. It is on main via #5902. Can we get this into a 1.5.x release?

@estesp estesp closed this Sep 29, 2021
Code Review automation moved this from Needs Contributor Update to Done Sep 29, 2021
@estesp estesp reopened this Sep 29, 2021
Code Review automation moved this from Done to New Sep 29, 2021
@estesp estesp moved this from New to Ready For Review in Code Review Sep 29, 2021
@theopenlab-ci
Copy link

theopenlab-ci bot commented Sep 29, 2021

Build succeeded.

Copy link
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

brandond pushed a commit to k3s-io/containerd that referenced this pull request Oct 4, 2021
Pull in a fix for containerd/cri that pulls in a fix for containerd/continuity: when copying directories for image volumes we should filter out the security.selinux xattr key because the target has been correctly relabeled already (and image volumes are copying from layer storage which has a read-only selinux context).

Upstream PR(s) for 1.5.x:
- containerd/continuity#178
- containerd#5104

Addresses:
- rancher/rke2#690

Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
@samuelkarp samuelkarp moved this from Ready For Review to Merge on Green in Code Review Oct 7, 2021
@dmcgowan dmcgowan merged commit c41d458 into containerd:release/1.5 Oct 9, 2021
Code Review automation moved this from Merge on Green to Done Oct 9, 2021
brandond pushed a commit to brandond/containerd that referenced this pull request Nov 18, 2021
Pull in a fix for containerd/cri that pulls in a fix for containerd/continuity: when copying directories for image volumes we should filter out the security.selinux xattr key because the target has been correctly relabeled already (and image volumes are copying from layer storage which has a read-only selinux context).

Upstream PR(s) for 1.5.x:
- containerd/continuity#178
- containerd#5104

Addresses:
- rancher/rke2#690

Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

image volumes have incorrect selinux labels
8 participants