Re: [RFC PATCH 1/6] keys: prevent quota overflow and widen quotalen and datalen to 32 bits

From: Eric Biggers

Date: Sat Oct 17 2026 - 01:28:56 EST


On Sat, Oct 17, 2026 at 12:52:59AM +0300, Jarkko Sakkinen wrote:
> @@ -245,6 +245,10 @@ struct key *key_alloc(struct key_type *type, const char *desc,
> }
>
> desclen = strlen(desc);
> + if (desclen >= INT_MAX || type->def_datalen > INT_MAX - desclen - 1) {
> + key = ERR_PTR(-EINVAL);
> + goto error;
> + }
> quotalen = desclen + 1 + type->def_datalen;

This should be tightened further to 'desclen > U16_MAX', since desclen
is assigned to a u16 later in the function.

- Eric