stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ucounts: fix counter leak in inc_rlimit_get_ucounts()
@ 2024-10-31  4:56 Andrei Vagin
  2024-10-31  9:50 ` Alexey Gladkov
  2024-10-31 17:38 ` Roman Gushchin
  0 siblings, 2 replies; 5+ messages in thread
From: Andrei Vagin @ 2024-10-31  4:56 UTC (permalink / raw)
  To: Eric W. Biederman, Kees Cook
  Cc: Roman Gushchin, linux-kernel, Andrei Vagin, Alexey Gladkov,
	stable

The inc_rlimit_get_ucounts() increments the specified rlimit counter and
then checks its limit. If the value exceeds the limit, the function
returns an error without decrementing the counter.

Fixes: 15bc01effefe ("ucounts: Fix signal ucount refcounting")
Tested-by: Roman Gushchin <roman.gushchin@linux.dev>
Co-debugged-by: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Kees Cook <kees@kernel.org>
Cc: Andrei Vagin <avagin@google.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Alexey Gladkov <legion@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrei Vagin <avagin@google.com>
---
 kernel/ucount.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/ucount.c b/kernel/ucount.c
index 8c07714ff27d..16c0ea1cb432 100644
--- a/kernel/ucount.c
+++ b/kernel/ucount.c
@@ -328,13 +328,12 @@ long inc_rlimit_get_ucounts(struct ucounts *ucounts, enum rlimit_type type)
 		if (new != 1)
 			continue;
 		if (!get_ucounts(iter))
-			goto dec_unwind;
+			goto unwind;
 	}
 	return ret;
-dec_unwind:
+unwind:
 	dec = atomic_long_sub_return(1, &iter->rlimit[type]);
 	WARN_ON_ONCE(dec < 0);
-unwind:
 	do_dec_rlimit_put_ucounts(ucounts, iter, type);
 	return 0;
 }
-- 
2.47.0.163.g1226f6d8fa-goog


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-10-31 17:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-31  4:56 [PATCH] ucounts: fix counter leak in inc_rlimit_get_ucounts() Andrei Vagin
2024-10-31  9:50 ` Alexey Gladkov
2024-10-31 15:43   ` Andrei Vagin
2024-10-31 16:17     ` Roman Gushchin
2024-10-31 17:38 ` Roman Gushchin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).