Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2e11f829 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Trond Myklebust
Browse files

nfs: cap request size to fit a kmalloced page array



pNFS servers may return arbitrarily large layouts.  Trim back the I/O size
to one that we can at least allocate the page array for.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent bc7d4b8f
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -481,6 +481,14 @@ size_t nfs_generic_pg_test(struct nfs_pageio_descriptor *desc,
		return 0;
		return 0;
	}
	}


	/*
	 * Limit the request size so that we can still allocate a page array
	 * for it without upsetting the slab allocator.
	 */
	if (((desc->pg_count + req->wb_bytes) >> PAGE_SHIFT) *
			sizeof(struct page) > PAGE_SIZE)
		return 0;

	return min(desc->pg_bsize - desc->pg_count, (size_t)req->wb_bytes);
	return min(desc->pg_bsize - desc->pg_count, (size_t)req->wb_bytes);
}
}
EXPORT_SYMBOL_GPL(nfs_generic_pg_test);
EXPORT_SYMBOL_GPL(nfs_generic_pg_test);