diff options
author | Linus Torvalds | 2018-12-27 17:07:35 -0800 |
---|---|---|
committer | Linus Torvalds | 2018-12-27 17:07:35 -0800 |
commit | bc77789a491cdc6f47e5bbd1d04ddd283d64658b (patch) | |
tree | 7ee181b42c600a6456be1d337f47ff60f1c955c2 /fs | |
parent | 47a43f2f0ce24bb75e3e4500118000585a3b496a (diff) | |
parent | 3cc31fa65d85610574c0f6a474e89f4c419923d5 (diff) |
Merge tag 'iomap-4.21-merge-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull iomap update from Darrick Wong:
"Fix a memory overflow bug for blocksize < pagesize"
* tag 'iomap-4.21-merge-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
iomap: don't search past page end in iomap_is_partially_uptodate
Diffstat (limited to 'fs')
-rw-r--r-- | fs/iomap.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/fs/iomap.c b/fs/iomap.c index d6bc98ae8d35..ce837d962d47 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -492,16 +492,29 @@ done: } EXPORT_SYMBOL_GPL(iomap_readpages); +/* + * iomap_is_partially_uptodate checks whether blocks within a page are + * uptodate or not. + * + * Returns true if all blocks which correspond to a file portion + * we want to read within the page are uptodate. + */ int iomap_is_partially_uptodate(struct page *page, unsigned long from, unsigned long count) { struct iomap_page *iop = to_iomap_page(page); struct inode *inode = page->mapping->host; - unsigned first = from >> inode->i_blkbits; - unsigned last = (from + count - 1) >> inode->i_blkbits; + unsigned len, first, last; unsigned i; + /* Limit range to one page */ + len = min_t(unsigned, PAGE_SIZE - from, count); + + /* First and last blocks in range within page */ + first = from >> inode->i_blkbits; + last = (from + len - 1) >> inode->i_blkbits; + if (iop) { for (i = first; i <= last; i++) if (!test_bit(i, iop->uptodate)) |