-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
syscall, os/exec: Support for User Namespaces #8447
Labels
Milestone
Comments
This bug should have more context and references to the interfaces involved. It seems this is a new Linux-only interface as of Linux 3.5: I dug up this description of /proc/nnn/uid_map and gid_map, etc: https://lists.linux-foundation.org/pipermail/containers/2013-January/031504.html It's probably committed somewhere. Copying Ian, who loves fork issues. |
Yes, this is a linux only feature. It is described here -- http://lwn.net/Articles/532593/ |
OK, that is some crazy stuff. But, it's not clear to me why this needs to go into the syscall package at all. Why can't the child process do it when it starts up? That is, I can see that it would sometimes be convenient to have this in SysProcAttr, but so far everything in SysProcAttr is there because it can't reasonably be done elsewhere. It seems like this mapping could be written by a helper process. |
The child process is limited in what mappings it could write. One approach we tried was writing the mappings after the child is exec'ed. In that case, child does become root (if the parent writes the correct mappings), but it has lost capabilities on exec (unless the binary was a setuid), so it is very limited in what it could do. It can't even switch to the docker user since CAP_SETUID/CAP_SETGID are lost. This led us to the path of pursuing this patch. |
The mappings have to be written after the fork and before the exec of the new process or they will not be successfully applied. That is why it has to go into the syscall package because we have no reliable way to insert code in-between the fork and exec. Like the comment above using a helper process to write the mappings does work but capabilities are lost when the fork'd process tries to update it's own UID/GID mappings. |
Here are more details about what happens in exec_linux.go when CLONE_NEWUSER is passed as a flag -- 1. child uid is overflowuid i.e 65534. 2. If UID/GID are passed setuid/setgid in child will fail since linux returns invalid arguments for setuid/setgid for any unmapped values. (With patch and mappings written, this succeeds as the mappings have been written.) 3. child execs any binary (nsinit in case of docker which isn't setuid) and since the child isn't root it loses capabilities. With the patch we ensure that it is root, so it has all capabilities and is able to do further setup before exec'ing into user supplied command. |
Comment 11 by brandon@ifup.co: Ian- Does this mean that the current code review should be closed and something new should be proposed against go.sys? https://golang.org/cl/126190043 This issue blocks a pretty major feature of Docker and libcontainer so it would be great to get it on the right path for go 1.4. |
I think that I was wrong about go.sys. Code that has to run between fork and exec more or less has to run in the syscall support, otherwise the os and os/exec packages can't use it. I'm not sure I understand that CL, though. It looks like that CL was never even mailed out. Is it ready for review? Why does it use a pipe rather than simply opening the file in the child? Labels changed: added release-go1.4, removed release-none. |
Ian, it wasn't mailed out after this discussion as I assumed that it won't be used in favor of a go.sys based solution. The pipe is used as a synchronization mechanism to make the child wait for the parent to write the mappings. BTW, I can mail this out to the appropriate mailing list if we are ready to make the change in fork/exec code. |
I used the publish + mail comments option on the codereview, since I don't have access to the system where I initiated the codereview from right now. Hopefully that sent out an email to initiate a formal review. If that didn't work, I will resend it from my other system in the evening. |
https://golang.org/cl/126190043/ mentions this issue. |
This issue was closed by revision f9d7e13. Status changed to Fixed. |
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jun 25, 2018
Fixes golang#8447. LGTM=iant R=golang-codereviews, bradfitz, iant CC=golang-codereviews https://golang.org/cl/126190043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jun 26, 2018
Fixes golang#8447. LGTM=iant R=golang-codereviews, bradfitz, iant CC=golang-codereviews https://golang.org/cl/126190043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jul 9, 2018
Fixes golang#8447. LGTM=iant R=golang-codereviews, bradfitz, iant CC=golang-codereviews https://golang.org/cl/126190043
wheatman
pushed a commit
to wheatman/go-akaros
that referenced
this issue
Jul 30, 2018
Fixes golang#8447. LGTM=iant R=golang-codereviews, bradfitz, iant CC=golang-codereviews https://golang.org/cl/126190043
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by mrunalp:
The text was updated successfully, but these errors were encountered: