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

From
Jarkko Sakkinen <jarkko@kernel.org>
Date
2026-10-20 00:19:59
Also in
keyrings, lkml, stable
Reply to
Jarkko Sakkinen, 2026-10-19
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:
quoted
On Mon, Oct 19, 2026 at 09:17:22PM +0300, Jarkko Sakkinen wrote:
quoted
@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
Thread (32 messages) 32 messages, 3 authors, last reply 29d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help