From: shuo chen <1289151713@qq.com>
To: sashiko-reviews@lists.linux.dev
Cc: tytso@mit.edu, linux-ext4@vger.kernel.org
Subject: Re: [PATCH v5] ext4: rewrite ext4_convert_inline_data_nolock to make it safer
Date: Wed, 2 Sep 2026 20:24:06 +0800 [thread overview]
Message-ID: <tencent_93CC3232AC6A9418BCE4372286770F91850A@qq.com> (raw)
In-Reply-To: <20260902102416.6FDE61F00A3D@smtp.kernel.org>
On Wed, Sep 02, 2026 at 10:24:16AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
>
> [Severity: High]
> Does initializing .not_found to 0 set up a false positive match instead of
> the expected -ENODATA?
>
> If a filesystem image is mounted where a file has EXT4_INODE_INLINE_DATA
> set but lacks the EXT4_STATE_XATTR flag, ext4_xattr_ibody_find() will exit
> early without modifying is.s.not_found.
>
> Because it was initialized to 0 (meaning 'found'), later in this function:
>
> error = ext4_xattr_ibody_find(inode, &i, &is);
> if (error)
> goto recovery;
> if (!is.s.not_found)
> error = ext4_xattr_ibody_set(handle, inode, &i, &is);
>
> The code believes a valid xattr entry exists at is.s.here (which points to
> uninitialized space). This causes ext4_xattr_ibody_set() to attempt to
> delete a bogus entry, potentially leading to out-of-bounds memory
> operations and a kernel panic.
Got it.
>
> [ ... ]
> > + struct ext4_extent newex;
> > +
> > + newex.ee_block = cpu_to_le32(0);
> > + newex.ee_len = cpu_to_le16(1);
> > + ext4_ext_store_pblock(&newex, block);
> > + path = ext4_ext_insert_extent(handle, inode, path, &newex, 0);
> > + if (IS_ERR(path)) {
> > + error = PTR_ERR(path);
> > + if (error == -EDQUOT || error == -ENOSPC)
> > + goto recovery;
> > + } else {
> > + ext4_free_ext_path(path);
> > + }
>
> [Severity: Critical]
> Does this restricted error check silently swallow fatal failure codes
> (like -ENOMEM or -EIO) from ext4_ext_insert_extent()?
>
> If ext4_ext_insert_extent() fails due to memory pressure or I/O error, the
> restricted check allows the failure to fall through.
>
> The unhandled error code is then overwritten shortly after:
>
> error = ext4_xattr_ibody_find(inode, &i, &is);
>
> This completely masks the prior failure, causing the function to complete
> successfully. The inline data flag is cleared, but the newly allocated
> block is never added to the file's extent tree, permanently losing the
> file's data and leaking the block.
Got it.I will make the inode revert to inline data when the error is
neither EDQUOT nor ENOSPC,but it will not free the blocks.
If the error is neither EDQUOT nor ENOSPC,freeing blocks here could
lead to a more severe error.See the patch
"avoid infinite loops caused by residual data"
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/tencent_FBF9C69AF090A1BF9003C68555A8928D1707@qq.com?part=1
prev parent reply other threads:[~2026-09-02 12:24 UTC|newest]
Thread overview: 23+ 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
2026-09-02 10:10 ` [PATCH v5] " shuo chen
2026-09-02 10:24 ` sashiko-bot
2026-09-02 12:24 ` 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_93CC3232AC6A9418BCE4372286770F91850A@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