From a14252edd74287f10aaf3682bfe95f56ffde64eb Mon Sep 17 00:00:00 2001 From: yangyun Date: Sat, 30 Mar 2024 15:18:54 +0800 Subject: [PATCH] fix file leak in high level api --- 0010-Fix-file-leak-in-high-level-API.patch | 43 ++++++++++++++++++++++ fuse3.spec | 6 ++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 0010-Fix-file-leak-in-high-level-API.patch diff --git a/0010-Fix-file-leak-in-high-level-API.patch b/0010-Fix-file-leak-in-high-level-API.patch new file mode 100644 index 0000000..4c61f04 --- /dev/null +++ b/0010-Fix-file-leak-in-high-level-API.patch @@ -0,0 +1,43 @@ +From 4b6148831a9e36cb2ca3ba4920cf2def6fe8a3c0 Mon Sep 17 00:00:00 2001 +From: Peri +Date: Thu, 11 May 2023 02:38:46 +0100 +Subject: [PATCH] Fix file leak in high level API + +Added a secondary check in fuse_lib_unlink() after hide_node() +to check again under a lock if the (now hidden) file is still open. +If not then delete it. + +This should synchronise fuse_lib_unlink() with fuse_lib_release(), +when nullpath_ok is set. +--- + lib/fuse.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/lib/fuse.c b/lib/fuse.c +index 1c0627e..44e4857 100755 +--- a/lib/fuse.c ++++ b/lib/fuse.c +@@ -3014,6 +3014,20 @@ static void fuse_lib_unlink(fuse_req_t req, fuse_ino_t parent, + fuse_prepare_interrupt(f, req, &d); + if (!f->conf.hard_remove && is_open(f, parent, name)) { + err = hide_node(f, path, parent, name); ++ if (!err) { ++ /* we have hidden the node so now check again under a lock in case it is not used any more */ ++ if (!is_open(f, parent, wnode->name)) { ++ char *unlinkpath; ++ ++ /* get the hidden file path, to unlink it */ ++ if (try_get_path(f, wnode->nodeid, NULL, &unlinkpath, NULL, false) == 0) { ++ err = fuse_fs_unlink(f->fs, unlinkpath); ++ if (!err) ++ remove_node(f, parent, wnode->name); ++ free(unlinkpath); ++ } ++ } ++ } + } else { + err = fuse_fs_unlink(f->fs, path); + if (!err) +-- +2.33.0 + diff --git a/fuse3.spec b/fuse3.spec index 0c618bf..b2e9d35 100644 --- a/fuse3.spec +++ b/fuse3.spec @@ -2,7 +2,7 @@ Name: fuse3 Version: %{fuse3ver} -Release: 12 +Release: 13 Summary: User space File System of fuse3 License: GPL+ and LGPLv2+ URL: http://fuse.sf.net @@ -18,6 +18,7 @@ Patch6: 0006-Fix-fd-leak-with-clone_fd.patch Patch7: 0007-Fix-use-after-free-warning.patch Patch8: 0008-Disable-leak-suppression-773.patch Patch9: 0009-Fix-memory-leak-in-high-level-API-781.patch +Patch10: 0010-Fix-file-leak-in-high-level-API.patch BuildRequires: libselinux-devel, pkgconfig, systemd-udev, meson, fdupes BuildRequires: autoconf, automake, libtool, gettext-devel, ninja-build @@ -108,6 +109,9 @@ install -p -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir} %{_mandir}/man8/* %changelog +* Sat Mar 30 2024 yangyun -3.9.2-13 +- fix file leak in high level api + * Tue Feb 8 2024 yangyun -3.9.2-12 - fix memory leak in high level api -- Gitee