Skip to content

Commit 1caf5f6

Browse files
committed
NFSD: Fix "start of NFS reply" pointer passed to nfsd_cache_update()
The "statp + 1" pointer that is passed to nfsd_cache_update() is supposed to point to the start of the egress NFS Reply header. In fact, it does point there for AUTH_SYS and RPCSEC_GSS_KRB5 requests. But both krb5i and krb5p add fields between the RPC header's accept_stat field and the start of the NFS Reply header. In those cases, "statp + 1" points at the extra fields instead of the Reply. The result is that nfsd_cache_update() caches what looks to the client like garbage. A connection break can occur for a number of reasons, but the most common reason when using krb5i/p is a GSS sequence number window underrun. When an underrun is detected, the server is obliged to drop the RPC and the connection to force a retransmit with a fresh GSS sequence number. The client presents the same XID, it hits in the server's DRC, and the server returns the garbage cache entry. The "statp + 1" argument has been used since the oldest changeset in the kernel history repo, so it has been in nfsd_dispatch() literally since before history began. The problem arose only when the server-side GSS implementation was added twenty years ago. Reviewed-by: Jeff Layton <jlayton@kernel.org> Tested-by: Jeff Layton <jlayton@kernel.org Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 49cecd8 commit 1caf5f6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/nfsd/nfssvc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ int nfsd_dispatch(struct svc_rqst *rqstp)
981981
const struct svc_procedure *proc = rqstp->rq_procinfo;
982982
__be32 *statp = rqstp->rq_accept_statp;
983983
struct nfsd_cacherep *rp;
984+
__be32 *nfs_reply;
984985

985986
/*
986987
* Give the xdr decoder a chance to change this if it wants
@@ -1010,6 +1011,7 @@ int nfsd_dispatch(struct svc_rqst *rqstp)
10101011
goto out_dropit;
10111012
}
10121013

1014+
nfs_reply = xdr_inline_decode(&rqstp->rq_res_stream, 0);
10131015
*statp = proc->pc_func(rqstp);
10141016
if (test_bit(RQ_DROPME, &rqstp->rq_flags))
10151017
goto out_update_drop;
@@ -1023,7 +1025,7 @@ int nfsd_dispatch(struct svc_rqst *rqstp)
10231025
*/
10241026
smp_store_release(&rqstp->rq_status_counter, rqstp->rq_status_counter + 1);
10251027

1026-
nfsd_cache_update(rqstp, rp, rqstp->rq_cachetype, statp + 1);
1028+
nfsd_cache_update(rqstp, rp, rqstp->rq_cachetype, nfs_reply);
10271029
out_cached_reply:
10281030
return 1;
10291031

0 commit comments

Comments
 (0)