Offering: HULK hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/8430 -------------------------------- There is a stale data issue caused by merging 9e891675aab8. After the patch was merged, data writeback before punch hole cancellation was canceled. This led to some regions of unwritten extents not being zeroed, ultimately exposing stale data. Fixes: 9e891675aab8 ("ext4: don't write back data before punch hole in nojournal mode") Signed-off-by: Yongjian Sun <sunyongjian1@huawei.com> --- fs/ext4/inode.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 84a09f3e6d49..cc4eeccc0dd7 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -4696,13 +4696,12 @@ int ext4_punch_hole(struct file *file, loff_t offset, loff_t length) ret = ext4_update_disksize_before_punch(inode, offset, length); if (ret) goto out_dio; - - ret = ext4_truncate_page_cache_block_range(inode, - first_block_offset, last_block_offset + 1); - if (ret) - goto out_dio; } + ret = ext4_truncate_page_cache_block_range(inode, offset, offset + length); + if (ret) + goto out_dio; + if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) credits = ext4_writepage_trans_blocks(inode); else -- 2.39.2