diff options
| author | Eric W. Biederman <ebiederm@xmission.com> | 2012-07-26 08:15:35 -0400 |
|---|---|---|
| committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-11-20 07:18:14 -0500 |
| commit | b2e0d98705e60e45bbb3c0032c48824ad7ae0704 (patch) | |
| tree | e187c82e1c3babd34095f2b946614131719bbb03 /include/linux | |
| parent | cde1975bc242f3e1072bde623ef378e547b73f91 (diff) | |
userns: Implement unshare of the user namespace
- Add CLONE_THREAD to the unshare flags if CLONE_NEWUSER is selected
As changing user namespaces is only valid if all there is only
a single thread.
- Restore the code to add CLONE_VM if CLONE_THREAD is selected and
the code to addCLONE_SIGHAND if CLONE_VM is selected.
Making the constraints in the code clear.
Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/nsproxy.h | 2 | ||||
| -rw-r--r-- | include/linux/user_namespace.h | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h index cc37a55ad00..10e5947491c 100644 --- a/include/linux/nsproxy.h +++ b/include/linux/nsproxy.h | |||
| @@ -67,7 +67,7 @@ void exit_task_namespaces(struct task_struct *tsk); | |||
| 67 | void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new); | 67 | void switch_task_namespaces(struct task_struct *tsk, struct nsproxy *new); |
| 68 | void free_nsproxy(struct nsproxy *ns); | 68 | void free_nsproxy(struct nsproxy *ns); |
| 69 | int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **, | 69 | int unshare_nsproxy_namespaces(unsigned long, struct nsproxy **, |
| 70 | struct fs_struct *); | 70 | struct cred *, struct fs_struct *); |
| 71 | int __init nsproxy_cache_init(void); | 71 | int __init nsproxy_cache_init(void); |
| 72 | 72 | ||
| 73 | static inline void put_nsproxy(struct nsproxy *ns) | 73 | static inline void put_nsproxy(struct nsproxy *ns) |
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h index 95142cae446..17651f08d67 100644 --- a/include/linux/user_namespace.h +++ b/include/linux/user_namespace.h | |||
| @@ -39,6 +39,7 @@ static inline struct user_namespace *get_user_ns(struct user_namespace *ns) | |||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | extern int create_user_ns(struct cred *new); | 41 | extern int create_user_ns(struct cred *new); |
| 42 | extern int unshare_userns(unsigned long unshare_flags, struct cred **new_cred); | ||
| 42 | extern void free_user_ns(struct kref *kref); | 43 | extern void free_user_ns(struct kref *kref); |
| 43 | 44 | ||
| 44 | static inline void put_user_ns(struct user_namespace *ns) | 45 | static inline void put_user_ns(struct user_namespace *ns) |
| @@ -66,6 +67,14 @@ static inline int create_user_ns(struct cred *new) | |||
| 66 | return -EINVAL; | 67 | return -EINVAL; |
| 67 | } | 68 | } |
| 68 | 69 | ||
| 70 | static inline int unshare_userns(unsigned long unshare_flags, | ||
| 71 | struct cred **new_cred) | ||
| 72 | { | ||
| 73 | if (unshare_flags & CLONE_NEWUSER) | ||
| 74 | return -EINVAL; | ||
| 75 | return 0; | ||
| 76 | } | ||
| 77 | |||
| 69 | static inline void put_user_ns(struct user_namespace *ns) | 78 | static inline void put_user_ns(struct user_namespace *ns) |
| 70 | { | 79 | { |
| 71 | } | 80 | } |
