btrfs: make thaw time super block check to also verify checksum
authorQu Wenruo <wqu@suse.com>
Tue, 18 Oct 2022 01:56:38 +0000 (09:56 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Jan 2023 10:59:20 +0000 (11:59 +0100)
commitd4e6a13eb9a3361e2aaa17558687a2bd8b26d97c
treeb9ed942e3f15dd748b2bd9378c392a27ba0c2423
parent70a1dccd0e58155b4e2a2fb738d77c65d32662d3
btrfs: make thaw time super block check to also verify checksum

commit 3d17adea74a56a4965f7a603d8ed8c66bb9356d9 upstream.

Previous commit a05d3c915314 ("btrfs: check superblock to ensure the fs
was not modified at thaw time") only checks the content of the super
block, but it doesn't really check if the on-disk super block has a
matching checksum.

This patch will add the checksum verification to thaw time superblock
verification.

This involves the following extra changes:

- Export btrfs_check_super_csum()
  As we need to call it in super.c.

- Change the argument list of btrfs_check_super_csum()
  Instead of passing a char *, directly pass struct btrfs_super_block *
  pointer.

- Verify that our checksum type didn't change before checking the
  checksum value, like it's done at mount time

Fixes: a05d3c915314 ("btrfs: check superblock to ensure the fs was not modified at thaw time")
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/disk-io.c
fs/btrfs/disk-io.h
fs/btrfs/super.c