From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF67715E8B; Mon, 30 Dec 2024 15:52:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735573952; cv=none; b=tUY8OFsKGlJ/7yBdSX8DYdE2yptjASfPks+CsZjvcBXSdCdaUpZ43fAd1yFQzCH1WkhuwVhRM4QpwAhsFqmaj+i2q1lAvqQPxRHCSnEFa8khGy4enrAHqyE4CAq747ey5FWLanAukUBukt+5eve1YBGhyaep38+goPkXn5KiPWM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735573952; c=relaxed/simple; bh=ba19d27Vo2N/7n13gFdJzpVsmMj/KjcQWT3+QC3ldag=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lewQItGDljpJx3lhbY3hqIbyW3KpPF9Cku96QOMN/HcQyE4gmzTvMLpC4MOwaynvZxYWYAwYTDfVk6b06E6Bh+o4ed7U2Ix2FDgr8rVeOyMMdvOWQqTl9+U4j8F1g4PpLVn/cvIXJRH6k71p7Q6GWniR1lruFNDmK4lXLEa8D9w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GHS5HD05; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="GHS5HD05" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EA63C4CED0; Mon, 30 Dec 2024 15:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1735573951; bh=ba19d27Vo2N/7n13gFdJzpVsmMj/KjcQWT3+QC3ldag=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GHS5HD05KBhPQ3KA5vc3GmfxYddd5pxhl73OqGe+FZhU+0/tj5n0NU4bSyjT4PViV mMAzPnWqkmUujJXkhwRS/Ipt7KCi7sooFOQZUtmNk3PhUqzvahy9TaCMaL7qaNwYGL gx3L8PMdrbgn3Guj7zzDq6ndIq0x8TYvZGse4UlU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Naohiro Aota , Johannes Thumshirn , Qu Wenruo , David Sterba Subject: [PATCH 6.6 82/86] btrfs: sysfs: fix direct super block member reads Date: Mon, 30 Dec 2024 16:43:30 +0100 Message-ID: <20241230154214.826853777@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241230154211.711515682@linuxfoundation.org> References: <20241230154211.711515682@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Qu Wenruo 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//nodesize - sys/fs/btrfs//sectorsize - sys/fs/btrfs//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 Reviewed-by: Johannes Thumshirn Signed-off-by: Qu Wenruo Reviewed-by: David Sterba Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/sysfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1022,7 +1022,7 @@ static ssize_t btrfs_nodesize_show(struc { struct btrfs_fs_info *fs_info = to_fs_info(kobj); - return sysfs_emit(buf, "%u\n", fs_info->super_copy->nodesize); + return sysfs_emit(buf, "%u\n", fs_info->nodesize); } BTRFS_ATTR(, nodesize, btrfs_nodesize_show); @@ -1032,7 +1032,7 @@ static ssize_t btrfs_sectorsize_show(str { struct btrfs_fs_info *fs_info = to_fs_info(kobj); - return sysfs_emit(buf, "%u\n", fs_info->super_copy->sectorsize); + return sysfs_emit(buf, "%u\n", fs_info->sectorsize); } BTRFS_ATTR(, sectorsize, btrfs_sectorsize_show); @@ -1084,7 +1084,7 @@ static ssize_t btrfs_clone_alignment_sho { struct btrfs_fs_info *fs_info = to_fs_info(kobj); - return sysfs_emit(buf, "%u\n", fs_info->super_copy->sectorsize); + return sysfs_emit(buf, "%u\n", fs_info->sectorsize); } BTRFS_ATTR(, clone_alignment, btrfs_clone_alignment_show);