🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by Lin Ma Sat, 28 Nov 2026 03:11
[PATCH v2] net: rxrpc: Validate RxGK security level before allocating context
#23788
Author: Lin Ma
Date: Sat, 28 Nov 2026 03:11
65 lines
12761 bytes
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 before
setting conn->security_ix/conn->security_level or allocating 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>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Lin Ma <linma@zju.edu.cn>
---
v2: Move the security-level check before conn->security_ix and
    conn->security_level are set, so the error path doesn't modify the
    connection state, as suggested by Simon Horman.

Link: https://lore.kernel.org/all/20261119030622.1017012-1-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 77a67ace1d24..a1165ac39566 100644
--- a/net/rxrpc/rxgk.c
+++ b/net/rxrpc/rxgk.c
@@ -239,6 +239,16 @@ static int rxgk_init_connection_security(struct rxrpc_connection *conn,
 	_enter("{%d,%u},{%x}",
 	       conn->debug_id, conn->rxgk.key_number, key_serial(conn->key));
 
+	switch (token->rxgk->level) {
+	case RXRPC_SECURITY_PLAIN:
+	case RXRPC_SECURITY_AUTH:
+	case RXRPC_SECURITY_ENCRYPT:
+		break;
+	default:
+		ret = -EKEYREJECTED;
+		goto error;
+	}
+
 	conn->security_ix = token->security_index;
 	conn->security_level = token->rxgk->level;
 
@@ -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);
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads