diff options
Diffstat (limited to 'kernel/nsproxy.c')
-rw-r--r-- | kernel/nsproxy.c | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index 8246813335cc..8d6c852dc51e 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c | |||
@@ -7,6 +7,10 @@ | |||
7 | * modify it under the terms of the GNU General Public License as | 7 | * modify it under the terms of the GNU General Public License as |
8 | * published by the Free Software Foundation, version 2 of the | 8 | * published by the Free Software Foundation, version 2 of the |
9 | * License. | 9 | * License. |
10 | * | ||
11 | * Jun 2006 - namespaces support | ||
12 | * OpenVZ, SWsoft Inc. | ||
13 | * Pavel Emelianov <xemul@openvz.org> | ||
10 | */ | 14 | */ |
11 | 15 | ||
12 | #include <linux/module.h> | 16 | #include <linux/module.h> |
@@ -62,6 +66,8 @@ struct nsproxy *dup_namespaces(struct nsproxy *orig) | |||
62 | get_namespace(ns->namespace); | 66 | get_namespace(ns->namespace); |
63 | if (ns->uts_ns) | 67 | if (ns->uts_ns) |
64 | get_uts_ns(ns->uts_ns); | 68 | get_uts_ns(ns->uts_ns); |
69 | if (ns->ipc_ns) | ||
70 | get_ipc_ns(ns->ipc_ns); | ||
65 | } | 71 | } |
66 | 72 | ||
67 | return ns; | 73 | return ns; |
@@ -82,7 +88,7 @@ int copy_namespaces(int flags, struct task_struct *tsk) | |||
82 | 88 | ||
83 | get_nsproxy(old_ns); | 89 | get_nsproxy(old_ns); |
84 | 90 | ||
85 | if (!(flags & (CLONE_NEWNS | CLONE_NEWUTS))) | 91 | if (!(flags & (CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWIPC))) |
86 | return 0; | 92 | return 0; |
87 | 93 | ||
88 | new_ns = clone_namespaces(old_ns); | 94 | new_ns = clone_namespaces(old_ns); |
@@ -94,24 +100,31 @@ int copy_namespaces(int flags, struct task_struct *tsk) | |||
94 | tsk->nsproxy = new_ns; | 100 | tsk->nsproxy = new_ns; |
95 | 101 | ||
96 | err = copy_namespace(flags, tsk); | 102 | err = copy_namespace(flags, tsk); |
97 | if (err) { | 103 | if (err) |
98 | tsk->nsproxy = old_ns; | 104 | goto out_ns; |
99 | put_nsproxy(new_ns); | ||
100 | goto out; | ||
101 | } | ||
102 | 105 | ||
103 | err = copy_utsname(flags, tsk); | 106 | err = copy_utsname(flags, tsk); |
104 | if (err) { | 107 | if (err) |
105 | if (new_ns->namespace) | 108 | goto out_uts; |
106 | put_namespace(new_ns->namespace); | 109 | |
107 | tsk->nsproxy = old_ns; | 110 | err = copy_ipcs(flags, tsk); |
108 | put_nsproxy(new_ns); | 111 | if (err) |
109 | goto out; | 112 | goto out_ipc; |
110 | } | ||
111 | 113 | ||
112 | out: | 114 | out: |
113 | put_nsproxy(old_ns); | 115 | put_nsproxy(old_ns); |
114 | return err; | 116 | return err; |
117 | |||
118 | out_ipc: | ||
119 | if (new_ns->uts_ns) | ||
120 | put_uts_ns(new_ns->uts_ns); | ||
121 | out_uts: | ||
122 | if (new_ns->namespace) | ||
123 | put_namespace(new_ns->namespace); | ||
124 | out_ns: | ||
125 | tsk->nsproxy = old_ns; | ||
126 | put_nsproxy(new_ns); | ||
127 | goto out; | ||
115 | } | 128 | } |
116 | 129 | ||
117 | void free_nsproxy(struct nsproxy *ns) | 130 | void free_nsproxy(struct nsproxy *ns) |
@@ -120,5 +133,7 @@ void free_nsproxy(struct nsproxy *ns) | |||
120 | put_namespace(ns->namespace); | 133 | put_namespace(ns->namespace); |
121 | if (ns->uts_ns) | 134 | if (ns->uts_ns) |
122 | put_uts_ns(ns->uts_ns); | 135 | put_uts_ns(ns->uts_ns); |
136 | if (ns->ipc_ns) | ||
137 | put_ipc_ns(ns->ipc_ns); | ||
123 | kfree(ns); | 138 | kfree(ns); |
124 | } | 139 | } |