summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhang Yi <yi.zhang@huawei.com>2021-03-31 11:31:38 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-05-11 14:04:16 +0200
commitc599462ab9c3e8af4a982ec899b3ac47709a2570 (patch)
tree1f7364de7ecb8ef524cfa537e671912829bd0c86
parent9c61387630a54e35b96a90608aafd369ffb86f39 (diff)
downloadlinux-stable-c599462ab9c3e8af4a982ec899b3ac47709a2570.tar.gz
linux-stable-c599462ab9c3e8af4a982ec899b3ac47709a2570.tar.bz2
linux-stable-c599462ab9c3e8af4a982ec899b3ac47709a2570.zip
ext4: do not set SB_ACTIVE in ext4_orphan_cleanup()
commit 72ffb49a7b623c92a37657eda7cc46a06d3e8398 upstream. When CONFIG_QUOTA is enabled, if we failed to mount the filesystem due to some error happens behind ext4_orphan_cleanup(), it will end up triggering a after free issue of super_block. The problem is that ext4_orphan_cleanup() will set SB_ACTIVE flag if CONFIG_QUOTA is enabled, after we cleanup the truncated inodes, the last iput() will put them into the lru list, and these inodes' pages may probably dirty and will be write back by the writeback thread, so it could be raced by freeing super_block in the error path of mount_bdev(). After check the setting of SB_ACTIVE flag in ext4_orphan_cleanup(), it was used to ensure updating the quota file properly, but evict inode and trash data immediately in the last iput does not affect the quotafile, so setting the SB_ACTIVE flag seems not required[1]. Fix this issue by just remove the SB_ACTIVE setting. [1] https://lore.kernel.org/linux-ext4/99cce8ca-e4a0-7301-840f-2ace67c551f3@huawei.com/T/#m04990cfbc4f44592421736b504afcc346b2a7c00 Cc: stable@kernel.org Signed-off-by: Zhang Yi <yi.zhang@huawei.com> Tested-by: Jan Kara <jack@suse.cz> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20210331033138.918975-1-yi.zhang@huawei.com Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/ext4/super.c3
1 files changed, 0 insertions, 3 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 2ecf4594a20d..ae37a3c8fa69 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2675,9 +2675,6 @@ static void ext4_orphan_cleanup(struct super_block *sb,
sb->s_flags &= ~SB_RDONLY;
}
#ifdef CONFIG_QUOTA
- /* Needed for iput() to work correctly and not trash data */
- sb->s_flags |= SB_ACTIVE;
-
/*
* Turn on quotas which were not enabled for read-only mounts if
* filesystem has quota feature, so that they are updated correctly.