From: Oleg Nesterov Date: Tue, 6 Aug 2013 17:38:55 +0000 (+0200) Subject: userns: unshare_userns(&cred) should not populate cred on failure X-Git-Tag: v3.11-rc5~38 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6160968cee8b90a5dd95318d716e31d7775c4ef3;p=pandora-kernel.git userns: unshare_userns(&cred) should not populate cred on failure unshare_userns(new_cred) does *new_cred = prepare_creds() before create_user_ns() which can fail. However, the caller expects that it doesn't need to take care of new_cred if unshare_userns() fails. We could change the single caller, sys_unshare(), but I think it would be more clean to avoid the side effects on failure, so with this patch unshare_userns() does put_cred() itself and initializes *new_cred only if create_user_ns() succeeeds. Cc: stable@vger.kernel.org Signed-off-by: Oleg Nesterov Reviewed-by: Andy Lutomirski Signed-off-by: Linus Torvalds --- Reading git-diff-tree failed