From: Serge E. Hallyn Date: Tue, 17 Jul 2007 19:28:17 +0000 (-0400) Subject: user namespace: fix copy_user_ns return value X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=626ac545c12e5f9bffe93086d1d03d26c99987ea;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git user namespace: fix copy_user_ns return value When a CONFIG_USER_NS=n and a user tries to unshare some namespace other than the user namespace, the dummy copy_user_ns returns NULL rather than the old_ns. This value then gets assigned to task->nsproxy->user_ns, so that a subsequent setuid, which uses task->nsproxy->user_ns, causes a NULL pointer deref. Fix this by returning old_ns. Signed-off-by: Serge E. Hallyn Signed-off-by: Linus Torvalds --- diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h index bb320573bb9e..1101b0ce878f 100644 --- a/include/linux/user_namespace.h +++ b/include/linux/user_namespace.h @@ -49,7 +49,7 @@ static inline struct user_namespace *copy_user_ns(int flags, if (flags & CLONE_NEWUSER) return ERR_PTR(-EINVAL); - return NULL; + return old_ns; } static inline void put_user_ns(struct user_namespace *ns)