Skip to content

Commit 2f73f37

Browse files
Jorge Morachucklever
authored andcommitted
NFSD: fix LISTXATTRS returning a short list with eof=TRUE
If the XDR buffer is not large enough to fit all attributes and the remaining bytes left in the XDR buffer (xdrleft) is equal to the number of bytes for the current attribute, then the loop will prematurely exit without setting eof to FALSE. Also in this case, adding the eof flag to the buffer will make the reply 4 bytes larger than lsxa_maxcount. Need to check if there are enough bytes to fit not only the next attribute name but also the eof as well. Fixes: 23e50fe ("nfsd: implement the xattr functions and en/decode logic") Signed-off-by: Jorge Mora <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 61ab5e0 commit 2f73f37

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/nfsd/nfs4xdr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5447,7 +5447,8 @@ nfsd4_encode_listxattrs(struct nfsd4_compoundres *resp, __be32 nfserr,
54475447

54485448
slen -= XATTR_USER_PREFIX_LEN;
54495449
xdrlen = 4 + ((slen + 3) & ~3);
5450-
if (xdrlen > xdrleft) {
5450+
/* Check if both entry and eof can fit in the XDR buffer */
5451+
if (xdrlen + XDR_UNIT > xdrleft) {
54515452
if (count == 0) {
54525453
/*
54535454
* Can't even fit the first attribute name.

0 commit comments

Comments
 (0)