linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhang Yi <yi.zhang@huawei.com>
To: <linux-ext4@vger.kernel.org>
Cc: <tytso@mit.edu>, <adilger.kernel@dilger.ca>, <jack@suse.cz>,
	<yi.zhang@huawei.com>
Subject: [PATCH v2] ext4: do not set SB_ACTIVE in ext4_orphan_cleanup()
Date: Wed, 31 Mar 2021 20:09:10 +0800	[thread overview]
Message-ID: <20210331120910.2223493-1-yi.zhang@huawei.com> (raw)

When CONFIG_QUOTA is enabled and if we later fail to finish mounting the
filesystem due to some error after ext4_orphan_cleanup(), we may hit use
after free issues. The problem is that ext4_orphan_cleanup() sets
SB_ACTIVE flag and so inodes processed during the orphan cleanup are put
to the superblock's LRU list instead of being immediately destroyed.
However the path handling error recovery after failed ->fill_super()
call does not destroy inodes attached to the superblock and so they are
left active in memory while the superblock is freed.

Originally, SB_ACTIVE setting was added so that updated quota
information is not destroyed when we drop quota inode references after
orphan cleanup. However VFS does not purge dirty inode pages without
SB_ACTIVE flag for many years already. So just remove the hack with
setting SB_ACTIVE flag from ext4_orphan_cleanup().

Signed-off-by: Zhang Yi <yi.zhang@huawei.com>
Tested-by: Jan Kara <jack@suse.cz>
Reviewed-by: Jan Kara <jack@suse.cz>
---
Changes since v1:
 - Rephrase the changelog as Jan suggested.

 fs/ext4/super.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index b9693680463a..2a33c53b57d8 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3023,9 +3023,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.
-- 
2.25.4


                 reply	other threads:[~2021-03-31 12:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210331120910.2223493-1-yi.zhang@huawei.com \
    --to=yi.zhang@huawei.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).