diff options
| author | Siddharth Mishra <smish149@asu.edu> | 2026-11-02 23:10:21 -0700 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2026-11-09 18:50:58 +0100 |
| commit | a1250669825f96ecc7045ab1b10cdc3d8832339d (patch) | |
| tree | ee1d5db75dac74058aeba978e51219fc1a9b1c91 /tools/perf/scripts/python | |
| parent | fb6eeb6a4bba0e027cf772859a3455ef5bacceb8 (diff) | |
btrfs: tree-checker: reject extent owner ref without simple quota
[BUG]
An extent item can contain an owner ref. The owner ref is correct only
when the super block has the SIMPLE_QUOTA bit. If the bit is not set,
check_extent_item() gives a WARN_ON() and then accepts the leaf :
case BTRFS_EXTENT_OWNER_REF_KEY:
WARN_ON(!btrfs_fs_incompat(fs_info, SIMPLE_QUOTA));
break;
For all other incorrect inline refs, check_extent_item() returns
-EUCLEAN. After the tree-checker accepts the leaf, a free of the extent
calls btrfs_get_extent_inline_ref_type(). This function ASSERT()s the
SIMPLE_QUOTA bit.
On a kernel with CONFIG_BTRFS_ASSERT=y, a free of such an extent gives :
WARNING: fs/btrfs/tree-checker.c:1782 at __btrfs_check_leaf
assertion failed: btrfs_fs_incompat(fs_info, SIMPLE_QUOTA),
in fs/btrfs/extent-tree.c:354
kernel BUG at fs/btrfs/extent-tree.c:354!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI
RIP: 0010:btrfs_get_extent_inline_ref_type.cold
(fs/btrfs/extent-tree.c:354)
Call Trace:
lookup_inline_extent_backref (fs/btrfs/extent-tree.c:919)
lookup_extent_backref (fs/btrfs/extent-tree.c:1100)
__btrfs_free_extent.isra.0 (fs/btrfs/extent-tree.c:3319)
__btrfs_run_delayed_refs (fs/btrfs/extent-tree.c:2134)
btrfs_run_delayed_refs (fs/btrfs/extent-tree.c:2246)
btrfs_commit_transaction (fs/btrfs/transaction.c:2278)
ksys_sync (fs/sync.c:104)
Without CONFIG_BTRFS_ASSERT, the kernel gives only the WARN_ON(). Then
btrfs continues to use the owner ref.
[CAUSE]
I made a crafted image : an owner ref, no SIMPLE_QUOTA bit, and no quota
tree. I removed the file of the extent. At the next commit, btrfs
frees the extent and gives the BUG above.
For an owner ref without the SIMPLE_QUOTA bit, the tree-checker gives a
WARN_ON() and keeps the leaf. For all other inline ref types, it
rejects the leaf. Two sources can put owner refs without the
SIMPLE_QUOTA bit on a disk : a damaged or crafted image, and a kernel
without commit f2363e6fcc79 ("btrfs: fix transaction atomicity bug when
enabling simple quotas").
[FIX]
Reject the leaf with -EUCLEAN, as for all other incorrect inline refs.
Then btrfs finds the problem when it reads the leaf, and the ASSERT() is
not reached.
Link: https://syzkaller.appspot.com/bug?extid=d7d1fc7e21835ca19219
Link: https://syzkaller.appspot.com/bug?extid=4983e68a6d77180bfe33
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Siddharth Mishra <smish149@asu.edu>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions
