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

Move setns within nsexec #454

Merged
merged 8 commits into from
Feb 29, 2016

Conversation

mlaventure
Copy link
Contributor

This is a rebase of #105.

It move the setns calls within the init C code. This allows for namespaces that only affect future children (e.g. NEWPID) to correctly apply to created containers.

@mrunalp
Copy link
Contributor

mrunalp commented Jan 5, 2016

@dqminh ping


// IsNamespaceSupported returns the list of current kernel's supported
// namespaces. The namespaces will be sorted in order that we can safely setns
// to (i.e., mount namespace is at the bottom of the list)
Copy link
Contributor

Choose a reason for hiding this comment

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

this comment is outdated now. The function just check if the host supports a chosen namespace.

*/
char stack[4096] __attribute__ ((aligned(16)));
char stack_ptr[0];
jmp_buf *env;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just realized that I've used tab-width of 4 instead of 8, will fix sorry (although 7 seems to be what was used previously)

Copy link
Contributor

Choose a reason for hiding this comment

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

mmm, what i did was to use indent -linux with https://github.com/crosbymichael/vim-cfmt

@mlaventure mlaventure force-pushed the libcontainer-pidns branch 3 times, most recently from fd31b6f to a53b405 Compare January 7, 2016 17:10
#include <linux/limits.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/types.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to include sys/types.h

KILL(2)

NAME
       kill - send signal to a process

SYNOPSIS
       #include <sys/types.h>
       #include <signal.h>

       int kill(pid_t pid, int sig);

@LK4D4
Copy link
Contributor

LK4D4 commented Jan 15, 2016

@mlaventure let's try to merge it after next libcontainer tag.

@mlaventure mlaventure force-pushed the libcontainer-pidns branch 3 times, most recently from e8177bb to cbfcb9a Compare January 21, 2016 21:31
@mlaventure mlaventure force-pushed the libcontainer-pidns branch 3 times, most recently from 07a2e50 to 7ca7234 Compare February 8, 2016 15:57
@mlaventure
Copy link
Contributor Author

Rebased.

@crosbymichael crosbymichael added this to the 0.0.9 milestone Feb 10, 2016
dqminh and others added 8 commits February 28, 2016 11:59
This adds `configs.IsNamespaceSupported(nsType)` to check if the host supports
a namespace type.

Signed-off-by: Daniel, Dao Quang Minh <[email protected]>
Signed-off-by: Daniel, Dao Quang Minh <[email protected]>
Signed-off-by: Daniel, Dao Quang Minh <[email protected]>
This adds orderNamespacePaths to get correct order of namespaces for the
bootstrap program to join.

Signed-off-by: Daniel, Dao Quang Minh <[email protected]>
An init process can join other namespaces (pidns, ipc etc.). This leverages
C code defined in nsenter package to spawn a process with correct namespaces
and clone if necessary.

This moves all setns and cloneflags related code to nsenter layer, which mean
that we dont use Go os/exec to create process with cloneflags and set
uid/gid_map or setgroups anymore. The necessary data is passed from Go to C
using a netlink binary-encoding format.

With this change, setns and init processes are almost the same, which brings
some opportunity for refactoring.

Signed-off-by: Daniel, Dao Quang Minh <[email protected]>
[[email protected]: adapted to apply on master @ d97d5e]
Signed-off-by: Kenfe-Mickael Laventure <[email protected]>
Cut nsexec in smaller chunk routines to make it more readable.

Signed-off-by: Kenfe-Mickael Laventure <[email protected]>
This simply move the call to the Prestart hooks to be made once we
receive the procReady message from the client.

This is necessary as we had to move the setns calls within nsexec in
order to be accomodate joining namespaces that only affect future
children (e.g. NEWPID).

Signed-off-by: Kenfe-Mickael Laventure <[email protected]>
@mlaventure
Copy link
Contributor Author

Rebased.

@crosbymichael
Copy link
Member

LGTM

1 similar comment
@avagin
Copy link
Contributor

avagin commented Feb 29, 2016

LGTM

@estesp
Copy link
Contributor

estesp commented Feb 29, 2016

I've been playing with this PR and seems it allows usersn+(other namespaces) sharing properly, which should be good news for relaxing some of the disallowed combinations in Docker when user namespaces are enabled.. 👍

@mrunalp
Copy link
Contributor

mrunalp commented Feb 29, 2016

LGTM
Great work @dqminh Thanks @avagin for the guidance and feedback and @mlaventure for taking it to merge :)

mrunalp pushed a commit that referenced this pull request Feb 29, 2016
@mrunalp mrunalp merged commit b1872a0 into opencontainers:master Feb 29, 2016
@krobertson
Copy link

👍 I think this also fixes a potential issue with two containers sharing a user namespace.

Since other namespaces are associated with the user namespace they were created from, it is best to join the user namespace before creating the new namespaces on clone or unshare.

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

Successfully merging this pull request may close these issues.

9 participants