Linux EXT4 FS development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "William Chuang" <founder@logarcheon.com>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH 1/2] ext4: reserve quota credits in swap_inode_boot_loader()
Date: Tue, 17 Nov 2026 06:00:40 +0000	[thread overview]
Message-ID: <sashiko-outbox-218234@kernel.org> (raw)
In-Reply-To: <20261117052750.2955-2-founder@logarcheon.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] ext4: missing inode_bl type check in
  swap_inode_boot_loader() [1]
--

commit bcadebc925a37de0440a70c290c23f8fd547aadb
Author: William Chuang <founder@logarcheon.com>

ext4: reserve quota credits in swap_inode_boot_loader()

This commit reserves quota transaction credits in
swap_inode_boot_loader() to prevent running out of journal credits when
updating quota information during EXT4_IOC_SWAP_BOOT.

> diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
> index e8e579498c990..ae03eb834c7ac 100644
> --- a/fs/ext4/ioctl.c
> +++ b/fs/ext4/ioctl.c
> @@ -425,7 +425,12 @@ static long swap_inode_boot_loader(struct super_block *sb,
>  	truncate_inode_pages(&inode->i_data, 0);
>  	truncate_inode_pages(&inode_bl->i_data, 0);
>  
> -	handle = ext4_journal_start(inode_bl, EXT4_HT_MOVE_EXTENTS, 2);
> +	/*
> +	 * Two inode table blocks, plus one quota block per quota type for
> +	 * the dquot_free_space()/dquot_alloc_space() update below.
> +	 */
> +	handle = ext4_journal_start(inode_bl, EXT4_HT_MOVE_EXTENTS,
> +				    2 + EXT4_MAXQUOTAS_TRANS_BLOCKS(sb));
>  	if (IS_ERR(handle)) {
>  		err = -EINVAL;
>  		goto err_out;

[Severity: Critical]
This problem wasn't introduced by this patch, but can a crafted
filesystem where EXT4_BOOT_LOADER_INO is a directory trigger a warning
and corrupt VFS state in swap_inode_boot_loader() [1]?

fs/ext4/ioctl.c:swap_inode_boot_loader() {
	...
	inode_bl = ext4_iget(sb, EXT4_BOOT_LOADER_INO,
			EXT4_IGET_SPECIAL | EXT4_IGET_BAD);
	if (IS_ERR(inode_bl))
		return PTR_ERR(inode_bl);
	ei_bl = EXT4_I(inode_bl);

	lock_two_nondirectories(inode, inode_bl);
	...
	if (is_bad_inode(inode_bl) || !S_ISREG(inode_bl->i_mode)) {
		...
		inode_bl->i_mode = S_IFREG;
	}
	...
}

inode_bl is passed to lock_two_nondirectories() before its mode is
checked, which triggers WARN_ON_ONCE(S_ISDIR(inode2->i_mode)).  Then the
!S_ISREG() branch overwrites inode_bl->i_mode with S_IFREG instead of
rejecting it, changing the type of a cached directory inode in place.

[1] https://sashiko.dev/#/bug/linux-8cfc8e22-8259-4c89-8a8b-64c16e4481a5

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117052750.2955-1-founder@logarcheon.com?part=1

  reply	other threads:[~2026-11-17  6:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  5:27 [PATCH 0/2] ext4: fix two journal credit shortfalls behind one syzbot report William Chuang
2026-11-17  5:28 ` [PATCH 1/2] ext4: reserve quota credits in swap_inode_boot_loader() William Chuang
2026-11-17  6:00   ` sashiko-bot [this message]
2026-11-17  5:28 ` [PATCH 2/2] ext4: reserve an orphan credit for inline data writes William Chuang
2026-11-17  5:36   ` 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-218234@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=founder@logarcheon.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox