[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87v91uqksg.fsf_-_@disp2133>
Date: Mon, 18 Oct 2021 12:56:15 -0500
From: ebiederm@...ssion.com (Eric W. Biederman)
To: Alexey Gladkov <legion@...nel.org>
Cc: Rune Kleveland <rune.kleveland@...omedia.dk>,
Yu Zhao <yuzhao@...gle.com>,
Jordan Glover <Golden_Miller83@...tonmail.ch>,
LKML <linux-kernel@...r.kernel.org>, linux-mm@...ck.org,
containers@...ts.linux-foundation.org,
Hillf Danton <hdanton@...a.com>
Subject: [PATCH 2/4] ucounts: Remove unnecessary test for NULL ucount in get_ucounts
All of the callers of get_ucounts are passeds a non-NULL value so stop
handling a NULL ucounts pointer in get_ucounts.
It is guaranteed that ever valid fully formed cred that is passed to
commit_cred contains a non-NULL ucounts pointer. This in turn
gurantees that current_ucounts() never returns NULL.
The call of get_ucounts in user_shm_lock is always passed
current_ucounts().
The call of get_ucounts in mqueue_get_inode is always passed
current_ucounts().
The call of get_ucounts in inc_rlmit_get_ucounts is always
passed iter, after iter has been verified to be non-NULL.
The call of get_ucounts in key_change_session_keyring is always passed
current_ucounts().
The call of get_ucounts in prepare_cred is always passed
current_ucounts().
The call of get_ucounts in prepare_kernel_cred is always
passed task->cred->ucounts or init_cred->ucounts which
being on tasks are guaranteed to have a non-NULL ucounts
field.
Signed-off-by: "Eric W. Biederman" <ebiederm@...ssion.com>
---
kernel/ucount.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/ucount.c b/kernel/ucount.c
index eb03f3c68375..708d05164a7d 100644
--- a/kernel/ucount.c
+++ b/kernel/ucount.c
@@ -152,7 +152,7 @@ static void hlist_add_ucounts(struct ucounts *ucounts)
struct ucounts *get_ucounts(struct ucounts *ucounts)
{
- if (ucounts && atomic_add_negative(1, &ucounts->count)) {
+ if (atomic_add_negative(1, &ucounts->count)) {
put_ucounts(ucounts);
ucounts = NULL;
}
--
2.20.1
Powered by blists - more mailing lists