Skip to content

Commit 1ce3620

Browse files
adam900710gregkh
authored andcommitted
btrfs: sysfs: fix direct super block member reads
commit fca432e 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 6e1a822 commit 1ce3620

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
@@ -1022,7 +1022,7 @@ static ssize_t btrfs_nodesize_show(struct kobject *kobj,
10221022
{
10231023
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
10241024

1025-
return sysfs_emit(buf, "%u\n", fs_info->super_copy->nodesize);
1025+
return sysfs_emit(buf, "%u\n", fs_info->nodesize);
10261026
}
10271027

10281028
BTRFS_ATTR(, nodesize, btrfs_nodesize_show);
@@ -1032,7 +1032,7 @@ static ssize_t btrfs_sectorsize_show(struct kobject *kobj,
10321032
{
10331033
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
10341034

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

10381038
BTRFS_ATTR(, sectorsize, btrfs_sectorsize_show);
@@ -1084,7 +1084,7 @@ static ssize_t btrfs_clone_alignment_show(struct kobject *kobj,
10841084
{
10851085
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
10861086

1087-
return sysfs_emit(buf, "%u\n", fs_info->super_copy->sectorsize);
1087+
return sysfs_emit(buf, "%u\n", fs_info->sectorsize);
10881088
}
10891089

10901090
BTRFS_ATTR(, clone_alignment, btrfs_clone_alignment_show);

0 commit comments

Comments
 (0)