[RFC PATCH 5/8] KEYS: Prevent overflow of quota in key_alloc()
Jarkko Sakkinen
jarkko at kernel.org
Mon Oct 19 14:25:05 UTC 2026
Check that the calculated quota length does not go over 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 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/security/keys/key.c b/security/keys/key.c
index 30f8a8dea206..18043251365f 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -245,7 +245,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
}
desclen = strlen(desc);
- if (desclen > U16_MAX)
+ if (desclen > U16_MAX || type->def_datalen > INT_MAX - desclen - 1)
goto error;
quotalen = desclen + 1 + type->def_datalen;
--
2.47.3
More information about the Linux-security-module-archive
mailing list