aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/nsproxy.c
diff options
context:
space:
mode:
authorCedric Le Goater <clg@fr.ibm.com>2007-07-16 02:41:06 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-16 12:05:47 -0400
commit467e9f4b5086a60a5cb2e032ccaf4a31abadc4c2 (patch)
treef21b3975db312e4cdee1d9d3622549de2648b7ff /kernel/nsproxy.c
parent3e733f071e16bdad13a75eedb102e8941b09927e (diff)
fix create_new_namespaces() return value
dup_mnt_ns() and clone_uts_ns() return NULL on failure. This is wrong, create_new_namespaces() uses ERR_PTR() to catch an error. This means that the subsequent create_new_namespaces() will hit BUG_ON() in copy_mnt_ns() or copy_utsname(). Modify create_new_namespaces() to also use the errors returned by the copy_*_ns routines and not to systematically return ENOMEM. [oleg@tv-sign.ru: better changelog] Signed-off-by: Cedric Le Goater <clg@fr.ibm.com> Cc: Serge E. Hallyn <serue@us.ibm.com> Cc: Badari Pulavarty <pbadari@us.ibm.com> Cc: Pavel Emelianov <xemul@openvz.org> Cc: Herbert Poetzl <herbert@13thfloor.at> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Oleg Nesterov <oleg@tv-sign.ru> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/nsproxy.c')
-rw-r--r--kernel/nsproxy.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index 5aa28e219487..15a6015a849d 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -58,30 +58,41 @@ static struct nsproxy *create_new_namespaces(int flags, struct task_struct *tsk,
58 struct fs_struct *new_fs) 58 struct fs_struct *new_fs)
59{ 59{
60 struct nsproxy *new_nsp; 60 struct nsproxy *new_nsp;
61 int err;
61 62
62 new_nsp = clone_nsproxy(tsk->nsproxy); 63 new_nsp = clone_nsproxy(tsk->nsproxy);
63 if (!new_nsp) 64 if (!new_nsp)
64 return ERR_PTR(-ENOMEM); 65 return ERR_PTR(-ENOMEM);
65 66
66 new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs); 67 new_nsp->mnt_ns = copy_mnt_ns(flags, tsk->nsproxy->mnt_ns, new_fs);
67 if (IS_ERR(new_nsp->mnt_ns)) 68 if (IS_ERR(new_nsp->mnt_ns)) {
69 err = PTR_ERR(new_nsp->mnt_ns);
68 goto out_ns; 70 goto out_ns;
71 }
69 72
70 new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns); 73 new_nsp->uts_ns = copy_utsname(flags, tsk->nsproxy->uts_ns);
71 if (IS_ERR(new_nsp->uts_ns)) 74 if (IS_ERR(new_nsp->uts_ns)) {
75 err = PTR_ERR(new_nsp->uts_ns);
72 goto out_uts; 76 goto out_uts;
77 }
73 78
74 new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns); 79 new_nsp->ipc_ns = copy_ipcs(flags, tsk->nsproxy->ipc_ns);
75 if (IS_ERR(new_nsp->ipc_ns)) 80 if (IS_ERR(new_nsp->ipc_ns)) {
81 err = PTR_ERR(new_nsp->ipc_ns);
76 goto out_ipc; 82 goto out_ipc;
83 }
77 84
78 new_nsp->pid_ns = copy_pid_ns(flags, tsk->nsproxy->pid_ns); 85 new_nsp->pid_ns = copy_pid_ns(flags, tsk->nsproxy->pid_ns);
79 if (IS_ERR(new_nsp->pid_ns)) 86 if (IS_ERR(new_nsp->pid_ns)) {
87 err = PTR_ERR(new_nsp->pid_ns);
80 goto out_pid; 88 goto out_pid;
89 }
81 90
82 new_nsp->user_ns = copy_user_ns(flags, tsk->nsproxy->user_ns); 91 new_nsp->user_ns = copy_user_ns(flags, tsk->nsproxy->user_ns);
83 if (IS_ERR(new_nsp->user_ns)) 92 if (IS_ERR(new_nsp->user_ns)) {
93 err = PTR_ERR(new_nsp->user_ns);
84 goto out_user; 94 goto out_user;
95 }
85 96
86 return new_nsp; 97 return new_nsp;
87 98
@@ -99,7 +110,7 @@ out_uts:
99 put_mnt_ns(new_nsp->mnt_ns); 110 put_mnt_ns(new_nsp->mnt_ns);
100out_ns: 111out_ns:
101 kfree(new_nsp); 112 kfree(new_nsp);
102 return ERR_PTR(-ENOMEM); 113 return ERR_PTR(err);
103} 114}
104 115
105/* 116/*