ucounts: In set_cred_ucounts assume new->ucounts is non-NULL
authorEric W. Biederman <ebiederm@xmission.com>
Sat, 16 Oct 2021 17:51:58 +0000 (12:51 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Feb 2022 11:03:20 +0000 (12:03 +0100)
commitf418bfabea43325f306276226f64ebc7de1b7d56
tree994464193a4e1cf79511dbc39cf9bbc66bf01871
parentd464492eb3917e8a1be67c5aa6a4ad8fe7551652
ucounts: In set_cred_ucounts assume new->ucounts is non-NULL

commit 99c31f9feda41d0f10d030dc04ba106c93295aa2 upstream.

Any cred that is destined for use by commit_creds must have a non-NULL
cred->ucounts field.  Only curing credential construction is a NULL
cred->ucounts valid.  Only abort_creds, put_cred, and put_cred_rcu
needs to deal with a cred with a NULL ucount.  As set_cred_ucounts is
non of those case don't confuse people by handling something that can
not happen.

Link: https://lkml.kernel.org/r/871r4irzds.fsf_-_@disp2133
Tested-by: Yu Zhao <yuzhao@google.com>
Reviewed-by: Alexey Gladkov <legion@kernel.org>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/cred.c