diff --git a/0003-btrfs-progs-fix-the-incorrect-buffer-size-for-super.patch b/0003-btrfs-progs-fix-the-incorrect-buffer-size-for-super.patch new file mode 100644 index 0000000000000000000000000000000000000000..66b44415a526bea073fd4fa24c4eb394e4e9e00d --- /dev/null +++ b/0003-btrfs-progs-fix-the-incorrect-buffer-size-for-super.patch @@ -0,0 +1,45 @@ +From 84aa7cc8309533c96d52c442dd4cfb1ab02bbe18 Mon Sep 17 00:00:00 2001 +From: Qu Wenruo +Date: Wed, 26 Feb 2025 14:29:15 +1030 +Subject: [PATCH] btrfs-progs: fix the incorrect buffer size for super +block + structure + +Inside the function btrfs_add_to_fsid(), we allocate a buffer to write +the superblock to disk. + +However the buffer size is based on block size, which can cause two +problems: + +- 2K block size + The block size is too small for the super block, and we will write + beyond the buffer and corrupt the memory. + +- 16/64K block size + The block size will be larger than super block size, this will not + cause any problem but waste some memory. + +Fix the bug by using BTRFS_SUPER_INFO_SIZE as the correct buffer size. + +Signed-off-by: Qu Wenruo +Signed-off-by: David Sterba +--- + common/device-scan.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/common/device-scan.c b/common/device-scan.c +index c0e9167..79263aa 100644 +--- a/common/device-scan.c ++++ b/common/device-scan.c +@@ -131,7 +131,7 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans, + ret = -ENOMEM; + goto out; + } +- buf = calloc(1, sectorsize); ++ buf = calloc(1, BTRFS_SUPER_INFO_SIZE); + if (!buf) { + ret = -ENOMEM; + goto out; +-- +2.33.0 + diff --git a/btrfs-progs.spec b/btrfs-progs.spec index 93fb211dba433bffbe1c2b298c3d42bacb43a179..1205581bd3bd56325486d2568cf83abeba76d524 100644 --- a/btrfs-progs.spec +++ b/btrfs-progs.spec @@ -1,6 +1,6 @@ Name: btrfs-progs Version: 6.0 -Release: 3 +Release: 4 Summary: btrfs userspace programs License: GPLv2 and GPL+ and LGPL-2.1+ and GPL-3.0+ and LGPL-2.1 and MIT URL: https://btrfs.wiki.kernel.org/index.php/Main_Page @@ -8,6 +8,7 @@ Source0: https://www.kernel.org/pub/linux/kernel/people/kdave/%{name}/%{name} Patch0001: 0001-fix-exclusive-op-enqueue-timeout.patch Patch0002: 0002-fix-double-free-on-error-in-read_raid56.patch +Patch0003: 0003-btrfs-progs-fix-the-incorrect-buffer-size-for-super.patch BuildRequires: python3-devel >= 3.4 BuildRequires: libacl-devel, e2fsprogs-devel, libblkid-devel, libuuid-devel, zlib-devel, libzstd-devel, lzo-devel, systemd-devel @@ -73,6 +74,9 @@ make mandir=%{_mandir} bindir=%{_sbindir} libdir=%{_libdir} incdir=%{_includedir %{_mandir}/man8/*.gz %changelog +* Wed Oct 22 2025 wangmian - 6.0-4 +- fix the incorrect buffer size for super + * Tue Jul 2 2024 zhangyaqi - 6.0-3 - fix double free on error in read_raid56()