mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
f2fs: do sanity check on fio.new_blkaddr in do_write_page()
F2FS-fs (dm-55): access invalid blkaddr:972878540 Call trace: dump_backtrace+0xec/0x128 show_stack+0x18/0x28 dump_stack_lvl+0x40/0x88 dump_stack+0x18/0x24 __f2fs_is_valid_blkaddr+0x360/0x3b4 f2fs_is_valid_blkaddr+0x10/0x20 f2fs_get_node_info+0x21c/0x60c __write_node_page+0x15c/0x734 f2fs_sync_node_pages+0x4f8/0x700 f2fs_write_checkpoint+0x4a8/0x99c __checkpoint_and_complete_reqs+0x7c/0x20c issue_checkpoint_thread+0x4c/0xd8 kthread+0x11c/0x1b0 ret_from_fork+0x10/0x20 If f2fs_allocate_data_block() fails, we may update nat.blkaddr w/ uninitialized fio.new_blkaddr. - __write_node_folio - f2fs_do_write_node_page - do_write_page - f2fs_allocate_data_block : once it fails, it may not allocate new blkaddr - set_node_addr : update w/ uninitialized fio.new_blkaddr variable I've checked all error paths in f2fs_allocate_data_block(), it should be tagged w/ CP_ERROR_FLAG. In addition, f2fs_allocate_data_block() succeeds, fio.new_blkaddr should be valid. Let's add f2fs_bug_on() to check above two conditions to detect any potential bugs. Signed-off-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
1773f63d10
commit
70b6e85004
1 changed files with 6 additions and 0 deletions
|
@ -3948,8 +3948,14 @@ static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio)
|
|||
folio_end_writeback(folio);
|
||||
if (f2fs_in_warm_node_list(fio->sbi, folio))
|
||||
f2fs_del_fsync_node_entry(fio->sbi, folio);
|
||||
f2fs_bug_on(fio->sbi, !is_set_ckpt_flags(fio->sbi,
|
||||
CP_ERROR_FLAG));
|
||||
goto out;
|
||||
}
|
||||
|
||||
f2fs_bug_on(fio->sbi, !f2fs_is_valid_blkaddr(fio->sbi,
|
||||
fio->new_blkaddr, DATA_GENERIC_ENHANCE));
|
||||
|
||||
if (GET_SEGNO(fio->sbi, fio->old_blkaddr) != NULL_SEGNO)
|
||||
f2fs_invalidate_internal_cache(fio->sbi, fio->old_blkaddr, 1);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue