linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 0/3] btrfs-progs: fsck: detect obviously invalid metadata backref level
Date: Mon, 17 Jan 2022 10:38:47 +0800	[thread overview]
Message-ID: <20220117023850.40337-1-wqu@suse.com> (raw)

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


             reply	other threads:[~2022-01-17  2:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17  2:38 Qu Wenruo [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220117023850.40337-1-wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).