Re: [PATCH net] rxrpc: Fix overread of short key descriptions

From: Paolo Abeni

Date: Mon Nov 30 2026 - 13:10:23 EST


On 11/23/26 02:13, Lin Ma wrote:
rxrpc_read() checks whether the key description starts with "afs@" by
calling memcmp() with a length of 4. The description is an arbitrary
NUL-terminated string supplied when the key is created and is only
required to be non-empty, so it can be as short as one character. In
that case memcmp() reads up to two bytes past the end of the
kmemdup()'d description (which is strlen(description) + 1 bytes long).

The result of the comparison is not affected because the NUL terminator
is reached within the first four bytes, and the overread is normally
confined to the slab object, but it is still an out-of-bounds read.

Use str_has_prefix(), which stops at the NUL terminator.

Fixes: ed6dd18b5aceb ("RxRPC: Allow RxRPC keys to be read")
Signed-off-by: Lin Ma <linma@xxxxxxxxxx>
Not 'net' worthy. Possibly not even mailing list worthy, but we
can still take it if David acks it.

/P