Skip to content

Commit fca432e

Browse files
adam900710kdave
authored andcommitted
btrfs: sysfs: fix direct super block member reads
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: stable@vger.kernel.org Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent f2363e6 commit fca432e

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
@@ -1118,7 +1118,7 @@ static ssize_t btrfs_nodesize_show(struct kobject *kobj,
11181118
{
11191119
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
11201120

1121-
return sysfs_emit(buf, "%u\n", fs_info->super_copy->nodesize);
1121+
return sysfs_emit(buf, "%u\n", fs_info->nodesize);
11221122
}
11231123

11241124
BTRFS_ATTR(, nodesize, btrfs_nodesize_show);
@@ -1128,7 +1128,7 @@ static ssize_t btrfs_sectorsize_show(struct kobject *kobj,
11281128
{
11291129
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
11301130

1131-
return sysfs_emit(buf, "%u\n", fs_info->super_copy->sectorsize);
1131+
return sysfs_emit(buf, "%u\n", fs_info->sectorsize);
11321132
}
11331133

11341134
BTRFS_ATTR(, sectorsize, btrfs_sectorsize_show);
@@ -1180,7 +1180,7 @@ static ssize_t btrfs_clone_alignment_show(struct kobject *kobj,
11801180
{
11811181
struct btrfs_fs_info *fs_info = to_fs_info(kobj);
11821182

1183-
return sysfs_emit(buf, "%u\n", fs_info->super_copy->sectorsize);
1183+
return sysfs_emit(buf, "%u\n", fs_info->sectorsize);
11841184
}
11851185

11861186
BTRFS_ATTR(, clone_alignment, btrfs_clone_alignment_show);

0 commit comments

Comments
 (0)