Skip to content

The extended attributes of an image that says its shared entries are in a metabox it does not have are refused, as the kernel fails their listing - #304

Open
closer-claudio wants to merge 1 commit into
mainfrom
claudio/20261122-shared-ea-metabox
Open

closer-claudio wants to merge 1 commit into
mainfrom
claudio/20261122-shared-ea-metabox

Conversation

@closer-claudio

Copy link
Copy Markdown

The defect

The compat feature SHARED_EA_IN_METABOX says an image's shared extended attribute entries are read through its metabox inode. Open takes no image with a metabox (the incompat feature is refused), so an image it opens with that compat bit set has none.

The reader ignored the bit and served the shared entries it found in the plain xattr area, where the image says they are not. So did the copy of an image, and the reference model the tests judge the reader by.

What the kernel does

Read from the source (v7.4-rc3, fs/erofs/xattr.c, data.c, super.c), not run.

The kernel mounts such an image: nothing refuses the compat bit alone. It then fails the listing of every inode that has an xattr body with EFSCORRUPTED. erofs_listxattr runs the shared pass after the inline one, and erofs_xattr_iter_shared begins with the metabox's buffer, which erofs_init_metabuf refuses when there is no metabox inode, before it looks at the inode's shared count. An inode whose body holds inline entries only fails the same way. An inode with no xattr body, and every file's data, are served as in any other image.

The change

An inode with an xattr body in such an image is ErrCorrupt where its xattrs are read: at Stat, which carries them, and in the copy of an image, which decodes them itself. The reference model refuses the same listing, in the kernel's order: after the inline entries, before the shared ones.

What a consumer sees

For an image with that bit and no metabox:

  • Stat, Lstat and ReadDir's Info of an inode that has an xattr body return ErrCorrupt, where they returned attributes read from the wrong place.
  • An inode with no xattr body is served as before.
  • Reading a file's data needs no Stat and is served as before.
  • CopyFrom of such an image is refused when an inode has a body.

Where this follows the package's shape and not the kernel's: the kernel's stat succeeds for such an inode and only its xattr calls fail; here Stat carries the attributes, so it is Stat that fails. mkfs.erofs sets the bit only together with a metabox, so no image it writes is affected.

Evidence

TestContractSharedXattrsInAMetaboxTheImageDoesNotHave: every committed image without a blob, the bit set and the checksum redone. It opens; each inode that has an xattr body, by the reference model, is ErrCorrupt at Lstat, and each that has none is served; every regular file reads the bytes it read before; a copy, with data and metadata-only, is refused when an inode has a body. Two fuzz seeds already set the bit, and agree with the reference only when both refuse.

TestReaderCompactInodeMtime wrote a fuzzer's whole compat byte, this bit among them, to clear the checksum; it now clears the checksum bit alone.

just lint and just test pass.

For #272

… are refused

The compat feature SHARED_EA_IN_METABOX says an image's shared xattr
entries are read through its metabox inode. Open takes no image with a
metabox (the incompat feature is refused), so an image it opens with
that compat bit set has none.

The kernel mounts such an image, and fails the listing of every inode
that has an xattr body with EFSCORRUPTED: erofs_listxattr runs the
shared pass after the inline one, and erofs_xattr_iter_shared begins
with the metabox's buffer, which erofs_init_metabuf refuses when there
is no metabox inode, before it looks at the inode's shared count
(xattr.c, data.c). An inode with no xattr body, and every file's data,
are served as in any other image.

The reader ignored the bit and served the shared entries it found in
the plain xattr area, where the image says they are not, and so did
the copy of an image and the reference model the tests judge the
reader by.

Now an inode with an xattr body in such an image is ErrCorrupt where
its xattrs are read: at Stat, which carries them, and in the copy of an
image, which decodes them itself. Reading a file's data needs no Stat
and is served. The reference model refuses the same listing, in the
kernel's order: after the inline entries, before the shared ones.

TestContractSharedXattrsInAMetaboxTheImageDoesNotHave: every committed
image without a blob, the bit set and the checksum redone: it opens;
each inode that has an xattr body, by the reference model, is
ErrCorrupt at Lstat, and each that has none is served; every regular
file reads the bytes it read before; a copy, with data and
metadata-only, is refused when an inode has a body. Two fuzz seeds already set the
bit, and agree with the reference only when both refuse.

TestReaderCompactInodeMtime set the whole compat byte to a fuzzer's
value, this bit among them, to clear the checksum; it now clears the
checksum bit alone.

For #272

Signed-off-by: closer-claudio <claudio@farcloser.world>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@closer-claudio

Copy link
Copy Markdown
Author

Reviewed at 7e23fd9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant