From: Simon Horman <horms@kernel.org>
To: Lin Ma <linma@zju.edu.cn>
Cc: David Howells <dhowells@redhat.com>,
Marc Dionne <marc.dionne@auristor.com>,
netdev@vger.kernel.org, linux-afs@infradead.org
Subject: Re: [PATCH] net: rxrpc: Validate RxGK security level before allocating context
Date: Wed, 25 Nov 2026 14:50:18 +0000 [thread overview]
Message-ID: <20261125145018.GX31322@horms.kernel.org> (raw)
In-Reply-To: <20261119030622.1017012-1-linma@zju.edu.cn>
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>
next prev parent reply other threads:[~2026-11-25 14:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
2026-11-28 3:11 ` 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=20261125145018.GX31322@horms.kernel.org \
--to=horms@kernel.org \
--cc=dhowells@redhat.com \
--cc=linma@zju.edu.cn \
--cc=linux-afs@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.