]> www.infradead.org Git - users/jedix/linux-maple.git/commit
NFSD: Insulate nfsd4_encode_read() from page boundaries in the encode buffer
authorChuck Lever <chuck.lever@oracle.com>
Tue, 31 Dec 2024 00:28:53 +0000 (19:28 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Sat, 11 Jan 2025 04:39:46 +0000 (23:39 -0500)
commit1a861150bd6a69ea14da7a0d752da2b442e6a5dc
treec4d76687756df9a6412870e82167ba01305ff24f
parentef3675b45bcb6c17cabbbde620c6cea52ffb21ac
NFSD: Insulate nfsd4_encode_read() from page boundaries in the encode buffer

Commit 28d5bc468efe ("NFSD: Optimize nfsd4_encode_readv()") replaced
the use of write_bytes_to_xdr_buf() because it's expensive and the
data items to be encoded are already properly aligned.

However, the current code will corrupt the encoded data if the XDR
data items that are reserved early and then poked into the XDR
buffer later happen to fall on a page boundary in the XDR encoding
buffer.

__xdr_commit_encode can shift encoded data items in the encoding
buffer so that pointers returned from xdr_reserve_space() no longer
address the same part of the encoding stream.

This isn't an issue for splice reads because the reserved encode
buffer areas must fall in the XDR buffers header for the splice to
work without error. For vectored reads, however, there is a
possibility of send buffer corruption in rare cases.

Fixes: 28d5bc468efe ("NFSD: Optimize nfsd4_encode_readv()")
Reviewed-by: NeilBrown <neilb@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4xdr.c