From 0b774edec61d6b0ae73d5188f325a40c100bb5af Mon Sep 17 00:00:00 2001 From: cenhuilin Date: Tue, 2 Jul 2024 10:58:10 +0800 Subject: [PATCH] btrfs-progs: tune: fix the missing close() of filesystem fd --- ...-fix-the-missing-close-of-filesystem.patch | 38 +++++++++++++++++++ btrfs-progs.spec | 6 ++- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 0008-btrfs-progs-tune-fix-the-missing-close-of-filesystem.patch diff --git a/0008-btrfs-progs-tune-fix-the-missing-close-of-filesystem.patch b/0008-btrfs-progs-tune-fix-the-missing-close-of-filesystem.patch new file mode 100644 index 0000000..8afa9ca --- /dev/null +++ b/0008-btrfs-progs-tune-fix-the-missing-close-of-filesystem.patch @@ -0,0 +1,38 @@ +From ace7d241ccf2582e832c4c4a75eb6b638a0f543b Mon Sep 17 00:00:00 2001 +From: Qu Wenruo +Date: Tue, 2 Jul 2024 10:51:55 +0800 +Subject: [PATCH] btrfs-progs: tune: fix the missing close() of filesystem fd + +[BUG] +In "btrfs tune" subcommand, we're using open_ctree_fd(), which +requires passing a valid fd, and the caller is responsible to properly +handling the lifespan of the fd. + +But we just call close_ctree() and btrfs_close_all_devices(), without +closing the fd. + +[FIX] +Just manually close the fd. + +Reviewed-by: Anand Jain +Signed-off-by: Qu Wenruo +Signed-off-by: David Sterba +--- + tune/main.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/tune/main.c b/tune/main.c +index 9dcb559..0fbf37d 100644 +--- a/tune/main.c ++++ b/tune/main.c +@@ -535,6 +535,7 @@ out: + } + close_ctree(root); + btrfs_close_all_devices(); ++ close(fd); + + free_out: + return ret; +-- +2.33.0 + diff --git a/btrfs-progs.spec b/btrfs-progs.spec index 5fb82af..25e6f1f 100644 --- a/btrfs-progs.spec +++ b/btrfs-progs.spec @@ -1,6 +1,6 @@ Name: btrfs-progs Version: 6.6.3 -Release: 8 +Release: 9 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 @@ -13,6 +13,7 @@ Patch0004: 0004-btrfs-progs-scrub-status-only-report-limits-if-at-le.patch Patch0005: 0005-btrfs-progs-fix-freeing-of-device-after-error-in-btr.patch Patch0006: 0006-fix-double-free-on-error-in-read_raid56.patch Patch0007: 0007-btrfs-progs-fi-show-canonicalize-path-when-using-blk.patch +Patch0008: 0008-btrfs-progs-tune-fix-the-missing-close-of-filesystem.patch BuildRequires: python3-devel >= 3.4 BuildRequires: libacl-devel, e2fsprogs-devel, libblkid-devel, libuuid-devel, zlib-devel, libzstd-devel, lzo-devel, systemd-devel @@ -78,6 +79,9 @@ make mandir=%{_mandir} bindir=%{_sbindir} libdir=%{_libdir} incdir=%{_includedir %{_mandir}/man8/*.gz %changelog +* Tue Jul 2 2024 cenhuilin - 6.6.3-9 +- btrfs-progs: tune: fix the missing close() of filesystem fd + * Mon Jul 1 2024 liuh - 6.6.3-8 - btrfs-progs: fi show: canonicalize path when using blkid and -d -- Gitee