Message ID | 19310b1aee2625da1a90f59c03a8b78fbe21e8f3.1690792823.git.anand.jain@oracle.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | metadata_uuid misc cleanup and fixes part2 | expand |
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
On Mon, Jul 31, 2023 at 07:16:34PM +0800, Anand Jain wrote: > The function btrfs_validate_super() should verify the fsid in the provided > superblock argument. Because, all its callers expects it to do that. > > Such as in the following stack: > > write_all_supers() > sb = fs_info->super_for_commit; > btrfs_validate_write_super(.., sb) > btrfs_validate_super(.., sb, ..) > > scrub_one_super() > btrfs_validate_super(.., sb, ..) > > And > check_dev_super() > btrfs_validate_super(.., sb, ..) > > However, it currently verifies the fs_info::super_copy::fsid instead, > which does not help. > > Fix this using the correct fsid in the superblock argument. > > Signed-off-by: Anand Jain <anand.jain@oracle.com> > --- > fs/btrfs/disk-io.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c > index b4495d4c1533..f2279eb93370 100644 > --- a/fs/btrfs/disk-io.c > +++ b/fs/btrfs/disk-io.c > @@ -2373,11 +2373,10 @@ int btrfs_validate_super(struct btrfs_fs_info *fs_info, > ret = -EINVAL; > } > > - if (memcmp(fs_info->fs_devices->fsid, fs_info->super_copy->fsid, > - BTRFS_FSID_SIZE)) { > + if (memcmp(fs_info->fs_devices->fsid, sb->fsid, BTRFS_FSID_SIZE)) { For memcpy and strcpy please compare it against 0 so it follows the semantics of "is equal" or "is not equal".
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index b4495d4c1533..f2279eb93370 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -2373,11 +2373,10 @@ int btrfs_validate_super(struct btrfs_fs_info *fs_info, ret = -EINVAL; } - if (memcmp(fs_info->fs_devices->fsid, fs_info->super_copy->fsid, - BTRFS_FSID_SIZE)) { + if (memcmp(fs_info->fs_devices->fsid, sb->fsid, BTRFS_FSID_SIZE)) { btrfs_err(fs_info, "superblock fsid doesn't match fsid of fs_devices: %pU != %pU", - fs_info->super_copy->fsid, fs_info->fs_devices->fsid); + sb->fsid, fs_info->fs_devices->fsid); ret = -EINVAL; }
The function btrfs_validate_super() should verify the fsid in the provided superblock argument. Because, all its callers expects it to do that. Such as in the following stack: write_all_supers() sb = fs_info->super_for_commit; btrfs_validate_write_super(.., sb) btrfs_validate_super(.., sb, ..) scrub_one_super() btrfs_validate_super(.., sb, ..) And check_dev_super() btrfs_validate_super(.., sb, ..) However, it currently verifies the fs_info::super_copy::fsid instead, which does not help. Fix this using the correct fsid in the superblock argument. Signed-off-by: Anand Jain <anand.jain@oracle.com> --- fs/btrfs/disk-io.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)