From: Lin Ma <linma@zju.edu.cn>
To: David Howells <dhowells@redhat.com>,
Marc Dionne <marc.dionne@auristor.com>
Cc: netdev@vger.kernel.org, linux-afs@lists.infradead.org,
linux-kernel@vger.kernel.org, Lin Ma <linma@zju.edu.cn>
Subject: [PATCH net] rxrpc: Fix overread of short key descriptions
Date: Mon, 23 Nov 2026 09:13:02 +0800 [thread overview]
Message-ID: <20261123011302.4032262-1-linma@zju.edu.cn> (raw)
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@zju.edu.cn>
---
net/rxrpc/key.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c
index cbd26da44951..019e512aeb1f 100644
--- a/net/rxrpc/key.c
+++ b/net/rxrpc/key.c
@@ -746,7 +746,7 @@ static long rxrpc_read(const struct key *key,
_enter("");
/* we don't know what form we should return non-AFS keys in */
- if (memcmp(key->description, "afs@", 4) != 0)
+ if (!str_has_prefix(key->description, "afs@"))
return -EOPNOTSUPP;
cnlen = strlen(key->description + 4);
next reply other threads:[~2026-11-23 1:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 1:13 Lin Ma [this message]
2026-11-23 1:18 ` netdev-bot+sinfo
2026-11-23 2:12 ` Lin Ma
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123011302.4032262-1-linma@zju.edu.cn \
--to=linma@zju.edu.cn \
--cc=dhowells@redhat.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.dionne@auristor.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®