Skip to content

libcontainer: setupUserNamespace is always called#1743

Merged
cyphar merged 1 commit intoopencontainers:masterfrom
ObjectifLibre:userns_setup_fix
Feb 27, 2018
Merged

libcontainer: setupUserNamespace is always called#1743
cyphar merged 1 commit intoopencontainers:masterfrom
ObjectifLibre:userns_setup_fix

Conversation

@ynirk
Copy link
Copy Markdown
Contributor

@ynirk ynirk commented Feb 26, 2018

The setupUserNamespace is always called even if the usernamespace is not set. This results having wrong uid/gid set on devices.

This fix add a test to check if usernamespace is set befor calling
setupUserNamespace.

Fixes #1742

Signed-off-by: Julien Lavesque julien.lavesque@gmail.com

@ynirk ynirk changed the title libcontaner: setupUserNamespace is always called libcontainer: setupUserNamespace is always called Feb 26, 2018
The function is called even if the usernamespace is not set.
This results having wrong uid/gid set on devices.

This fix add a test to check if usernamespace is set befor calling
setupUserNamespace.

Fixes opencontainers#1742

Signed-off-by: Julien Lavesque <julien.lavesque@gmail.com>
@cyphar
Copy link
Copy Markdown
Member

cyphar commented Feb 26, 2018

The code in question is still broken with user namespaces, because the logic in setupUserNamespaces is wrong. It should only be setting the owner to root if and only if the uid or gid are unmapped in the user namespaces set (so if the uid is unmapped for a given device, set the uid to root).

However in general I also think that the the logic of "magically change the owners" doesn't make much sense either -- so maybe this section should just be dropped entirely. I'm not sure -- @crosbymichael do you know if anything actually depends on this?

@crosbymichael
Copy link
Copy Markdown
Member

crosbymichael commented Feb 26, 2018

LGTM

Also I think @cyphar point makes sense about changing the logic in a follow up PR. I think it was originally like this because the userns was erroring when no uid/gid was set on a device or the device was owned by a weird user before. We would have to test and see if we can remove it fully.

Approved with PullApprove

@crosbymichael
Copy link
Copy Markdown
Member

LGTM

@crosbymichael
Copy link
Copy Markdown
Member

@cyphar this should probably go in RC5 and 1.0. It was a bug merged in that caused this because we had a check before that wouldn't run this code unless userns was specified .

@mrunalp
Copy link
Copy Markdown
Contributor

mrunalp commented Feb 26, 2018

LGTM

Approved with PullApprove

@cyphar
Copy link
Copy Markdown
Member

cyphar commented Feb 27, 2018

@crosbymichael Alright, I'll send out a REJECT and then re-send the release mail. Merging.

LGTM (for the record).

Approved with PullApprove

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Devices are mounted with wrong uid/gid

4 participants