Skip to content

Commit 459ef4a

Browse files
adam900710gregkh
authored andcommitted
btrfs: sysfs: fix direct super block member reads
commit fca432e73db2bec0fdbfbf6d98d3ebcd5388a977 upstream. The following sysfs entries are reading super block member directly, which can have a different endian and cause wrong values: - sys/fs/btrfs/<uuid>/nodesize - sys/fs/btrfs/<uuid>/sectorsize - sys/fs/btrfs/<uuid>/clone_alignment Thankfully those values (nodesize and sectorsize) are always aligned inside the btrfs_super_block, so it won't trigger unaligned read errors, just endian problems. Fix them by using the native cached members instead. Fixes: df93589 ("btrfs: export more from FS_INFO to sysfs") CC: [email protected] Reviewed-by: Naohiro Aota <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Qu Wenruo <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent bb8e287 commit 459ef4a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/btrfs/sysfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ static ssize_t btrfs_nodesize_show(struct kobject *kobj,
971971
{
972972
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
973973

974-
return sysfs_emit(buf, "%u\n", fs_info->super_copy->nodesize);
974+
return sysfs_emit(buf, "%u\n", fs_info->nodesize);
975975
}
976976

977977
BTRFS_ATTR(, nodesize, btrfs_nodesize_show);
@@ -981,7 +981,7 @@ static ssize_t btrfs_sectorsize_show(struct kobject *kobj,
981981
{
982982
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
983983

984-
return sysfs_emit(buf, "%u\n", fs_info->super_copy->sectorsize);
984+
return sysfs_emit(buf, "%u\n", fs_info->sectorsize);
985985
}
986986

987987
BTRFS_ATTR(, sectorsize, btrfs_sectorsize_show);
@@ -1033,7 +1033,7 @@ static ssize_t btrfs_clone_alignment_show(struct kobject *kobj,
10331033
{
10341034
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
10351035

1036-
return sysfs_emit(buf, "%u\n", fs_info->super_copy->sectorsize);
1036+
return sysfs_emit(buf, "%u\n", fs_info->sectorsize);
10371037
}
10381038

10391039
BTRFS_ATTR(, clone_alignment, btrfs_clone_alignment_show);

0 commit comments

Comments
 (0)