All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] btrfs-progs: fsck: detect obviously invalid metadata backref level
@ 2022-01-17  2:38 Qu Wenruo
  2022-01-17  2:38 ` [PATCH 1/3] btrfs-progs: check/lowmem: fix crash when METADATA_ITEM has invalid level Qu Wenruo
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Qu Wenruo @ 2022-01-17  2:38 UTC (permalink / raw)
  To: linux-btrfs

There is a report that kernel tree-checker rejects a tree block of
extent tree, as it contains an obvious corrupted level (which is an
obvious bit flip).

But btrfs check, at least original mode, doesn't detect it at all.
While with my crafted image, lowmem mode would just crash due to the
large level value overflowing path->nodes[level].

Lowmem is enhanced to reject such level, and the existing code will
verify the level and report errors.

Original mode is more tricky, as it doesn't have level check at all.
I don't have a good idea to implement full level check at original mode,
so here I just introduced a basic check for tree level and reject it.

Finally introduce a test case for this.

Qu Wenruo (3):
  btrfs-progs: check/lowmem: fix crash when METADATA_ITEM has invalid
    level
  btrfs: check/original: reject bad metadata backref with invalid level
  btrfs-progs: tests/fsck: add test image with invalid metadata backref
    level

 check/main.c                                  |  19 ++++++++++++++++++
 check/mode-lowmem.c                           |  12 ++++++++++-
 .../053-bad-metadata-level/default.img.xz     | Bin 0 -> 2084 bytes
 .../fsck-tests/053-bad-metadata-level/test.sh |  19 ++++++++++++++++++
 4 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 tests/fsck-tests/053-bad-metadata-level/default.img.xz
 create mode 100755 tests/fsck-tests/053-bad-metadata-level/test.sh

-- 
2.34.1


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

end of thread, other threads:[~2022-02-01 17:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-17  2:38 [PATCH 0/3] btrfs-progs: fsck: detect obviously invalid metadata backref level Qu Wenruo
2022-01-17  2:38 ` [PATCH 1/3] btrfs-progs: check/lowmem: fix crash when METADATA_ITEM has invalid level Qu Wenruo
2022-01-17  2:47   ` Su Yue
2022-01-17  2:38 ` [PATCH 2/3] btrfs: check/original: reject bad metadata backref with " Qu Wenruo
2022-01-17  2:48   ` Su Yue
2022-02-01 17:34     ` David Sterba
2022-01-17  2:38 ` [PATCH 3/3] btrfs-progs: tests/fsck: add test image with invalid metadata backref level Qu Wenruo
2022-02-01 17:37 ` [PATCH 0/3] btrfs-progs: fsck: detect obviously " David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.