From: "yebin (H)" <yebin10@huawei.com>
To: Jan Kara <jack@suse.cz>, <linux-ext4@vger.kernel.org>, <tytso@mit.edu>
Subject: Re: [PATCH] ext4: protect ext4_acquire_dquot against freezing
Date: Tue, 24 Nov 2026 11:55:38 +0800 [thread overview]
Message-ID: <6B050ABA.1050808@huawei.com> (raw)
In-Reply-To: <sashiko-outbox-229179@kernel.org>
On 2026/11/23 20:02, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [High] ext4: deadlock with thaw_super() in ext4_acquire_dquot() via
> Q_XGETQUOTA
> --
>
> commit f23e3eb68e6a88d3c8dec26c7efee607385b6388
> Author: Ye Bin <yebin10@huawei.com>
>
> ext4: protect ext4_acquire_dquot against freezing
>
> This commit wraps ext4_acquire_dquot() with sb_start_intwrite() and
> sb_end_intwrite() when no journal transaction is currently active to
> protect quota acquisition against filesystem freezing.
>
> Link: https://patchwork.kernel.org/project/linux-fsdevel/patch/20261112135245.3347102-1-yebin@huaweicloud.com/
>
>> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
>> index 359f9d4ed4479..a06d5f298c849 100644
>> --- a/fs/ext4/super.c
>> +++ b/fs/ext4/super.c
>> @@ -7118,11 +7118,25 @@ static int ext4_acquire_dquot(struct dquot *dquot)
>> {
>> int ret, err;
>> handle_t *handle;
>> + bool freeze_protected = false;
>> +
>> + /*
>> + * Trying to sb_start_intwrite() in a running transaction
>> + * can result in a deadlock. Further, running transactions
>> + * are already protected from freezing.
>> + */
>> + if (!ext4_journal_current_handle()) {
>> + sb_start_intwrite(dquot->dq_sb);
>> + freeze_protected = true;
>> + }
>
> [Severity: High]
> Can calling sb_start_intwrite() here cause an ABBA deadlock between
> sb->s_umount and SB_FREEZE_FS when Q_XGETQUOTA or Q_XGETNEXTQUOTA runs on
> a frozen filesystem?
>
> quotactl_cmd_write() returns 0 for Q_XGETQUOTA and Q_XGETNEXTQUOTA, so
> quotactl_block() and quotactl_fd() acquire down_read(&sb->s_umount)
> without waiting for the filesystem to thaw. If the queried dquot is not
> yet active in memory, dquot_get_dqblk() calls dqget() ->
> ext4_acquire_dquot() with no running transaction and blocks in
> sb_start_intwrite() while holding s_umount:
>
> CPU0 CPU1
> ---- ----
> down_read(&sb->s_umount)
> sb_freeze_unlock(sb, SB_FREEZE_FS)
> sb_start_intwrite(sb)
> down_write(&sb->s_umount)
>
> *** DEADLOCK ***
>
> CPU0: do_quotactl() -> quota_getxquota() -> dquot_get_dqblk() ->
> dqget() -> ext4_acquire_dquot()
> CPU1: thaw_super() -> super_lock_excl() -> thaw_super_locked()
>
> Once this happens, thaw_super() cannot acquire s_umount to unfreeze the
> filesystem, leaving the filesystem permanently wedged.
>
Hi Jan,
Sashiko reported a deadlock with thaw_super() when Q_XGETQUOTA or
Q_XGETNEXTQUOTA runs on a frozen filesystem.
Looking at this, I think the same reasoning as commit ccf370e43e08
("quota: Forbid Q_GETQUOTA and Q_GETNEXTQUOTA for frozen filesystem")
also applies to Q_XGETQUOTA/Q_XGETNEXTQUOTA, since these can likewise
end up in ->acquire_dquot().
So my question is: would it be acceptable to also forbid these two
commands on a frozen filesystem, i.e. add them to quotactl_cmd_write()?
My concern is the resulting behavior change for read-only mounts.
quotactl_fd() would then call mnt_want_write() for these commands, which
returns -EROFS on a read-only mount. So Q_XGETQUOTA on a read-only
mounted filesystem (e.g. via xfs_quota) would change from working to
failing with -EROFS.
Alternatively, I can keep them as read-only commands and only make both
quotactl() and quotactl_fd() wait for the filesystem to thaw without
taking write access, which keeps read-only mount queries working and
only waits while the filesystem is frozen.
Which approach would you prefer?
Thanks,
Ye Bin
prev parent reply other threads:[~2026-11-24 3:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 11:46 [PATCH] ext4: protect ext4_acquire_dquot against freezing Ye Bin
2026-11-23 12:02 ` sashiko-bot
2026-11-24 3:55 ` yebin (H) [this message]
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=6B050ABA.1050808@huawei.com \
--to=yebin10@huawei.com \
--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