RFC SUNRPC: complete verified GSS replies after context expiry
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest1 patch 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/1 | SUNRPC: complete verified GSS replies after context expiryinclude/ include/ include/ +9 more | +551 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC PATCH 0/1] SUNRPC: complete verified GSS replies after context expiry
Hi,
I'd like to request feedback on a client-side RPCSEC_GSS change that allows an outstanding RPC to complete using its original reply after the Kerberos security context has expired.
I encountered this problem with NFSv4.0 over Kerberos. A server can execute a non-idempotent operation successfully, but its reply may be delayed until after the client's GSS context expires. The client then rejects the reply verifier, renews its credentials, and retransmits the request with a new XID. For operations such as RENAME, REMOVE, and MKDIR, the second execution can return ENOENT or EEXIST even though the original operation succeeded. NFSv4.1 and later are largely protected by the session reply cache, but they still renew credentials and retransmit.
The original issue is documented here:
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2173036
The proposed change allows an already-issued RPCSEC_GSS DATA request to complete using its original reply when the reply passes the required verification checks and the request satisfies a bounded context-expiry exception. The main changes are:
* Bind reply verification to the GSS sequence number of the corresponding transmitted request, including integrity- and privacy-protected reply bodies.
* Record when the complete TCP request record was queued, and require that this happened before the Kerberos context expired. Other transports do not record this, so the exception does not apply to them.
* Introduce reply-specific GSS verification callbacks so that Kerberos can explicitly distinguish successful cryptographic verification from context lifetime expiry. The existing strict interfaces keep their behavior.
* Bound the exception using the actual Kerberos end time, REALTIME and BOOTTIME deadlines, and clock-change checks.
* Accept an expired-context reply provisionally at the verifier stage, with final acceptance only after all verification required by the selected security service has completed.
The grace period defaults to 30 seconds, is capped at 120 seconds, and can be disabled with auth_rpcgss.expired_reply_grace=0.
When the original reply satisfies these conditions, the client passes it to the existing RPC result decoder. This preserves the actual NFS result, including NFS errors, without retransmitting the operation. Otherwise, the client keeps its existing credential renewal and retransmission behavior, subject to the normal retry budget. The change does not let new requests use expired contexts, and it does not provide exactly-once semantics when the original reply cannot be accepted. No server-side changes are required.
The patch is based on v7.4-rc3 and also applies cleanly to v7.4-rc4.
Testing
-------
Clients were QEMU/KVM guests running the patched v7.4-rc3 kernel, and servers were guests running an unmodified v7.4-rc3 kernel. The final campaign used 86 client/server VM pairs on 13 hosts and covered NFSv4.0, v4.1, and v4.2 with sec=krb5, krb5i, and krb5p, using RENAME, MKDIR, REMOVE, READ, and WRITE.
A TCP proxy in front of nfsd held the target reply until after context expiry and, in some scenarios, modified it. The scenarios included delayed replies, replies beyond the grace period or with the exception disabled, GSS sequence-number re-encoding, invalid reply bodies, missing, unknown, or error accept statuses, expiry boundaries, clock steps, and original NFS error replies. A test-only kprobe delay was used for the case where the deadline passes between header and body verification.
All 8,670 valid trials matched their expected outcomes:
* 3,600 delayed original replies were accepted without credential renewal or a new XID, including 900 trials in which the request had been re-encoded once or twice with a new GSS sequence number. nfsd executed the operation exactly once in each of these trials.
* 270 original NFS error replies were returned to the application without retransmission.
* 4,800 trials in which the exception was unavailable or the reply could not be accepted followed the existing credential renewal and retransmission behavior.
No unexpected EIO or incorrect acceptance was observed. In 16 trials of the initial campaign, and in one rerun, nfsd closed the connection before the held reply could be delivered, so the injected condition did not occur. These trials were excluded and replaced with valid reruns.
As expected, when the original reply cannot be accepted, NFSv4.0 can still re-execute non-idempotent operations. The patch avoids retransmission only when the original reply can still be verified; it does not change the NFSv4.0 recovery guarantees.
The testing did not cover NFSv3, non-TCP transports, nfsd callbacks, requests queued after context expiry, exhaustion of the credential retry budget, or NFS error replies to READ and WRITE. The refactored Kerberos verify and unwrap helpers are also used by nfsd, but the servers in these tests ran unmodified kernels.
Review feedback
---------------
I would particularly appreciate feedback on:
* Whether a bounded exception for completing an already-issued RPC with a verified reply is appropriate for RPCSEC_GSS.
* Whether reply-specific verification callbacks are a suitable way to keep cryptographic verification separate from context lifetime enforcement.
* Whether keeping the existing credential renewal and retransmission behavior when the original reply cannot be accepted is the right compatibility policy.
Thanks for your time and review.
Junyoung Im
Junyoung Im (1):
SUNRPC: complete verified GSS replies after context expiry
include/linux/sunrpc/auth_gss.h | 10 ++ include/linux/sunrpc/gss_api.h | 38 +++++ include/linux/sunrpc/xprt.h | 44 +++++ net/sunrpc/auth_gss/auth_gss.c | 205 +++++++++++++++++++++--- net/sunrpc/auth_gss/gss_krb5_internal.h | 10 ++ net/sunrpc/auth_gss/gss_krb5_mech.c | 24 +++ net/sunrpc/auth_gss/gss_krb5_unseal.c | 52 ++++-- net/sunrpc/auth_gss/gss_krb5_wrap.c | 53 +++++- net/sunrpc/auth_gss/gss_mech_switch.c | 39 +++++ net/sunrpc/clnt.c | 57 ++++++- net/sunrpc/xprt.c | 58 +++++++ net/sunrpc/xprtsock.c | 1 + 12 files changed, 551 insertions(+), 40 deletions(-)
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
Signature · 1 line
2.34.1