Re: [PATCH v2] ext4: clear in-inode xattr space before adding the first xattr

From: Theodore Ts'o

Date: Thu Nov 19 2026 - 09:51:34 EST



On Wed, 21 Oct 2026 16:56:35 +0800, Jiaming Zhang wrote:
> An inode can hold extended attributes in the space that follows its extra
> fields, whose size is given by i_extra_isize. When ext4 loads an inode,
> ext4_iget_extra_inode() validates that space only if it starts with the
> xattr magic, and only then sets EXT4_STATE_XATTR. Without the magic, the
> space is treated as empty and is not checked.
>
> ext4_xattr_ibody_set() passes the space to ext4_xattr_set_entry() whether
> or not EXT4_STATE_XATTR is set. ext4_xattr_set_entry() walks the entries
> there to find min_offs, the lowest value offset. That offset decides
> whether the new value fits and where the value is copied:
>
> [...]

Applied, thanks!

[1/1] ext4: clear in-inode xattr space before adding the first xattr
commit: ab7d0fdc084fa3812613378af181fcc047c81beb

Best regards,
--
Theodore Ts'o <tytso@xxxxxxx>