Skip to content

Commit 6c2190b

Browse files
chuckleveramschuma-ntap
authored andcommitted
NFS: Fix listxattr receive buffer size
Certain NFSv4.2/RDMA tests fail with v5.9-rc1. rpcrdma_convert_kvec() runs off the end of the rl_segments array because rq_rcv_buf.tail[0].iov_len holds a very large positive value. The resultant kernel memory corruption is enough to crash the client system. Callers of rpc_prepare_reply_pages() must reserve an extra XDR_UNIT in the maximum decode size for a possible XDR pad of the contents of the xdr_buf's pages. That guarantees the allocated receive buffer will be large enough to accommodate the usual contents plus that XDR pad word. encode_op_hdr() cannot add that extra word. If it does, xdr_inline_pages() underruns the length of the tail iovec. Fixes: 3e1f021 ("NFSv4.2: add client side XDR handling for extended attributes") Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 70438af commit 6c2190b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

fs/nfs/nfs42xdr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196
1 + nfs4_xattr_name_maxsz + 1)
197197
#define decode_setxattr_maxsz (op_decode_hdr_maxsz + decode_change_info_maxsz)
198198
#define encode_listxattrs_maxsz (op_encode_hdr_maxsz + 2 + 1)
199-
#define decode_listxattrs_maxsz (op_decode_hdr_maxsz + 2 + 1 + 1)
199+
#define decode_listxattrs_maxsz (op_decode_hdr_maxsz + 2 + 1 + 1 + 1)
200200
#define encode_removexattr_maxsz (op_encode_hdr_maxsz + 1 + \
201201
nfs4_xattr_name_maxsz)
202202
#define decode_removexattr_maxsz (op_decode_hdr_maxsz + \
@@ -531,7 +531,7 @@ static void encode_listxattrs(struct xdr_stream *xdr,
531531
{
532532
__be32 *p;
533533

534-
encode_op_hdr(xdr, OP_LISTXATTRS, decode_listxattrs_maxsz + 1, hdr);
534+
encode_op_hdr(xdr, OP_LISTXATTRS, decode_listxattrs_maxsz, hdr);
535535

536536
p = reserve_space(xdr, 12);
537537
if (unlikely(!p))

0 commit comments

Comments
 (0)