Skip to content

Commit 6c254bf

Browse files
committed
SUNRPC: Fix the calculation of xdr->end in xdr_get_next_encode_buffer()
I found that NFSD's new NFSv3 READDIRPLUS XDR encoder was screwing up right at the end of the page array. xdr_get_next_encode_buffer() does not compute the value of xdr->end correctly: * The check to see if we're on the final available page in xdr->buf needs to account for the space consumed by @nbytes. * The new xdr->end value needs to account for the portion of @nbytes that is to be encoded into the previous buffer. Fixes: 2825a7f ("nfsd4: allow encoding across page boundaries") Signed-off-by: Chuck Lever <[email protected]> Reviewed-by: NeilBrown <[email protected]> Reviewed-by: J. Bruce Fields <[email protected]>
1 parent f012e95 commit 6c254bf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

net/sunrpc/xdr.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,11 @@ static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr,
979979
*/
980980
xdr->p = (void *)p + frag2bytes;
981981
space_left = xdr->buf->buflen - xdr->buf->len;
982-
xdr->end = (void *)p + min_t(int, space_left, PAGE_SIZE);
982+
if (space_left - nbytes >= PAGE_SIZE)
983+
xdr->end = (void *)p + PAGE_SIZE;
984+
else
985+
xdr->end = (void *)p + space_left - frag1bytes;
986+
983987
xdr->buf->page_len += frag2bytes;
984988
xdr->buf->len += nbytes;
985989
return p;

0 commit comments

Comments
 (0)