OSDN Git Service

f2fs: fix to avoid accessing uninitialized field of inode page in is_alive()
authorChao Yu <yuchao0@huawei.com>
Tue, 10 Sep 2019 01:14:16 +0000 (09:14 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Jan 2020 13:51:13 +0000 (14:51 +0100)
commitf42b8aa3138cc90fc332f174ff76cd35a81ec385
treee236ca6ed6877b41b45b07ce1e2dfcdb3180cc4c
parent3f225f58d89591eccde789e09589e61fdf2193e3
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: 7a2af766af15 ("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>
fs/f2fs/dir.c
fs/f2fs/inline.c