diff options
author | Christoph Hellwig <hch@lst.de> | 2014-08-21 20:09:17 +0400 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2014-09-10 23:47:01 +0400 |
commit | 2e11f8296d22134c4fca7eb022eea2b09facd307 (patch) | |
tree | f80b3d375c399f31091ebe58d5fb7883dcbc8098 /fs | |
parent | bc7d4b8fd0917b4b84a8911185d34a97c696f219 (diff) | |
download | linux-2e11f8296d22134c4fca7eb022eea2b09facd307.tar.xz |
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: Christoph Hellwig <hch@lst.de>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/pagelist.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index be7cbce6e4c7..94e16ec88312 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -481,6 +481,14 @@ size_t nfs_generic_pg_test(struct nfs_pageio_descriptor *desc, 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); } EXPORT_SYMBOL_GPL(nfs_generic_pg_test); |