diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2019-04-30 08:45:34 -0700 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2019-05-01 07:47:37 -0700 |
commit | 7a77dad7e3be1280456508841ccdd2a091b1906a (patch) | |
tree | 7510729009e7832f994a672e224a1d92aee8326d /fs/iomap.c | |
parent | 26ddb1f4fd884258eeb8a8d7f2d40b163f00fedd (diff) |
iomap: Fix use-after-free error in page_done callback
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: Jan Kara <jack@suse.cz>
Fixes: 63899c6f8851 ("iomap: add a page_done callback")
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/iomap.c')
-rw-r--r-- | fs/iomap.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/iomap.c b/fs/iomap.c index 4380d2c412f4..e6453c1c831e 100644 --- a/fs/iomap.c +++ b/fs/iomap.c @@ -772,6 +772,7 @@ iomap_write_end(struct inode *inode, loff_t pos, unsigned len, __generic_write_end(inode, pos, ret, page); if (iomap->page_done) iomap->page_done(inode, pos, copied, page, iomap); + put_page(page); if (ret < len) iomap_write_failed(inode, pos, len); |