Skip to content

Commit 70b6e85

Browse files
chaseyuJaegeuk Kim
authored andcommitted
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 <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 1773f63 commit 70b6e85

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/f2fs/segment.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3948,8 +3948,14 @@ static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio)
39483948
folio_end_writeback(folio);
39493949
if (f2fs_in_warm_node_list(fio->sbi, folio))
39503950
f2fs_del_fsync_node_entry(fio->sbi, folio);
3951+
f2fs_bug_on(fio->sbi, !is_set_ckpt_flags(fio->sbi,
3952+
CP_ERROR_FLAG));
39513953
goto out;
39523954
}
3955+
3956+
f2fs_bug_on(fio->sbi, !f2fs_is_valid_blkaddr(fio->sbi,
3957+
fio->new_blkaddr, DATA_GENERIC_ENHANCE));
3958+
39533959
if (GET_SEGNO(fio->sbi, fio->old_blkaddr) != NULL_SEGNO)
39543960
f2fs_invalidate_internal_cache(fio->sbi, fio->old_blkaddr, 1);
39553961

0 commit comments

Comments
 (0)