Skip to content

Commit

Permalink
nfsd: Fixes for nfsd4_encode_read_plus_data()
Browse files Browse the repository at this point in the history
[ Upstream commit 72d7871 ]

Ensure that we encode the data payload + padding, and that we truncate
the preallocated buffer to the actual read size.

Fixes: 528b849 ("NFSD: Add READ_PLUS data support")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Trond Myklebust authored and gregkh committed Jan 27, 2021
1 parent 8478091 commit de82ec8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fs/nfsd/nfs4xdr.c
Expand Up @@ -4632,13 +4632,18 @@ nfsd4_encode_read_plus_data(struct nfsd4_compoundres *resp,
resp->rqstp->rq_vec, read->rd_vlen, maxcount, eof);
if (nfserr)
return nfserr;
xdr_truncate_encode(xdr, starting_len + 16 + xdr_align_size(*maxcount));

tmp = htonl(NFS4_CONTENT_DATA);
write_bytes_to_xdr_buf(xdr->buf, starting_len, &tmp, 4);
tmp64 = cpu_to_be64(read->rd_offset);
write_bytes_to_xdr_buf(xdr->buf, starting_len + 4, &tmp64, 8);
tmp = htonl(*maxcount);
write_bytes_to_xdr_buf(xdr->buf, starting_len + 12, &tmp, 4);

tmp = xdr_zero;
write_bytes_to_xdr_buf(xdr->buf, starting_len + 16 + *maxcount, &tmp,
xdr_pad_size(*maxcount));
return nfs_ok;
}

Expand Down

0 comments on commit de82ec8

Please sign in to comment.