linux-stable/fs/ext4
Jan Kara c9fc93e7a9 ext4: do not zeroout extents beyond i_disksize
commit 801674f34e upstream.

We do not want to create initialized extents beyond end of file because
for e2fsck it is impossible to distinguish them from a case of corrupted
file size / extent tree and so it complains like:

Inode 12, i_size is 147456, should be 163840.  Fix? no

Code in ext4_ext_convert_to_initialized() and
ext4_split_convert_extents() try to make sure it does not create
initialized extents beyond inode size however they check against
inode->i_size which is wrong. They should instead check against
EXT4_I(inode)->i_disksize which is the current inode size on disk.
That's what e2fsck is going to see in case of crash before all dirty
data is written. This bug manifests as generic/456 test failure (with
recent enough fstests where fsx got fixed to properly pass
FALLOC_KEEP_SIZE_FL flags to the kernel) when run with dioread_lock
mount option.

CC: stable@vger.kernel.org
Fixes: 21ca087a38 ("ext4: Do not zero out uninitialized extents beyond i_size")
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Link: https://lore.kernel.org/r/20200331105016.8674-1-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-21 09:03:10 +02:00
..
acl.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
acl.h ext4: fix up remaining files with SPDX cleanups 2017-12-17 22:00:59 -05:00
balloc.c ext4: fix potential race between online resizing and write operations 2020-02-28 16:38:57 +01:00
bitmap.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
block_validity.c ext4: add cond_resched() to ext4_protect_reserved_inode 2020-02-19 19:51:55 +01:00
dir.c ext4: fix checksum errors with indexed dirs 2020-02-19 19:51:55 +01:00
ext4.h ext4: fix race between writepages and enabling EXT4_EXTENTS_FL 2020-02-28 16:38:57 +01:00
ext4_extents.h ext4: verify the depth of extent tree in ext4_find_extent() 2018-06-14 12:55:10 -04:00
ext4_jbd2.c ext4: shutdown should not prevent get_write_access 2018-02-18 22:07:36 -05:00
ext4_jbd2.h ext4: use jbd2_inode dirty range scoping 2019-07-28 08:29:29 +02:00
extents.c ext4: do not zeroout extents beyond i_disksize 2020-04-21 09:03:10 +02:00
extents_status.c ext4: remove NULL check before calling kmem_cache_destroy() 2018-05-20 22:44:13 -04:00
extents_status.h ext4: fix up remaining files with SPDX cleanups 2017-12-17 22:00:59 -05:00
file.c ext4: fix ext4_dax_read/write inode locking sequence for IOCB_NOWAIT 2020-02-24 08:34:35 +01:00
fsmap.c ext4: make function ‘ext4_getfsmap_find_fixed_metadata’ static 2018-05-10 11:50:04 -04:00
fsmap.h ext4: fix up remaining files with SPDX cleanups 2017-12-17 22:00:59 -05:00
fsync.c Revert "ext4: use ext4_write_inode() when fsyncing w/o a journal" 2019-02-15 08:10:13 +01:00
hash.c ext4: fix up remaining files with SPDX cleanups 2017-12-17 22:00:59 -05:00
ialloc.c ext4: fix potential race between s_flex_groups online resizing and access 2020-02-28 16:38:57 +01:00
indirect.c ext4: cleanup bh release code in ext4_ind_remove_space() 2019-04-05 22:32:55 +02:00
inline.c ext4: set error return correctly when ext4_htree_store_dirent fails 2020-01-27 14:51:03 +01:00
inode.c ext4: fix a data race at inode->i_blocks 2020-04-17 10:48:51 +02:00
ioctl.c ext4: disallow files with EXT4_JOURNAL_DATA_FL from EXT4_IOC_SWAP_BOOT 2019-11-06 13:05:37 +01:00
Kconfig fs/*/Kconfig: drop links to 404-compliant http://acl.bestbits.at 2018-01-01 12:45:37 -07:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mballoc.c ext4: fix potential race between s_flex_groups online resizing and access 2020-02-28 16:38:57 +01:00
mballoc.h ext4: fix up remaining files with SPDX cleanups 2017-12-17 22:00:59 -05:00
migrate.c ext4: fix race between writepages and enabling EXT4_EXTENTS_FL 2020-02-28 16:38:57 +01:00
mmp.c ext4: don't assume that mmp_nodename/bdevname have NUL 2020-02-19 19:51:55 +01:00
move_extent.c ext4: use jbd2_inode dirty range scoping 2019-07-28 08:29:29 +02:00
namei.c ext4: add cond_resched() to __ext4_find_entry() 2020-02-28 16:38:56 +01:00
page-io.c ext4: fix deadlock allocating crypto bounce page from mempool 2020-02-11 04:34:16 -08:00
readpage.c ext4: readpages() should submit IO as read-ahead 2018-08-17 16:20:29 -07:00
resize.c ext4: fix potential race between s_flex_groups online resizing and access 2020-02-28 16:38:57 +01:00
super.c ext4: fix incorrect inodes per group in error message 2020-04-21 09:03:07 +02:00
symlink.c ext4: switch to fscrypt_get_symlink() 2018-01-11 22:10:40 -05:00
sysfs.c for-4.19/block-20180812 2018-08-14 10:23:25 -07:00
truncate.h ext4: handle layout changes to pinned DAX mappings 2018-07-29 17:00:22 -04:00
xattr.c ext4: ignore e_value_offs for xattrs with value-in-ea-inode 2019-05-22 07:37:42 +02:00
xattr.h ext4: add extra checks to ext4_xattr_block_get() 2018-03-30 20:04:11 -04:00
xattr_security.c ext4: use XATTR_CREATE in ext4_initxattrs() 2018-05-10 11:52:14 -04:00
xattr_trusted.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xattr_user.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00