Netdev List
 help / color / mirror / Atom feed
* [PATCH] net: rxrpc: Validate RxGK security level before allocating context
@ 2026-11-19  3:06 Lin Ma
  2026-11-25 14:50 ` Simon Horman
  0 siblings, 1 reply; 2+ messages in thread
From: Lin Ma @ 2026-11-19  3:06 UTC (permalink / raw)
  To: David Howells, Marc Dionne; +Cc: netdev, linux-afs

rxgk_init_connection_security() currently stores a generated transport-key
context before validating the token security level.  A rejected level can
therefore leave a context in conn->rxgk.keys[]; a retry overwrites it and
leaks the context and its crypto transforms.  Validate the level first so
failed initialization does not allocate or install a context.

Found by LLM-assisted manual code inspection; not runtime-triggered.
Related upstream fixes include commit 7e1876caa836
("rxrpc: Fix leak of rxgk context in rxgk_verify_response()") and commit
b555912b9b210 ("rxrpc: Fix key parsing memleak").  These analogous fixes
support the allocation-lifetime analysis, but neither covers this path.

Fixes: 9d1d2b59341f ("rxrpc: rxgk: Implement the yfs-rxgk security class (GSSAPI)")
Assisted-by: Codex:GPT-6 <codex@openai.com>
Signed-off-by: Lin Ma <linma@zju.edu.cn>
---
 net/rxrpc/rxgk.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/net/rxrpc/rxgk.c b/net/rxrpc/rxgk.c
index f9f5a2dc62ed..80fc8bea61a2 100644
--- a/net/rxrpc/rxgk.c
+++ b/net/rxrpc/rxgk.c
@@ -242,6 +242,16 @@ static int rxgk_init_connection_security(struct rxrpc_connection *conn,
 	conn->security_ix = token->security_index;
 	conn->security_level = token->rxgk->level;
 
+	switch (conn->security_level) {
+	case RXRPC_SECURITY_PLAIN:
+	case RXRPC_SECURITY_AUTH:
+	case RXRPC_SECURITY_ENCRYPT:
+		break;
+	default:
+		ret = -EKEYREJECTED;
+		goto error;
+	}
+
 	if (rxrpc_conn_is_client(conn)) {
 		conn->rxgk.start_time = ktime_get();
 		do_div(conn->rxgk.start_time, 100);
@@ -254,16 +264,6 @@ static int rxgk_init_connection_security(struct rxrpc_connection *conn,
 	conn->rxgk.enctype = gk->krb5->etype;
 	conn->rxgk.keys[gk->key_number & 3] = gk;
 
-	switch (conn->security_level) {
-	case RXRPC_SECURITY_PLAIN:
-	case RXRPC_SECURITY_AUTH:
-	case RXRPC_SECURITY_ENCRYPT:
-		break;
-	default:
-		ret = -EKEYREJECTED;
-		goto error;
-	}
-
 	ret = 0;
 error:
 	_leave(" = %d", ret);
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-25 14:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19  3:06 [PATCH] net: rxrpc: Validate RxGK security level before allocating context Lin Ma
2026-11-25 14:50 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox