This is a note to let you know that I've just added the patch titled Revert "ucounts: Increase ucounts reference counter before the security hook" to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: revert-ucounts-increase-ucounts-reference-counter-before-the-security-hook.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 32f7f4c3664c0b30b14a25621d2fabd252df9dc4 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Date: Fri, 3 Sep 2021 16:06:21 +0200 Subject: Revert "ucounts: Increase ucounts reference counter before the security hook" From: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> This reverts commit b493af3a66e067f93e5e03465507866ddeabff9e which is commit bbb6d0f3e1feb43d663af089c7dedb23be6a04fb upstream. The "original" commit 905ae01c4ae2 ("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@xxxxxxxxxxxx> Link: https://lore.kernel.org/r/87v93k4bl6.fsf@disp2133 Cc: Alexey Gladkov <legion@xxxxxxxxxx> Cc: Sasha Levin <sashal@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- kernel/cred.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/kernel/cred.c +++ b/kernel/cred.c @@ -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); @@ -753,11 +753,11 @@ struct cred *prepare_kernel_cred(struct #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); Patches currently in stable-queue which might be from gregkh@xxxxxxxxxxxxxxxxxxx are queue-5.10/ubifs-report-correct-st_size-for-encrypted-symlinks.patch queue-5.10/ext4-fix-race-writing-to-an-inline_data-file-while-its-xattrs-are-changing.patch queue-5.10/revert-cred-add-missing-return-error-code-when-set_cred_ucounts-failed.patch queue-5.10/ext4-report-correct-st_size-for-encrypted-symlinks.patch queue-5.10/revert-add-a-reference-to-ucounts-for-each-cred.patch queue-5.10/fscrypt-add-fscrypt_symlink_getattr-for-computing-st_size.patch queue-5.10/f2fs-report-correct-st_size-for-encrypted-symlinks.patch queue-5.10/revert-ucounts-increase-ucounts-reference-counter-before-the-security-hook.patch