]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: sysfs: fix direct super block member reads
authorQu Wenruo <wqu@suse.com>
Wed, 18 Dec 2024 06:30:56 +0000 (17:00 +1030)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 2 Jan 2025 09:30:55 +0000 (10:30 +0100)
commit459ef4a242b06ae12b1e70828b6224b2d159d5cc
treeec228aafef788210f4b800e9a35705e55126753e
parentbb8e287f596b62fac18ed84cc03a9f1752f6b3b8
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: df93589a1737 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/sysfs.c