[PATCH net v2] rxrpc: Fix RxGK server to reject an expired ticket

From: Andrew Stellman

Date: Fri Nov 20 2026 - 16:45:07 EST


rxgk_yfs_decode_ticket() decodes the ticket in a RESPONSE and builds a
key from it. Nothing checks the ticket's expiration time before the
connection is set up, so a client holding a token whose ticket has
expired can still open a connection and have its calls delivered to the
service. Section 6.3 of draft-wilkinson-afs3-rxgk-afs-08 says servers
must reject connections secured with an expired token, and rxkad
already rejects an expired ticket in rxkad_decrypt_ticket().

Compare the ticket's end time with the current time before the key is
built, and abort the connection with RXGK_EXPIRED if the ticket has
expired. The key's expiry can't be used for this. An end time less than
one second from 1970 is truncated to 0 in key->expiry, which means no
expiry. An end time one second or more before 1970 makes building the
key fail with -EKEYEXPIRED, and rxgk_extract_token() drops the RESPONSE
without aborting.

A ticket that expires while a connection is open is not handled here.
As with rxkad, the server keeps accepting calls on that connection but
can't send replies.

Reproduced on v7.4-rc3 under QEMU with the in-kernel rxperf server and a
small userspace client. The client's token has an end time in the
future, because the client won't use an expired token, but the ticket
inside it (encrypted with rxperf's test server key) has expired. Without
the patch, a ticket that expired 30 days ago gets a connection and
rxperf reads the whole request. Only its reply fails, with -EKEYEXPIRED.
Tickets with an end time half a second before or after the start of 1970
also get a connection, and their replies succeed. A ticket with an end
time a day before 1970 gets no abort, and the client times out. With the
patch all four are aborted with RXGK_EXPIRED and no request data reaches
rxperf. A token with an unexpired ticket works either way. No other
kernel changes, debug code or error injection were used. There is no
rxrpc selftest.

The issue was found by Claude Opus 5.5 running Quality Playbook, an
LLM-driven code review tool:
https://github.com/andrewstellman/quality-playbook
The fix and this changelog were drafted with the same tool and reviewed
by me.

Fixes: 9d1d2b59341f ("rxrpc: rxgk: Implement the yfs-rxgk security class (GSSAPI)")
Signed-off-by: Andrew Stellman <astellman@xxxxxxxxxxxxxxxxxxx>
---
v2: Check the ticket's end time directly instead of calling
key_validate() on the new key, which missed end times before or near
1970 (Sashiko).
v1: https://lore.kernel.org/netdev/20261119184541.26343-1-astellman@xxxxxxxxxxxxxxxxxxx/

A reproducer is available on request.

David, this takes enum rxrpc_abort_reason to 128 entries. Your pending
"rxrpc: Fix packet encryption error handling" adds one more, so with
both it has 129. In a small test, clang treats a __mode(byte) enum as
signed and warns that the 129th value wraps to -128. I can reuse an
existing reason instead if you prefer.

include/trace/events/rxrpc.h | 1 +
net/rxrpc/rxgk_app.c | 11 +++++++++++
2 files changed, 12 insertions(+)

diff --git a/include/trace/events/rxrpc.h b/include/trace/events/rxrpc.h
index 56dc9b614071..684034c67c69 100644
--- a/include/trace/events/rxrpc.h
+++ b/include/trace/events/rxrpc.h
@@ -97,6 +97,7 @@
EM(rxgk_abort_resp_short_yfs_key, "rxgk-resp-short-yfs-key") \
EM(rxgk_abort_resp_short_yfs_tkt, "rxgk-resp-short-yfs-tkt") \
EM(rxgk_abort_resp_tok_dec, "rxgk-resp-tok-dec") \
+ EM(rxgk_abort_resp_tok_expired, "rxgk-resp-tok-expired") \
EM(rxgk_abort_resp_tok_internal_error, "rxgk-resp-tok-int-err") \
EM(rxgk_abort_resp_tok_keyerr, "rxgk-resp-tok-keyerr") \
EM(rxgk_abort_resp_tok_nokey, "rxgk-resp-tok-nokey") \
diff --git a/net/rxrpc/rxgk_app.c b/net/rxrpc/rxgk_app.c
index 200a30064fae..93ee8b84316f 100644
--- a/net/rxrpc/rxgk_app.c
+++ b/net/rxrpc/rxgk_app.c
@@ -47,6 +47,7 @@ int rxgk_yfs_decode_ticket(struct rxrpc_connection *conn, struct sk_buff *skb,
const struct cred *cred = current_cred(); // TODO - use socket creds
struct key *key;
size_t pre_ticket_len, payload_len;
+ s64 endtime, now;
unsigned int klen, enctype;
void *payload, *ticket;
__be32 *t, *p, *q, *tmp;
@@ -96,6 +97,16 @@ int rxgk_yfs_decode_ticket(struct rxrpc_connection *conn, struct sk_buff *skb,
* the ticket.
*/
t = ticket + sizeof(__be32) * 2 + xdr_round_up(klen);
+
+ /* Reject an expired ticket. An end time of 0 means no expiry. */
+ endtime = (s64)((u64)ntohl(t[5]) << 32 | ntohl(t[6]));
+ now = div_s64(ktime_get_real_ns(), 100);
+ if (endtime != 0 && endtime <= now) {
+ ret = rxrpc_abort_conn(conn, skb, RXGK_EXPIRED, -EKEYEXPIRED,
+ rxgk_abort_resp_tok_expired);
+ goto error;
+ }
+
q = payload + 5 * sizeof(__be32);
q[0] = htonl(RXRPC_SECURITY_YFS_RXGK);
q[1] = t[1]; /* begintime - msw */
--
2.43.0