Skip to content

Commit

Permalink
user namespace: fix copy_user_ns return value
Browse files Browse the repository at this point in the history
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@us.ibm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Serge E. Hallyn authored and Linus Torvalds committed Jul 19, 2007
1 parent 9550b10 commit 626ac54
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/linux/user_namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 626ac54

Please sign in to comment.