mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs: tree-checker: reject simple quota metadata without SIMPLE_QUOTA
@ 2026-11-03  3:49 Siddharth Mishra
  2026-11-03  3:49 ` [PATCH 1/2] btrfs: tree-checker: validate qgroup status item Siddharth Mishra
  2026-11-03  3:49 ` [PATCH 2/2] btrfs: tree-checker: reject extent owner ref without simple quota Siddharth Mishra
  0 siblings, 2 replies; 6+ messages in thread
From: Siddharth Mishra @ 2026-11-03  3:49 UTC (permalink / raw)
  To: David Sterba
  Cc: Qu Wenruo, Boris Burkov, Chris Mason, linux-btrfs, linux-kernel,
	Siddharth Mishra

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-11-03  5:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03  3:49 [PATCH 0/2] btrfs: tree-checker: reject simple quota metadata without SIMPLE_QUOTA Siddharth Mishra
2026-11-03  3:49 ` [PATCH 1/2] btrfs: tree-checker: validate qgroup status item Siddharth Mishra
2026-11-03  4:36   ` Qu Wenruo
2026-11-03  3:49 ` [PATCH 2/2] btrfs: tree-checker: reject extent owner ref without simple quota Siddharth Mishra
2026-11-03  4:40   ` Qu Wenruo
2026-11-03  5:15     ` Siddharth Mishra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®