Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Lin Ma
Thu, 19 Nov 2026 03:06
[PATCH] net: rxrpc: Validate RxGK security level before allocating context
Author: Lin Ma
Date: Thu, 19 Nov 2026 03:06
Date: Thu, 19 Nov 2026 03:06
60 lines
10464 bytes
10464 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 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
Re: [PATCH] net: rxrpc: Validate RxGK security level before allocating context
Author: Simon Horman
Date: Wed, 25 Nov 2026 14:50
Date: Wed, 25 Nov 2026 14:50
52 lines
9568 bytes
9568 bytes
On Thu, Nov 19, 2026 at 11:06:22AM +0800, Lin Ma wrote:
> 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);
Hi,
I agree this is correct, but if the switch is being moved,
it might be just as well to move it before security_ix and security_level
are set, to avoid any unnecessary work in the error case.
That notwithstanding:
Reviewed-by: Simon Horman <horms@kernel.org>
Re: [PATCH] net: rxrpc: Validate RxGK security level before allocating context
Author: Lin Ma
Date: Sat, 28 Nov 2026 03:11
Date: Sat, 28 Nov 2026 03:11
9 lines
10791 bytes
10791 bytes
Hi Simon, Thanks, that makes sense. I'll move the check before conn->security_ix and conn->security_level are set, so the error path doesn't touch the connection state, and send a v2. Thanks, Lin Ma
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