]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
SUNRPC: Fix the calculation of xdr->end in xdr_get_next_encode_buffer()
authorChuck Lever <chuck.lever@oracle.com>
Tue, 7 Jun 2022 20:47:52 +0000 (16:47 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jun 2022 14:52:39 +0000 (16:52 +0200)
commitb419808712fc4fb4edc72cb29cd4d8994a3eacb7
treec9b62f006dcfe8746b53c3a8026a8fddf6e918bb
parent4d0f47dc7df635787a5288478b32486e18e87063
SUNRPC: Fix the calculation of xdr->end in xdr_get_next_encode_buffer()

[ Upstream commit 6c254bf3b637dd4ef4f78eb78c7447419c0161d7 ]

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: 2825a7f90753 ("nfsd4: allow encoding across page boundaries")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: NeilBrown <neilb@suse.de>
Reviewed-by: J. Bruce Fields <bfields@fieldses.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sunrpc/xdr.c