Skip to content

Commit

Permalink
Revert "ucounts: Increase ucounts reference counter before the securi…
Browse files Browse the repository at this point in the history
…ty hook"

This reverts commit b493af3 which is
commit bbb6d0f upstream.

The "original" commit 905ae01 ("Add a reference to ucounts for each
cred"), should not have been applied to the 5.10.y tree, so revert it,
and the follow-on fixup patches as well.

Reported-by: "Eric W. Biederman" <ebiederm@xmission.com>
Link: https://lore.kernel.org/r/87v93k4bl6.fsf@disp2133
Cc: Alexey Gladkov <legion@kernel.org>
Cc: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
gregkh committed Sep 8, 2021
1 parent 0479b2b commit 0c14438
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions kernel/cred.c
Expand Up @@ -286,11 +286,11 @@ struct cred *prepare_creds(void)
new->security = NULL;
#endif

new->ucounts = get_ucounts(new->ucounts);
if (!new->ucounts)
if (security_prepare_creds(new, old, GFP_KERNEL_ACCOUNT) < 0)
goto error;

if (security_prepare_creds(new, old, GFP_KERNEL_ACCOUNT) < 0)
new->ucounts = get_ucounts(new->ucounts);
if (!new->ucounts)
goto error;

validate_creds(new);
Expand Down Expand Up @@ -753,11 +753,11 @@ struct cred *prepare_kernel_cred(struct task_struct *daemon)
#ifdef CONFIG_SECURITY
new->security = NULL;
#endif
new->ucounts = get_ucounts(new->ucounts);
if (!new->ucounts)
if (security_prepare_creds(new, old, GFP_KERNEL_ACCOUNT) < 0)
goto error;

if (security_prepare_creds(new, old, GFP_KERNEL_ACCOUNT) < 0)
new->ucounts = get_ucounts(new->ucounts);
if (!new->ucounts)
goto error;

put_cred(old);
Expand Down

0 comments on commit 0c14438

Please sign in to comment.