ipcns: fix use after free in free_ipc_ns()

commit b515498 ("userns: add a user namespace owner of ipc ns") added a
user namespace owner of ipc ns, but it also introduced a use after free in
free_ipc_ns().

Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
Acked-by: "Serge E. Hallyn" <serge.hallyn@canonical.com>
Acked-by: David Howells <dhowells@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Daniel Lezcano <daniel.lezcano@free.fr>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Xiaotian Feng and committed by
Linus Torvalds
be4d250a c03e3126

+1 -1
+1 -1
ipc/namespace.c
··· 104 sem_exit_ns(ns); 105 msg_exit_ns(ns); 106 shm_exit_ns(ns); 107 - kfree(ns); 108 atomic_dec(&nr_ipc_ns); 109 110 /* ··· 112 */ 113 ipcns_notify(IPCNS_REMOVED); 114 put_user_ns(ns->user_ns); 115 } 116 117 /*
··· 104 sem_exit_ns(ns); 105 msg_exit_ns(ns); 106 shm_exit_ns(ns); 107 atomic_dec(&nr_ipc_ns); 108 109 /* ··· 113 */ 114 ipcns_notify(IPCNS_REMOVED); 115 put_user_ns(ns->user_ns); 116 + kfree(ns); 117 } 118 119 /*