From: Fanqi Yu <fanqi.yu@columbia.edu>
To: tytso@mit.edu, adilger.kernel@dilger.ca
Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
Fanqi Yu <fanqi.yu@columbia.edu>
Subject: [PATCH] ext4: Prevent successful remount as r/w after filesystem abort
Date: Sun, 15 Sep 2024 17:08:04 -0400 [thread overview]
Message-ID: <20240915210802.3835698-1-fanqi.yu@columbia.edu> (raw)
While the order of writing to the shutdown and read-only flags has been
enforced by a write memory barrier, the read side in remount does not
have a pairing read barrier.
In the event of a fs forced shutdown remounting as read-only,
remounting it again as read-write can succeed when the flag reads are
reordered such that sb_rdonly() returns true and
ext4_forced_shutdown() returns false.
Commit 4418e14112e3 ("ext4: Fix fsync error handling after filesystem
abort") has added the other barriers related to these two flags but
seems to have missed this one.
Signed-off-by: Fanqi Yu <fanqi.yu@columbia.edu>
---
fs/ext4/super.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 044135796f2b..c5d3f8969dec 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -6542,6 +6542,13 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb)
flush_work(&sbi->s_sb_upd_work);
if ((bool)(fc->sb_flags & SB_RDONLY) != sb_rdonly(sb)) {
+
+ /*
+ * Make sure we read the updated s_ext4_flags.
+ * Pairs with smp_wmb() in ext4_handle_error().
+ */
+ smp_rmb();
+
if (ext4_forced_shutdown(sb)) {
err = -EROFS;
goto restore_opts;
--
2.34.1
next reply other threads:[~2024-09-15 21:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-15 21:08 Fanqi Yu [this message]
2024-09-17 12:35 ` [PATCH] ext4: Prevent successful remount as r/w after filesystem abort Jan Kara
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=20240915210802.3835698-1-fanqi.yu@columbia.edu \
--to=fanqi.yu@columbia.edu \
--cc=adilger.kernel@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@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