[RFC PATCH 6/8] KEYS: Prevent overflow of user->qnbytes in key_alloc()
Jarkko Sakkinen
jarkko at kernel.org
Mon Oct 19 14:25:06 UTC 2026
Add the missing check rejecting resulting byte counts above INT_MAX.
Cc: stable at vger.kernel.org
Assisted-by: LLM
Fixes: 7e047ef5fe2d ("[PATCH] keys: sort out key quota system")
Signed-off-by: Jarkko Sakkinen <jarkko at kernel.org>
---
security/keys/key.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/security/keys/key.c b/security/keys/key.c
index 18043251365f..5afc16425daf 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -263,7 +263,8 @@ struct key *key_alloc(struct key_type *type, const char *desc,
key_quota_root_maxbytes : key_quota_maxbytes;
spin_lock_irqsave(&user->lock, irqflags);
- if (user->qnkeys == INT_MAX)
+ if (user->qnkeys == INT_MAX ||
+ quotalen > INT_MAX - user->qnbytes)
goto no_quota;
if (!(flags & KEY_ALLOC_QUOTA_OVERRUN)) {
--
2.47.3
More information about the Linux-security-module-archive
mailing list