summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorAnna Schumaker <Anna.Schumaker@Netapp.com>2021-06-09 17:07:29 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-07-20 16:02:18 +0200
commit9a4f77f171f68e5a275c4fabd8d78579af7b4950 (patch)
treec023c7d6e1ed1b9f09061e706f1904956a2c9417 /net
parent7c96a2ee45be41d5a167e6332d202086752c36bb (diff)
downloadlinux-9a4f77f171f68e5a275c4fabd8d78579af7b4950.tar.gz
linux-9a4f77f171f68e5a275c4fabd8d78579af7b4950.tar.bz2
linux-9a4f77f171f68e5a275c4fabd8d78579af7b4950.zip
sunrpc: Avoid a KASAN slab-out-of-bounds bug in xdr_set_page_base()
[ Upstream commit 6d1c0f3d28f98ea2736128ed3e46821496dc3a8c ] This seems to happen fairly easily during READ_PLUS testing on NFS v4.2. I found that we could end up accessing xdr->buf->pages[pgnr] with a pgnr greater than the number of pages in the array. So let's just return early if we're setting base to a point at the end of the page data and let xdr_set_tail_base() handle setting up the buffer pointers instead. Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com> Fixes: 8d86e373b0ef ("SUNRPC: Clean up helpers xdr_set_iov() and xdr_set_page_base()") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/xdr.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 3964ff74ee51..ca10ba2626f2 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -1230,10 +1230,9 @@ static unsigned int xdr_set_page_base(struct xdr_stream *xdr,
void *kaddr;
maxlen = xdr->buf->page_len;
- if (base >= maxlen) {
- base = maxlen;
- maxlen = 0;
- } else
+ if (base >= maxlen)
+ return 0;
+ else
maxlen -= base;
if (len > maxlen)
len = maxlen;