Linux EXT4 FS development
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@dilger.ca>
To: Deepanshu Kartikey <kartikey406@gmail.com>
Cc: Theodore Ts'o <tytso@mit.edu>, linux-ext4 <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH v2] ext4: validate ea_ino and size in check_xattrs
Date: Tue, 23 Sep 2025 12:04:42 -0600	[thread overview]
Message-ID: <AB6112E6-A3CE-4232-83C6-9099463A7AA4@dilger.ca> (raw)
In-Reply-To: <20250923133245.1091761-1-kartikey406@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1816 bytes --]

On Sep 23, 2025, at 7:32 AM, Deepanshu Kartikey <kartikey406@gmail.com> wrote:
> 
> During xattr block validation, check_xattrs() processes xattr entries
> without validating that entries claiming to use EA inodes have non-zero
> sizes. Corrupted filesystems may contain xattr entries where e_value_size
> is zero but e_value_inum is non-zero, indicating invalid xattr data.
> 
> Add validation in check_xattrs() to detect this corruption pattern early
> and return -EFSCORRUPTED, preventing invalid xattr entries from causing
> issues throughout the ext4 codebase.

This should also have a corresponding check and fix in e2fsck, otherwise
the kernel will fail but there is no way to repair such a filesystem.

Cheers, Andreas

> Suggested-by: Theodore Ts'o <tytso@mit.edu>
> Reported-by: syzbot+4c9d23743a2409b80293@syzkaller.appspotmail.com
> Link: https://syzkaller.appspot.com/bug?extid=4c9d23743a2409b80293
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
> ---
> ---
> Changes in v2:
> - Moved validation from ext4_xattr_move_to_block() to check_xattrs() as suggested by Theodore Ts'o
> - This provides broader coverage and may address other similar syzbot reports
> 
> fs/ext4/xattr.c | 4 ++++
> 1 file changed, 4 insertions(+)
> 
> diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
> index 5a6fe1513fd2..d621e77c8c4d 100644
> --- a/fs/ext4/xattr.c
> +++ b/fs/ext4/xattr.c
> @@ -251,6 +251,10 @@ check_xattrs(struct inode *inode, struct buffer_head *bh,
> 			err_str = "invalid ea_ino";
> 			goto errout;
> 		}
> +		if (ea_ino && !size) {
> +			err_str = "invalid size in ea xattr";
> +			goto errout;
> +		}
> 		if (size > EXT4_XATTR_SIZE_MAX) {
> 			err_str = "e_value size too large";
> 			goto errout;
> --
> 2.43.0
> 


Cheers, Andreas






[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 873 bytes --]

  reply	other threads:[~2025-09-23 18:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-23 13:32 [PATCH v2] ext4: validate ea_ino and size in check_xattrs Deepanshu Kartikey
2025-09-23 18:04 ` Andreas Dilger [this message]
2025-09-26  1:15   ` Theodore Ts'o
     [not found]   ` <CADhLXY5mSwFEXo3BdupqycA-VC96WqKfmqNDq7MYM-_SRFKWxg@mail.gmail.com>
2025-09-26 19:47     ` Andreas Dilger
2025-09-26 21:24       ` Theodore Ts'o
2025-09-26 21:47 ` Theodore Ts'o
  -- strict thread matches above, loose matches on Subject: below --
2025-09-24  1:21 Deepanshu Kartikey

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=AB6112E6-A3CE-4232-83C6-9099463A7AA4@dilger.ca \
    --to=adilger@dilger.ca \
    --cc=kartikey406@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --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