[PATCH v2 0/2] btrfs: tree-checker: reject simple quota metadata without SIMPLE_QUOTA
From: Siddharth Mishra
Date: Tue Nov 03 2026 - 01:13:05 EST
Simple quotas put two types of metadata on the disk : the status item
with SIMPLE_MODE, and the owner ref in an extent item. These two types
are correct only when the super block has the SIMPLE_QUOTA bit. Several
functions ASSERT() this rule. The tree-checker does not enforce it :
- The tree-checker does not examine the status item. A status item
with SIMPLE_MODE and no SIMPLE_QUOTA bit causes a BUG at mount, in
qgroup_read_enable_gen(). Patch 1 adds a check.
- For an owner ref without the SIMPLE_QUOTA bit, check_extent_item()
gives a WARN_ON() and accepts the leaf. When btrfs frees the extent,
btrfs_get_extent_inline_ref_type() causes a BUG. Patch 2 rejects the
leaf. syzbot found both symptoms in 2024, without a reproducer.
Two sources can put these states on a disk : a damaged or crafted
image, and a power failure just after simple quotas were enabled on a
kernel without commit f2363e6fcc79 ("btrfs: fix transaction atomicity
bug when enabling simple quotas").
Found by fuzzing. An AI tool helped with the analysis and the patches.
I reproduced both problems with crafted images on for-next. With the
patches, the tree-checker rejects the bad leaf. With patch 1, btrfs
then mounts the filesystem without quotas. With patch 2, the mount
fails. A clean simple quota filesystem still mounts, writes data, frees
extents and mounts again. The fstests group qgroup has no new failure.
Changelog:
v2:
- Remove the paragraph about fuzzing and testing from the commit
messages
- Remove the Fixes: tags; keep the stable tag, because kernels without
f2363e6fcc79 can write this state
- Patch 1: add a tree dump of the status item, remove the code comments
- Patch 2: move the crafted image from [BUG] to [CAUSE]
v1: https://lore.kernel.org/linux-btrfs/20261103034932.1790235-1-smish149@xxxxxxx/
Siddharth Mishra (2):
btrfs: tree-checker: validate qgroup status item
btrfs: tree-checker: reject extent owner ref without simple quota
fs/btrfs/tree-checker.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
base-commit: d6f76ca0a70d0c814731394a625ff0dc1feb390e
--
2.54.0