提交 3fe39e24 编写于 作者: A Andreas Gruenbacher 提交者: Caspar Zhang

iomap: Fix use-after-free error in page_done callback

commit 7a77dad7e3be1280456508841ccdd2a091b1906a upstream

In iomap_write_end, we're not holding a page reference anymore when
calling the page_done callback, but the callback needs that reference to
access the page.  To fix that, move the put_page call in
__generic_write_end into the callers of __generic_write_end.  Then, in
iomap_write_end, put the page after calling the page_done callback.
Reported-by: NJan Kara <jack@suse.cz>
Fixes: 63899c6f ("iomap: add a page_done callback")
Signed-off-by: NHui Zhu <teawaterz@linux.alibaba.com>
Signed-off-by: NAndreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: NJan Kara <jack@suse.cz>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Reviewed-by: NDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
上级 b6179dc8
......@@ -2104,7 +2104,6 @@ void __generic_write_end(struct inode *inode, loff_t pos, unsigned copied,
}
unlock_page(page);
put_page(page);
if (old_size < pos)
pagecache_isize_extended(inode, old_size, pos);
......@@ -2160,6 +2159,7 @@ int generic_write_end(struct file *file, struct address_space *mapping,
{
copied = block_write_end(file, mapping, pos, len, copied, page, fsdata);
__generic_write_end(mapping->host, pos, copied, page);
put_page(page);
return copied;
}
EXPORT_SYMBOL(generic_write_end);
......
......@@ -778,6 +778,7 @@ iomap_write_end(struct inode *inode, loff_t pos, unsigned len,
if (iomap->page_done)
iomap->page_done(inode, pos, copied, page, iomap);
put_page(page);
if (ret < len)
iomap_write_failed(inode, pos, len);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册