Linux EXT4 FS development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ye Bin" <yebin@huaweicloud.com>, linux-ext4@vger.kernel.org
Cc: tytso@mit.edu
Subject: Re: [PATCH v3 2/2] ext4: protect ext4_acquire_dquot against freezing
Date: Thu, 26 Nov 2026 12:50:02 +0000	[thread overview]
Message-ID: <sashiko-outbox-235531@kernel.org> (raw)
In-Reply-To: <20261126123611.2517017-3-yebin@huaweicloud.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] ext4: s_umount vs SB_FREEZE_FS deadlock in ext4_acquire_dquot()
  via vfs_ustat()
--

commit 5d68ea2752fdd861a0ff07e25a26ec6f31917f7a
Author: Ye Bin <yebin10@huawei.com>

ext4: protect ext4_acquire_dquot against freezing

This commit takes sb_start_intwrite() in ext4_acquire_dquot() when no
transaction is running so that quota acquisition during file open does not
start a transaction on a frozen filesystem.

> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index 880f664d6c04b..af965cab32e7f 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -7168,11 +7168,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 this cause an ABBA deadlock between sb->s_umount and SB_FREEZE_FS when
ustat(2) runs on a frozen filesystem?

Commit "quota: Forbid Q_XGETQUOTA and Q_XGETNEXTQUOTA for frozen filesystem"
blocks quotactl from reaching ext4_acquire_dquot() on a frozen superblock,
but vfs_ustat() also acquires s_umount for reading via user_get_super()
without checking whether the filesystem is frozen:

fs/statfs.c:vfs_ustat() {
	struct super_block *s = user_get_super(dev, false);
	int err;
	if (!s)
		return -EINVAL;

	err = statfs_by_dentry(s->s_root, sbuf);
	drop_super(s);
	return err;
}

When project quota limits are enabled and the root directory inode has
EXT4_INODE_PROJINHERIT set, ext4_statfs() calls ext4_statfs_project() ->
dqget().  Because the root inode is a directory, its project dquot is not
kept attached in i_dquot[PRJQUOTA], so if no other inode holds an active
reference to that project dquot when the filesystem is frozen, dqget()
invokes ext4_acquire_dquot() with no running transaction:

CPU0                              CPU1
----                              ----
                                  freeze_super()
                                    /* freezes at SB_FREEZE_COMPLETE */
vfs_ustat()
  user_get_super()
    down_read(&sb->s_umount)
  ...
  ext4_acquire_dquot()
    sb_start_intwrite(sb)
                                  thaw_super()
                                    super_lock_excl(sb)
                                      down_write(&sb->s_umount)

 *** DEADLOCK ***

CPU0: vfs_ustat() -> statfs_by_dentry() -> ext4_statfs() ->
      ext4_statfs_project() -> dqget() -> ext4_acquire_dquot()
CPU1: thaw_super() -> super_lock_excl()

CPU0 blocks in sb_start_intwrite() waiting for SB_FREEZE_FS while holding
s_umount for reading, and thaw_super() cannot unlock SB_FREEZE_FS until it
acquires s_umount exclusively, leaving the filesystem permanently frozen.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126123611.2517017-1-yebin@huaweicloud.com?part=2

  reply	other threads:[~2026-11-26 12:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 12:36 [PATCH v3 0/2] ext4: protect quota acquisition against filesystem freezing Ye Bin
2026-11-26 12:36 ` [PATCH v3 1/2] quota: Forbid Q_XGETQUOTA and Q_XGETNEXTQUOTA for frozen filesystem Ye Bin
2026-11-26 12:36 ` [PATCH v3 2/2] ext4: protect ext4_acquire_dquot against freezing Ye Bin
2026-11-26 12:50   ` sashiko-bot [this message]
2026-11-26 12:50 ` [PATCH v3 0/2] ext4: protect quota acquisition against filesystem freezing sashiko-bot

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=sashiko-outbox-235531@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tytso@mit.edu \
    --cc=yebin@huaweicloud.com \
    /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