Re: [PATCH v2 2/6] KEYS: Reject @desclen values >= KEY_MAX_DESC_SIZE in key_alloc()

From: Jarkko Sakkinen

Date: Mon Oct 19 2026 - 20:21:06 EST


On Mon, Oct 19, 2026 at 11:46:58PM +0300, Jarkko Sakkinen wrote:
> On Mon, Oct 19, 2026 at 12:17:59PM -0700, Eric Biggers wrote:
> > On Mon, Oct 19, 2026 at 09:17:22PM +0300, Jarkko Sakkinen wrote:
> > > @desclen in key_alloc() is saved to the 16-bit wide desc_len field in
> > > struct keyring_index_key.
> > >
> > > Reject @desclen values at or above KEY_MAX_DESC_SIZE with -EINVAL in
> > > order to account for the NUL terminator and prevent integer overflow.
> >
> > This should say something like: "in order to match the userspace limit
> > and avoid u16 truncation".
> >
> > There are also similar truncations of desc_len to u16 in
> > key_create_or_update() and keyring_search().
>
> Ack.

Please correct if I'm wrong but I think these don't need anything
special given that both are capped by strndup().

Br, Jarkko