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 7378915E8B; Mon, 30 Dec 2024 15:48:04 +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=1735573684; cv=none; b=ivprJqDP8N7bS/IIrwnvRZxW5LdM3vdKEdh8XRR+LCANYzrZ1KuquEgKBkiUqvW50DmevuEIVq/RwUiT9VJUbJvFMRKTq/Glrd9RfSFspRfKnn3PV8IsLHQqTxPKiudGaHsXjYz8vYhNcjvRJ2QVyt1SipFBBQ3AnkpkqBkWbA0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735573684; c=relaxed/simple; bh=ulstMmyN5wBMevMHM6Le4aeMEAEJCqnPY0RkgB0mYRQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lQ2lX8be/Xc7shz3VKyPTnf2jCXja+zogxDZZx0hi/KWI1+oXJiGax6eNSCp8Raszmjeu5En0+BoMlAfhnz4AOeNJvDz0+VA1GqCO9wp4PUyTX0RjGuLLzew6GItSYgw0RogmRb+uDOLc8IZkwJlWKPsmBPLmvwmFAnsYLGRuAw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=L28HcuaS; 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="L28HcuaS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A46C3C4CED0; Mon, 30 Dec 2024 15:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1735573684; bh=ulstMmyN5wBMevMHM6Le4aeMEAEJCqnPY0RkgB0mYRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L28HcuaS/2XOkFJwrFjeUUiQAHRex6EBnVmTYiii6dXiMsUpkjW767UBKIo/6IH3Q 78eeKLot24AVoLc9qBKom+vItnXhlDst1lKlswbZLJQDueiQiXLWP3LSk0XNwgPxt/ 8HhjUfpaKRNKNEWUQsadOVmEMec1Fvp1gbj3PvUQ= 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.1 57/60] btrfs: sysfs: fix direct super block member reads Date: Mon, 30 Dec 2024 16:43:07 +0100 Message-ID: <20241230154209.445890417@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241230154207.276570972@linuxfoundation.org> References: <20241230154207.276570972@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.1-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 @@ -971,7 +971,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); @@ -981,7 +981,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); @@ -1033,7 +1033,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);