From: shuo chen <1289151713@qq.com>
To: sashiko-reviews@lists.linux.dev
Cc: tytso@mit.edu, linux-ext4@vger.kernel.org
Subject: Re: [PATCH v4] ext4: rewrite ext4_convert_inline_data_nolock to make it safer
Date: Mon, 31 Aug 2026 14:34:58 +0800 [thread overview]
Message-ID: <tencent_8756434A305EF41A89C387860E424A199709@qq.com> (raw)
In-Reply-To: <20260831023455.02F981F000E9@smtp.kernel.org>
On Mon, Aug 31, 2026 at 02:34:54AM +0000, sashiko-bot@kernel.org wrote:
> [Severity: High]
> Does this error path leak a reference to is.iloc.bh?
>
> If kmalloc() for xattr_buf fails, the code jumps to the error label which does
> not call brelse(is.iloc.bh). Since ext4_get_inode_loc() pins a reference
> on is.iloc.bh, could this result in a permanent buffer head reference leak?
Got it.
>
> [Severity: High]
> Does hardcoding the extent length to 1 leak extra allocated blocks?
>
> In ext4_convert_inline_data_nolock(), ext4_mb_new_blocks() may return a
> larger extent due to bigalloc or normalization, passing the total allocated
> blocks as len:
>
> fs/ext4/inline.c:ext4_convert_inline_data_nolock() {
> ...
> newblock = ext4_mb_new_blocks(handle, &ar, &error);
> if (error < 0)
> goto out;
> allocated_block = EXT4_C2B(sbi, ar.len);
> ...
> error = ext4_set_inline_data_block(handle, inode,
> newblock, allocated_block, bh);
> ...
> }
>
> If multiple blocks were allocated, the remaining blocks might be permanently
> leaked since they are marked as used but not mapped to the file.
The remaining blocks are stored in i_prealloc_node.
>
> [Severity: Critical]
> Is it possible this overwrites the error code from ext4_ext_insert_extent()?
>
> If ext4_ext_insert_extent() fails with an error other than -EDQUOT or
> -ENOSPC, execution falls through to the ext4_xattr_ibody_find() call, which
> could succeed (returning 0) and overwrite the failure. This would cause the
> function to proceed to the success path, clearing EXT4_INODE_INLINE_DATA
> without actually inserting the extent, potentially leading to data loss and
> a block leak.
Got it.
>
> [Severity: Critical]
> Does this recovery path miss a call to ext4_mark_iloc_dirty()?
>
> The code restores the inline data into raw_inode->i_block and clears the
> EXT4_INODE_EXTENTS flag, but doesn't mark the inode dirty. Since
> ext4_ext_tree_init() previously dirtied the inode, it might be written to
> disk with an invalid checksum and the EXT4_EXTENTS_FL flag still set in
> raw_inode->i_flags, which could cause metadata corruption.
Got it.
I'll fix these issues and send v5.
prev parent reply other threads:[~2026-08-31 6:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 8:33 [PATCH] Add EXT4_STATE_MAY_INLINE_DATA check in ext4_readdir pipishuo
2026-08-13 8:49 ` sashiko-bot
2026-08-14 1:27 ` shuo chen
2026-08-14 3:31 ` Theodore Tso
2026-08-14 8:40 ` shuo chen
2026-08-14 13:57 ` Theodore Tso
2026-08-15 1:43 ` shuo chen
2026-08-16 15:02 ` [PATCH v2] " shuo chen
2026-08-16 15:16 ` sashiko-bot
2026-08-16 20:05 ` [syzbot ci] " syzbot ci
2026-08-17 3:12 ` [PATCH v2] " Theodore Tso
2026-08-17 8:24 ` shuo chen
2026-08-22 16:26 ` [PATCH] " shuo chen
2026-08-22 16:43 ` sashiko-bot
2026-08-22 16:28 ` [PATCH V3] " shuo chen
2026-08-22 16:45 ` sashiko-bot
2026-08-27 8:50 ` shuo chen
2026-08-31 2:20 ` [PATCH v4] ext4: rewrite ext4_convert_inline_data_nolock to make it safer shuo chen
2026-08-31 2:34 ` sashiko-bot
2026-08-31 6:34 ` shuo chen [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=tencent_8756434A305EF41A89C387860E424A199709@qq.com \
--to=1289151713@qq.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