f2fs: fix to avoid accessing uninitialized field of inode page in is_alive()
[ Upstream commit 98194030554cd9b10568a9b58f5a135c7e7cba85 ]
If inode is newly created, inode page may not synchronize with inode cache,
so fields like .i_inline or .i_extra_isize could be wrong, in below call
path, we may access such wrong fields, result in failing to migrate valid
target block.
Thread A Thread B
- f2fs_create
- f2fs_add_link
- f2fs_add_dentry
- f2fs_init_inode_metadata
- f2fs_add_inline_entry
- f2fs_new_inode_page
- f2fs_put_page
: inode page wasn't updated with inode cache
- gc_data_segment
- is_alive
- f2fs_get_node_page
- datablock_addr
- offset_in_addr
: access uninitialized fields
Fixes: 7a2af766af ("f2fs: enhance on-disk inode structure scalability")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
3f225f58d8
commit
f42b8aa313
@@ -572,6 +572,11 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name,
|
|||||||
|
|
||||||
if (inode) {
|
if (inode) {
|
||||||
f2fs_i_pino_write(inode, dir->i_ino);
|
f2fs_i_pino_write(inode, dir->i_ino);
|
||||||
|
|
||||||
|
/* synchronize inode page's data from inode cache */
|
||||||
|
if (is_inode_flag_set(inode, FI_NEW_INODE))
|
||||||
|
f2fs_update_inode(inode, page);
|
||||||
|
|
||||||
f2fs_put_page(page, 1);
|
f2fs_put_page(page, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -578,6 +578,11 @@ int f2fs_add_inline_entry(struct inode *dir, const struct qstr *new_name,
|
|||||||
/* we don't need to mark_inode_dirty now */
|
/* we don't need to mark_inode_dirty now */
|
||||||
if (inode) {
|
if (inode) {
|
||||||
f2fs_i_pino_write(inode, dir->i_ino);
|
f2fs_i_pino_write(inode, dir->i_ino);
|
||||||
|
|
||||||
|
/* synchronize inode page's data from inode cache */
|
||||||
|
if (is_inode_flag_set(inode, FI_NEW_INODE))
|
||||||
|
f2fs_update_inode(inode, page);
|
||||||
|
|
||||||
f2fs_put_page(page, 1);
|
f2fs_put_page(page, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user