From: "Theodore Tso" <tytso@mit.edu>
To: sashiko-reviews@lists.linux.dev, linux-ext4@vger.kernel.org
Cc: Zhang Yi <yi.zhang@huaweicloud.com>
Subject: Re: [PATCH v4 9/9] ext4: protect WRITE_ZEROES written extents with orphan list
Date: Wed, 22 Jul 2026 13:07:12 -0400 [thread overview]
Message-ID: <amD3fZPiCKwUqhGd@mit.edu> (raw)
In-Reply-To: <20260714084203.971381F000E9@smtp.kernel.org>
On Tue, Jul 14, 2026 at 08:42:03AM -0500, sashiko-bot@kernel.org wrote:
> > @@ -4701,6 +4729,11 @@ static int ext4_alloc_file_blocks(struct file *file, loff_t offset, loff_t len,
> > pagecache_isize_extended(inode, old_size, epos);
> >
> > return ret ? ret : ret2;
> > +
> > +out:
> > + if (orphan && inode->i_nlink)
> > + ext4_orphan_del(NULL, inode);
>
> [Severity: Critical]
> Does passing a NULL handle to ext4_orphan_del() here corrupt the on-disk
> orphan list?
>
> If ext4_convert_unwritten_extents() fails on the first iteration, epos is 0.
> The code skips starting a new journal handle, jumps to out: and calls
> ext4_orphan_del(NULL, inode).
>
> A NULL handle removes the inode from the in-memory list but leaves it
> permanently linked in the on-disk list. If this inode is later unlinked and
> freed, could this sever the rest of the on-disk orphan list and lead to severe
> filesystem corruption during recovery if the inode is reallocated?
This looks like a valid problem; it's possible to get to this point in
the code:
if (!epos || !new_size)
goto out;
where we've already added the inode to the orphan list, and we will
then leave the inode on the orphan list.
I think we need to fix this by checking to see if orphan == true, and
if so, we need to start a handle, and then call ext4_orphan_del() with
that handle, and stop it afterwards.
Do you agree?
If so, are you OK if I just drop this last patch in the series, and
you can resubmit with the fix?
Thaks,
- Ted
prev parent reply other threads:[~2026-07-22 17:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 8:00 [PATCH v4 0/9] ext4: fix unaligned edge handling in FALLOC_FL_WRITE_ZEROES Zhang Yi
2026-07-14 8:00 ` [PATCH v4 1/9] ext4: use FGP_WRITEBEGIN for tail block zeroing Zhang Yi
2026-07-14 8:00 ` [PATCH v4 2/9] ext4: skip tail block zeroing for inline data files Zhang Yi
2026-07-14 15:09 ` Jan Kara
2026-07-14 8:00 ` [PATCH v4 3/9] ext4: check return value of ext4_get_block() in ext4_load_tail_bh() Zhang Yi
2026-07-14 8:00 ` [PATCH v4 4/9] ext4: move partial block zeroing earlier in ext4_zero_range() Zhang Yi
2026-07-14 8:00 ` [PATCH v4 5/9] ext4: clarify return semantics of ext4_load_tail_bh() Zhang Yi
2026-07-14 8:00 ` [PATCH v4 6/9] ext4: track partial-zero outcome per edge in ext4_zero_partial_blocks() Zhang Yi
2026-07-14 8:00 ` [PATCH v4 7/9] ext4: zero out whole block for clean edges in WRITE_ZEROES Zhang Yi
2026-07-14 8:00 ` [PATCH v4 8/9] ext4: write back partial-zeroed " Zhang Yi
2026-07-14 8:00 ` [PATCH v4 9/9] ext4: protect WRITE_ZEROES written extents with orphan list Zhang Yi
[not found] ` <20260714084203.971381F000E9@smtp.kernel.org>
2026-07-22 17:07 ` Theodore Tso [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=amD3fZPiCKwUqhGd@mit.edu \
--to=tytso@mit.edu \
--cc=linux-ext4@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yi.zhang@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