From: sashiko-bot@kernel.org
To: guzebing <guzebing1612@gmail.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH] ext4: reject delalloc to nodelalloc before applying remount options
Date: Fri, 14 Aug 2026 05:13:37 +0000 [thread overview]
Message-ID: <20260814051341.4AF3C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260814034855.1573759-1-guzebing1612@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The patch incompletely fixes the TOCTOU vulnerability and resource leaks. Post-apply validations in `__ext4_remount()` still expose transient invalid states during failure paths, and the error path restores options locklessly.
--
--- Patch [1]: [PATCH] ext4: reject delalloc to nodelalloc before applying remount options ---
commit 3e2a754f5c730db5d2d9a5a35cc756e9e8b67276
Author: guzebing <guzebing1612@gmail.com>
ext4: reject delalloc to nodelalloc before applying remount options
This patch rejects switching from delalloc to nodelalloc during remount
prior to applying options. This prevents a race window where concurrent
truncates observe nodelalloc and leak reserved data blocks.
> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index bca0dc87d0b7c..ec21ed1cb6ded 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
[ ... ]
> @@ -6688,13 +6696,6 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb)
> goto restore_opts;
> }
>
> - if ((old_opts.s_mount_opt & EXT4_MOUNT_DELALLOC) &&
> - !test_opt(sb, DELALLOC)) {
> - ext4_msg(sb, KERN_ERR, "can't disable delalloc during remount");
> - err = -EINVAL;
> - goto restore_opts;
> - }
> -
> sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
> (test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0);
[Severity: High]
This is a pre-existing issue, but does this approach leave other mount
options vulnerable to similar transient states and lockless rollbacks?
While this patch successfully addresses the delalloc to nodelalloc
transition by moving the check to ext4_check_opt_consistency(), other
validations in __ext4_remount() are still performed after
ext4_apply_options() has been called.
For example, if a user mounts with nodelalloc and then remounts with
-o delalloc,nombcache, the nombcache check in __ext4_remount() fails
after delalloc has already been applied:
__ext4_remount() {
...
if ((sbi->s_mount_opt ^ old_opts.s_mount_opt) & EXT4_MOUNT_NO_MBCACHE) {
ext4_msg(sb, KERN_ERR, "can't enable nombcache during remount");
err = -EINVAL;
goto restore_opts;
}
...
}
This creates a window where delalloc is transiently true, allowing
concurrent tasks to create an inode with delayed allocation and reserve
data blocks, which could leak when delalloc is rolled back to false.
Furthermore, the rollback at the restore_opts label:
restore_opts:
sbi->s_mount_opt = old_opts.s_mount_opt;
sbi->s_mount_opt2 = old_opts.s_mount_opt2;
restores the mount options without acquiring the s_writepages_rwsem.
Could rolling back options like DIOREAD_NOLOCK or DELALLOC locklessly
cause data races with concurrent writepages operations, potentially
triggering the WARN_ON in ext4_add_complete_io()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260814034855.1573759-1-guzebing1612@gmail.com?part=1
next prev parent reply other threads:[~2026-08-14 5:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 3:48 [PATCH] ext4: reject delalloc to nodelalloc before applying remount options guzebing
2026-08-14 5:13 ` sashiko-bot [this message]
2026-08-14 7:41 ` Ojaswin Mujoo
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=20260814051341.4AF3C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=guzebing1612@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.