diff options
author | Chao Yu <yuchao0@huawei.com> | 2020-02-28 18:08:46 +0800 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2020-03-10 09:18:33 -0700 |
commit | 95978caa138948054e06d00bfc3432b518699f1b (patch) | |
tree | b5a509df3794e8736f54163871943ab44ad5ae13 /fs/f2fs | |
parent | 06c7540fd29ccae351d1a9e0a0a817cb235618bd (diff) | |
download | linux-95978caa138948054e06d00bfc3432b518699f1b.tar.bz2 |
f2fs: fix to avoid use-after-free in f2fs_write_multi_pages()
In compress cluster, if physical block number is less than logic
page number, race condition will cause use-after-free issue as
described below:
- f2fs_write_compressed_pages
- fio.page = cic->rpages[0];
- f2fs_outplace_write_data
- f2fs_compress_write_end_io
- kfree(cic->rpages);
- kfree(cic);
- fio.page = cic->rpages[1];
f2fs_write_multi_pages+0xfd0/0x1a98
f2fs_write_data_pages+0x74c/0xb5c
do_writepages+0x64/0x108
__writeback_single_inode+0xdc/0x4b8
writeback_sb_inodes+0x4d0/0xa68
__writeback_inodes_wb+0x88/0x178
wb_writeback+0x1f0/0x424
wb_workfn+0x2f4/0x574
process_one_work+0x210/0x48c
worker_thread+0x2e8/0x44c
kthread+0x110/0x120
ret_from_fork+0x10/0x18
Fixes: 4c8ff7095bef ("f2fs: support data compression")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/compress.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c index 25bc6154c31c..411d1a5679ac 100644 --- a/fs/f2fs/compress.c +++ b/fs/f2fs/compress.c @@ -848,7 +848,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc, blkaddr = datablock_addr(dn.inode, dn.node_page, dn.ofs_in_node); - fio.page = cic->rpages[i]; + fio.page = cc->rpages[i]; fio.old_blkaddr = blkaddr; /* cluster header */ |