Re: [PATCH v3 2/3] KEYS: Reject @desclen values >= KEY_MAX_DESC_SIZE in key_alloc()
From: Jarkko Sakkinen
Date: Tue Oct 20 2026 - 07:05:28 EST
On Mon, Oct 19, 2026 at 07:28:32PM -0700, Eric Biggers wrote:
> On Tue, Oct 20, 2026 at 04:47:43AM +0300, Jarkko Sakkinen wrote:
> > On Tue, Oct 20, 2026 at 04:38:56AM +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 match the userspace limit. The constraints inherits from the one byte
> > > required for the NULL character.
> > >
> > > Cc: stable@xxxxxxxxxxxxxxx
> > > Assisted-by: LLM
> > > Fixes: f771fde82051 ("keys: Simplify key description management")
> > > Reviewed-by: David Howells <dhowells@xxxxxxxxxx>
> > > Signed-off-by: Jarkko Sakkinen <jarkko@xxxxxxxxxx>
> >
> > This is now the only one, which does not have keyutils script in the
> > commit message so in that sense I think these fixes look pretty good.
>
> Sure, this fix is still incomplete though, as I mentioned.
>
> Turns out Sashiko found this too; see the comment on
> https://sashiko.dev/#/patchset/20261020013903.1244157-1-jarkko%40kernel.org
I did not ignore what you said honestly but I overlooked generated
descriptions.
By comparing your v2 response and Sashiko's response and going through the
code this is the list that I have where similar check should be placed:
- key_alloc(): before quota calculation (in place)
- __key_create_or_update(): before assigning index_key.desc_len
- keyring_search(): before match_preparse
- request_key_and_link(): before match_preparse
- request_key_rcu(): before check_cached_key()
Some sites might require some minor changes I just wrote the around the
ballpark locations.
Did I miss any site that you are aware of?
Because there are so many, despite simple check I also wonder, should
we have a macro for this check?
>
> - Eric
Br, Jarkko