From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v2 3/4] btrfs: Add csum type check for btrfs_check_super_valid()
Date: Tue, 24 Apr 2018 12:48:08 +0800 [thread overview]
Message-ID: <20180424044809.29838-4-wqu@suse.com> (raw)
In-Reply-To: <20180424044809.29838-1-wqu@suse.com>
Just like incompat flags check, although we have already done super csum
type check before calling btrfs_check_super_valid(), we can still add
such check for later write time check.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/disk-io.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 3968f7ff8de2..9282a6ac91db 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3985,6 +3985,15 @@ static int btrfs_validate_super(struct btrfs_fs_info *fs_info)
btrfs_err(fs_info, "no valid FS found");
ret = -EINVAL;
}
+ /*
+ * For write time check, as for mount time we have checked csum before
+ * calling btrfs_check_super_valid(), so it must be a corruption
+ */
+ if (btrfs_super_csum_type(sb) >= ARRAY_SIZE(btrfs_csum_sizes)) {
+ btrfs_err(fs_info, "corrupted csum type %u",
+ btrfs_super_csum_type(sb));
+ ret = -EINVAL;
+ }
if (btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP) {
btrfs_err(fs_info, "unrecognized or unsupported super flag: %llu",
btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP);
--
2.17.0
next prev parent reply other threads:[~2018-04-24 4:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-24 4:48 [PATCH v2 0/4] btrfs: Add write time super block validation Qu Wenruo
2018-04-24 4:48 ` [PATCH v2 1/4] btrfs: Rename btrfs_check_super_valid() to btrfs_validate_super() Qu Wenruo
2018-04-24 4:48 ` [PATCH v2 2/4] btrfs: Add incompat flags check for btrfs_check_super_valid() Qu Wenruo
2018-04-24 10:48 ` David Sterba
2018-04-24 11:28 ` Qu Wenruo
2018-04-24 11:30 ` David Sterba
2018-04-24 12:03 ` Qu Wenruo
2018-04-24 4:48 ` Qu Wenruo [this message]
2018-04-24 4:48 ` [PATCH v2 4/4] btrfs: Do super block verification before writing it to disk Qu Wenruo
2018-04-24 13:14 ` David Sterba
2018-05-10 14:43 ` [PATCH v2 0/4] btrfs: Add write time super block validation David Sterba
2018-05-11 2:57 ` Qu Wenruo
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=20180424044809.29838-4-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