Skip to content

Commit

Permalink
knfsd: Allow NFSv2/3 WRITE calls to succeed when krb5i etc is used.
Browse files Browse the repository at this point in the history
When RPCSEC/GSS and krb5i is used, requests are padded, typically to a multiple
of 8 bytes.  This can make the request look slightly longer than it
really is.

As of

	f34b956 "The NFSv2/NFSv3 server does not handle zero
		length WRITE request correctly",

the xdr decode routines for NFSv2 and NFSv3 reject requests that aren't
the right length, so krb5i (for example) WRITE requests can get lost.

This patch relaxes the appropriate test and enhances the related comment.

Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Cc: Peter Staubach <staubach@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
NeilBrown authored and Linus Torvalds committed Jan 13, 2008
1 parent 84427ea commit ba67a39
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion fs/nfsd/nfs3xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,11 @@ nfs3svc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p,
* Round the length of the data which was specified up to
* the next multiple of XDR units and then compare that
* against the length which was actually received.
* Note that when RPCSEC/GSS (for example) is used, the
* data buffer can be padded so dlen might be larger
* than required. It must never be smaller.
*/
if (dlen != XDR_QUADLEN(len)*4)
if (dlen < XDR_QUADLEN(len)*4)
return 0;

if (args->count > max_blocksize) {
Expand Down
5 changes: 4 additions & 1 deletion fs/nfsd/nfsxdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,11 @@ nfssvc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p,
* Round the length of the data which was specified up to
* the next multiple of XDR units and then compare that
* against the length which was actually received.
* Note that when RPCSEC/GSS (for example) is used, the
* data buffer can be padded so dlen might be larger
* than required. It must never be smaller.
*/
if (dlen != XDR_QUADLEN(len)*4)
if (dlen < XDR_QUADLEN(len)*4)
return 0;

rqstp->rq_vec[0].iov_base = (void*)p;
Expand Down

0 comments on commit ba67a39

Please sign in to comment.