diff --git a/0017-btrfs-progs-fix-the-incorrect-buffer-size-for-super-.patch b/0017-btrfs-progs-fix-the-incorrect-buffer-size-for-super-.patch new file mode 100644 index 0000000000000000000000000000000000000000..9e5ed6c4a04a948284ea82d0c2cf75b355c1d8e1 --- /dev/null +++ b/0017-btrfs-progs-fix-the-incorrect-buffer-size-for-super-.patch @@ -0,0 +1,44 @@ +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 630220a..a0317c4 100644 +--- a/common/device-scan.c ++++ b/common/device-scan.c +@@ -147,7 +147,7 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans, + if (!device) + return -ENOMEM; + +- buf = calloc(1, sectorsize); ++ buf = calloc(1, BTRFS_SUPER_INFO_SIZE); + if (!buf) { + ret = -ENOMEM; + goto out; +-- +2.43.0 + diff --git a/btrfs-progs.spec b/btrfs-progs.spec index d8af3c6ebdc19388a19a6fd36ffbf1f09dcba5b9..04bb2a86837a8e9de481b5294ff8db09d076c230 100644 --- a/btrfs-progs.spec +++ b/btrfs-progs.spec @@ -1,6 +1,6 @@ Name: btrfs-progs Version: 6.6.3 -Release: 17 +Release: 18 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 @@ -22,6 +22,7 @@ Patch0013: 0013-btrfs-progs-corrupt-block-fix-memory-leak-in-debug_c.patch Patch0014: 0014-btrfs-progs-image-fix-the-bug-that-filename-sanitiza.patch Patch0015: 0015-btrfs-progs-convert-fix-the-filename-output-when-rol.patch Patch0016: 0016-btrfs-progs-fix-the-wrong-size-from-device_get_parti.patch +Patch0017: 0017-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 @@ -87,6 +88,10 @@ make mandir=%{_mandir} bindir=%{_sbindir} libdir=%{_libdir} incdir=%{_includedir %{_mandir}/man8/*.gz %changelog +* Fri Oct 17 2025 liuh - 6.6.3-18 +- sync patch from community + btrfs-progs: fix the incorrect buffer size for super block structure + * Fri Aug 29 2025 liuh - 6.6.3-17 - sync patch from community btrfs-progs: fix the wrong size from device_get_partition_size_sysfs()