[PATCH] user namespace: fix copy_user_ns return value

From: Serge E . Hallyn
Date: Tue Jul 17 2007 - 15:28:17 EST


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 <serue@xxxxxxxxxx>
---
include/linux/user_namespace.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
index bb32057..1101b0c 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)
--
1.5.1.1.GIT

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/