Re: [PATCH v2 2/6] KEYS: Reject @desclen values >= KEY_MAX_DESC_SIZE in key_alloc()
From: Eric Biggers
Date: Mon Oct 19 2026 - 15:18:40 EST
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().
> +#define KEY_MAX_DESC_SIZE 4096
Could use a comment mentioning that it includes the trailing NUL.
- Eric