Skip to content

fix(oci): apply absolute symlink resolution to /etc/group#12925

Merged
AkihiroSuda merged 1 commit intocontainerd:mainfrom
pauloappbr:fix/12683-apply-symlink-fix-to-groups
Mar 12, 2026
Merged

fix(oci): apply absolute symlink resolution to /etc/group#12925
AkihiroSuda merged 1 commit intocontainerd:mainfrom
pauloappbr:fix/12683-apply-symlink-fix-to-groups

Conversation

@pauloappbr
Copy link
Copy Markdown
Contributor

This is a follow-up to PR #12732.

As noted by @TheColorman, while the previous PR successfully resolved absolute symlinks pointing outside the mount root for /etc/passwd during user lookups, the same logic was missing for group lookups. This caused openat etc/group: path escapes from parent errors when /etc/group was also an absolute symlink (e.g., in NixOS environments).

This patch updates GIDFromFS, getSupplementalGroupsFromFS, and WithAppendAdditionalGroups to use the openUserFile helper, ensuring absolute symlinks are correctly re-anchored across all OCI user/group resolution paths.

Fixes #12683

Signed-off-by: Paulo Oliveira [email protected]

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.

Thanks. The change looks good. However, please add the UT to cover this case.

@github-project-automation github-project-automation Bot moved this from Needs Triage to Needs Update in Pull Request Review Feb 21, 2026
@pauloappbr pauloappbr force-pushed the fix/12683-apply-symlink-fix-to-groups branch from 1176e7f to a5bf049 Compare February 22, 2026 00:59
@pauloappbr
Copy link
Copy Markdown
Contributor Author

Thanks. The change looks good. However, please add the UT to cover this case.

Done! Added TestGroupLookup_AbsoluteSymlink covering both GIDFromFS and getSupplementalGroupsFromFS absolute symlink resolution.
I also squashed the commits to keep the history clean. Let me know if it needs anything else! Thanks for the review.

This is a follow-up to PR #12732.

As noted by @TheColorman, while the previous PR successfully resolved absolute symlinks pointing outside the mount root for /etc/passwd during user lookups, the same logic was missing for group lookups. This caused `openat etc/group: path escapes from parent` errors when /etc/group was also an absolute symlink (e.g., in NixOS environments).

This patch updates GIDFromFS, getSupplementalGroupsFromFS, and WithAppendAdditionalGroups to use the openUserFile helper, ensuring absolute symlinks are correctly re-anchored across all OCI user/group resolution paths. Includes unit test for validation.

Fixes #12683

Signed-off-by: Paulo Oliveira <[email protected]>
@fuweid fuweid added cherry-pick/2.0.x Change to be cherry picked to release/2.0 branch cherry-pick/2.1.x Change to be cherry picked to release/2.1 branch cherry-pick/1.7.x Change to be cherry picked to release/1.7 branch cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch and removed cherry-pick/2.0.x Change to be cherry picked to release/2.0 branch labels Feb 22, 2026
@eskytthe
Copy link
Copy Markdown

Thanks for this @pauloappbr

MR tested on NixOS - NixOS/nixpkgs#482748 (comment) and runs fine.

(In NixOS we can add patches (commits/MRs) to packages in a simple way, and have a rather powerful test system to test packages with)

BR
Erik

@eskytthe
Copy link
Copy Markdown

eskytthe commented Mar 9, 2026

Is it possible to get a extra review on this from somebody with write access? We and others are stuck on older versions of contained because of this change in go.

@AllanBlanchard
Copy link
Copy Markdown

@eskytthe Which version do you use exactly? We have the same problem on our Nix-based continuous integration and if I can downgrade to a reasonable working version it could help a lot.

@h0nIg
Copy link
Copy Markdown

h0nIg commented Mar 11, 2026

@samuelkarp can you please help?

@eskytthe
Copy link
Copy Markdown

@eskytthe Which version do you use exactly? We have the same problem on our Nix-based continuous integration and if I can downgrade to a reasonable working version it could help a lot.

@AllanBlanchard we use 2.1.5 for our k8s setup - runs well (think it was standard in nixos 25.05). Overlay included if you can use it. Note containerd ver. 2.2.2 was released yesterday - but yes it do not include this /etc/group fix.
/Erik

  containerd = super.containerd.overrideAttrs (
    final: prev: {
      name = "${final.pname}-${final.version}";
      version =
        assert prev.version == "2.2.1";
        "2.1.5";
      src = self.fetchFromGitHub {
        owner = "containerd";
        repo = "containerd";
        rev = "v${final.version}";
        hash = "sha256-P948Rn11kAENAX3qHrSmIdV6VgybbuHdOTAgcYWk2bg=";
      };
      makeFlags = (prev.makeFlags or [ ]) ++ [ "VERSION=v${final.version}" ];
    }
  );

@fuweid
Copy link
Copy Markdown
Member

fuweid commented Mar 11, 2026

ping @samuelkarp @mxpv @AkihiroSuda

@github-project-automation github-project-automation Bot moved this from Needs Update to Review In Progress in Pull Request Review Mar 12, 2026
@AkihiroSuda AkihiroSuda added this pull request to the merge queue Mar 12, 2026
@AkihiroSuda
Copy link
Copy Markdown
Member

/cherry-pick release/2.2

@k8s-infra-cherrypick-robot
Copy link
Copy Markdown

@AkihiroSuda: once the present PR merges, I will cherry-pick it on top of release/2.2 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release/2.2

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-sigs/prow repository.

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 12, 2026
@AkihiroSuda AkihiroSuda added this pull request to the merge queue Mar 12, 2026
Merged via the queue into containerd:main with commit 1794073 Mar 12, 2026
92 of 94 checks passed
@github-project-automation github-project-automation Bot moved this from Review In Progress to Done in Pull Request Review Mar 12, 2026
@k8s-infra-cherrypick-robot
Copy link
Copy Markdown

@AkihiroSuda: new pull request created: #13019

Details

In response to this:

/cherry-pick release/2.2

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-sigs/prow repository.

@austinvazquez austinvazquez added cherry-picked/2.2.x PR commits are cherry-picked into release/2.2 branch and removed cherry-pick/2.2.x Change to be cherry picked to release/2.2 branch labels Mar 13, 2026
@Harjappan-Singh
Copy link
Copy Markdown

Hi @austinvazquez, could you please confirm if this was cherry-picked to 2.2.x? I don't see it in the commit history

@samuelkarp
Copy link
Copy Markdown
Member

@Harjappan-Singh Look at #13019. You can see it was merged March 12, but the last 2.2 was release March 10. It's in the branch, but not released yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/client Go client cherry-pick/1.7.x Change to be cherry picked to release/1.7 branch cherry-pick/2.1.x Change to be cherry picked to release/2.1 branch cherry-picked/2.2.x PR commits are cherry-picked into release/2.2 branch go Pull requests that update Go code size/M

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[Go 1.24] v2.2.0 fails to create containers from images having /etc/{passwd,group} symlinked to an absolute path