diff mbox series

[v2,2/2] SUNRPC: Check if the buffer has fewer bytes than requested

Message ID 20201208202925.597663-3-Anna.Schumaker@Netapp.com (mailing list archive)
State New
Headers show
Series Fixes for READ_PLUS | expand

Commit Message

Anna Schumaker Dec. 8, 2020, 8:29 p.m. UTC
From: Anna Schumaker <Anna.Schumaker@Netapp.com>

xdr_expand_hole() might truncate data off the end of the buffer. If that
happens, we need to return a short read to the NFS code to indicate that
some data has been lost.

Fixes: e6ac0accb27c "SUNRPC: Add an xdr_align_data() function"
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
 net/sunrpc/xdr.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series


diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 5b848fe65c81..68f470e33427 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -1273,6 +1273,8 @@  uint64_t xdr_align_data(struct xdr_stream *xdr, uint64_t offset, uint32_t length
 	bytes = xdr->nwords << 2;
 	if (length < bytes)
 		bytes = length;
+	if (bytes < length)
+		length = bytes;
 	/* Move page data to the left */
 	if (from > offset) {