linux-stable/fs/f2fs
Sunmin Jeong f5bc133ef6 f2fs: truncate page cache before clearing flags when aborting atomic write
[ Upstream commit 74b0ebcbdd ]

In f2fs_do_write_data_page, FI_ATOMIC_FILE flag selects the target inode
between the original inode and COW inode. When aborting atomic write and
writeback occur simultaneously, invalid data can be written to original
inode if the FI_ATOMIC_FILE flag is cleared meanwhile.

To prevent the problem, let's truncate all pages before clearing the flag

Atomic write thread              Writeback thread
  f2fs_abort_atomic_write
    clear_inode_flag(inode, FI_ATOMIC_FILE)
                                  __writeback_single_inode
                                    do_writepages
                                      f2fs_do_write_data_page
                                        - use dn of original inode
    truncate_inode_pages_final

Fixes: 3db1de0e58 ("f2fs: change the current atomic write way")
Cc: stable@vger.kernel.org #v5.19+
Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
Reviewed-by: Yeongjin Gil <youngjin.gil@samsung.com>
Signed-off-by: Sunmin Jeong <s_min.jeong@samsung.com>
Reviewed-by: Daeho Jeong <daehojeong@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-03 15:19:37 +02:00
..
Kconfig f2fs: introduce F2FS_UNFAIR_RWSEM to support unfair rwsem 2022-03-04 09:15:53 -08:00
Makefile
acl.c f2fs: port to vfs{g,u}id_t and associated helpers 2022-10-04 13:31:43 -07:00
acl.h
checkpoint.c f2fs: reduce stack memory cost by using bitfield in struct f2fs_io_info 2024-03-26 18:20:54 -04:00
compress.c f2fs: ro: compress: fix to avoid caching unaligned extent 2024-03-26 18:20:56 -04:00
data.c f2fs: compress: fix to avoid inconsistence bewteen i_blocks and dnode 2024-03-26 18:20:54 -04:00
debug.c f2fs: refactor extent_cache to support for read and more 2023-05-17 11:53:52 +02:00
dir.c f2fs: convert to use bitmap API 2024-01-10 17:10:30 +01:00
extent_cache.c f2fs: inode: fix to do sanity check on extent cache correctly 2023-05-17 11:53:59 +02:00
f2fs.h f2fs: mark inode dirty for FI_ATOMIC_COMMITTED flag 2024-04-03 15:19:37 +02:00
file.c f2fs: compress: fix reserve_cblocks counting error when out of space 2024-03-26 18:20:56 -04:00
gc.c f2fs: delete obsolete FI_FIRST_BLOCK_WRITTEN 2024-03-26 18:20:54 -04:00
gc.h f2fs: Fix system crash due to lack of free space in LFS 2023-05-24 17:32:38 +01:00
hash.c f2fs: don't use casefolded comparison for "." and ".." 2022-05-17 11:19:23 -07:00
inline.c f2fs: avoid false alarm of circular locking 2023-09-19 12:28:05 +02:00
inode.c f2fs: introduce get_dnode_addr() to clean up codes 2024-03-26 18:20:54 -04:00
iostat.c f2fs: fix to avoid potential memory corruption in __update_iostat_latency() 2023-03-11 13:55:21 +01:00
iostat.h f2fs: iostat: support accounting compressed IO 2022-08-29 21:15:51 -07:00
namei.c f2fs: fix to avoid dirent corruption 2024-01-25 15:27:32 -08:00
node.c f2fs: ro: compress: fix to avoid caching unaligned extent 2024-03-26 18:20:56 -04:00
node.h f2fs: convert to use bitmap API 2024-01-10 17:10:30 +01:00
recovery.c f2fs: fix to avoid potential panic during recovery 2024-03-26 18:20:55 -04:00
segment.c f2fs: truncate page cache before clearing flags when aborting atomic write 2024-04-03 15:19:37 +02:00
segment.h f2fs: check number of blocks in a current section 2024-03-26 18:20:56 -04:00
shrinker.c f2fs: refactor extent_cache to support for read and more 2023-05-17 11:53:52 +02:00
super.c f2fs: compress: fix to check zstd compress level correctly in mount option 2024-03-26 18:20:55 -04:00
sysfs.c f2fs: convert to use bitmap API 2024-01-10 17:10:30 +01:00
verity.c fs: f2fs: initialize fsdata in pagecache_write() 2023-03-11 13:55:18 +01:00
xattr.c f2fs: fix to check return value of f2fs_recover_xattr_data 2024-01-25 15:27:36 -08:00
xattr.h