Skip to content

c8d: Fix image commit with userns mapping (carry)#46972

Merged
thaJeztah merged 2 commits intomoby:masterfrom
dmcgowan:fix-userns-capabilities
Jan 3, 2024
Merged

c8d: Fix image commit with userns mapping (carry)#46972
thaJeztah merged 2 commits intomoby:masterfrom
dmcgowan:fix-userns-capabilities

Conversation

@dmcgowan
Copy link
Member

@dmcgowan dmcgowan commented Dec 21, 2023

Alternative approach to #46938 as mentioned here.

The remapping in the commit code was in the wrong place, we would create
a diff and then remap the snapshot, but the descriptor created in
"CreateDiff" was still pointing to the old snapshot, we now remap the
snapshot before creating a diff. Also make sure we don't lose any
capabilities, they used to be lost after the chown.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
@dmcgowan dmcgowan force-pushed the fix-userns-capabilities branch from 856f624 to 711b01c Compare December 21, 2023 03:05
@dmcgowan dmcgowan changed the title c8d: Fix image commit with userns mapping (carry, WIP) c8d: Fix image commit with userns mapping (carry) Dec 22, 2023
@dmcgowan dmcgowan marked this pull request as ready for review December 22, 2023 05:59
@dmcgowan
Copy link
Member Author

Marking this one as ready to review, I don't see any problems in the tests and any optimizations can come later if necessary.

@thaJeztah thaJeztah added containerd-integration Issues and PRs related to containerd integration area/images Image Distribution area/security/userns kind/bugfix PR's that fix bugs status/2-code-review labels Dec 22, 2023
@thaJeztah thaJeztah added this to the 25.0.0 milestone Dec 22, 2023
@thaJeztah
Copy link
Member

Looks like there's a compile failure on Windows;

..\..\daemon\containerd\image_commit.go:265:28: undefined: remapSuffix
..\..\daemon\containerd\image_commit.go:284:16: i.copyAndUnremapRootFS undefined (type *ImageService has no field or method copyAndUnremapRootFS)

@dmcgowan dmcgowan force-pushed the fix-userns-capabilities branch from 711b01c to fc25b1b Compare December 22, 2023 14:24
xattrs[xattr] = data
}

if err := os.Lchown(path, uid, gid); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Can be in a follow-up, but considering to add some details about why these attributes are stripped in the first place (I was initially scratching my head on that), and why we have to go against that. Perhaps it's considered "common knowledge" but I wasn't aware (🙈) Djordje posted a link to https://lwn.net/Articles/244747/ on Slack, which made that clear to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

That sounds useful and would help me understand it as well.

Signed-off-by: Derek McGowan <derek@mcg.dev>
Copy link
Member

@rumpl rumpl 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
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM let's bring this one in

@thaJeztah thaJeztah merged commit 0863225 into moby:master Jan 3, 2024
@thaJeztah thaJeztah deleted the fix-userns-capabilities branch January 3, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/images Image Distribution area/security/userns containerd-integration Issues and PRs related to containerd integration kind/bugfix PR's that fix bugs status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants