[PATCH 0/2] btrfs: tree-checker: reject simple quota metadata without SIMPLE_QUOTA
From: Siddharth Mishra
Date: Mon Nov 02 2026 - 22:50:07 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").
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.
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 | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
base-commit: d6f76ca0a70d0c814731394a625ff0dc1feb390e
--
2.54.0