[PATCH v2 5/6] KEYS: Reject @datalen values over INT_MAX

Jarkko Sakkinen jarkko at kernel.org
Mon Oct 19 18:17:25 UTC 2026


Protect quota from overflowing by rejecting @datalen values that
surpass over INT_MAX.

Cc: stable at vger.kernel.org
Assisted-by: LLM
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reviewed-by: David Howells <dhowells at redhat.com>
Signed-off-by: Jarkko Sakkinen <jarkko at kernel.org>
---
 security/keys/key.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/security/keys/key.c b/security/keys/key.c
index dbf5626a48b7..fbd608634bde 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -384,6 +384,9 @@ int key_payload_reserve(struct key *key, size_t datalen)
 
 	key_check(key);
 
+	if (datalen > INT_MAX)
+		return -EINVAL;
+
 	/* contemplate the quota adjustment */
 	if (delta != 0 && test_bit(KEY_FLAG_IN_QUOTA, &key->flags)) {
 		unsigned maxbytes = uid_eq(key->user->uid, GLOBAL_ROOT_UID) ?
-- 
2.47.3




More information about the Linux-security-module-archive mailing list