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

From
Eric Biggers <ebiggers@kernel.org>
Date
2026-10-19 19:18:01
Also in
keyrings, lkml, stable
Reply to
Jarkko Sakkinen, 2026-10-19
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
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