!42 Fix fd leak with clone_fd
From: @liuzhiqiang26 Reviewed-by: @wubo009 Signed-off-by: @wubo009
This commit is contained in:
commit
a45f4f755c
55
0003-Fix-fd-leak-with-clone_fd.patch
Normal file
55
0003-Fix-fd-leak-with-clone_fd.patch
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
From 2da64ec9a37d684b73882574f391f9ad366b3c0d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Frank Dinoff <fdinoff@google.com>
|
||||||
|
Date: Mon, 21 Mar 2022 13:13:21 -0400
|
||||||
|
Subject: [PATCH] Fix fd leak with clone_fd
|
||||||
|
|
||||||
|
do_interrupt would destroy_req on the request without decrementing the
|
||||||
|
channel's refcount. With clone_fd this could leak file descriptors if
|
||||||
|
the worker thread holding the cloned fd was destroyed. (Only
|
||||||
|
max_idle_threads are kept).
|
||||||
|
---
|
||||||
|
lib/fuse_lowlevel.c | 12 +++++++++---
|
||||||
|
1 file changed, 9 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
|
||||||
|
index b5638fc..3a1e7d8 100644
|
||||||
|
--- a/lib/fuse_lowlevel.c
|
||||||
|
+++ b/lib/fuse_lowlevel.c
|
||||||
|
@@ -123,6 +123,7 @@ static void list_add_req(struct fuse_req *req, struct fuse_req *next)
|
||||||
|
|
||||||
|
static void destroy_req(fuse_req_t req)
|
||||||
|
{
|
||||||
|
+ assert(req->ch == NULL);
|
||||||
|
pthread_mutex_destroy(&req->lock);
|
||||||
|
free(req);
|
||||||
|
}
|
||||||
|
@@ -1712,8 +1713,11 @@ static int find_interrupted(struct fuse_session *se, struct fuse_req *req)
|
||||||
|
|
||||||
|
pthread_mutex_lock(&se->lock);
|
||||||
|
curr->ctr--;
|
||||||
|
- if (!curr->ctr)
|
||||||
|
+ if (!curr->ctr) {
|
||||||
|
+ fuse_chan_put(req->ch);
|
||||||
|
+ req->ch = NULL;
|
||||||
|
destroy_req(curr);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
@@ -1739,9 +1743,11 @@ static void do_interrupt(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
|
||||||
|
req->u.i.unique = arg->unique;
|
||||||
|
|
||||||
|
pthread_mutex_lock(&se->lock);
|
||||||
|
- if (find_interrupted(se, req))
|
||||||
|
+ if (find_interrupted(se, req)) {
|
||||||
|
+ fuse_chan_put(req->ch);
|
||||||
|
+ req->ch = NULL;
|
||||||
|
destroy_req(req);
|
||||||
|
- else
|
||||||
|
+ } else
|
||||||
|
list_add_req(req, &se->interrupts);
|
||||||
|
pthread_mutex_unlock(&se->lock);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.24.0.windows.2
|
||||||
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Name: fuse3
|
Name: fuse3
|
||||||
Version: %{fuse3ver}
|
Version: %{fuse3ver}
|
||||||
Release: 4
|
Release: 5
|
||||||
Summary: User space File System of fuse3
|
Summary: User space File System of fuse3
|
||||||
License: GPL+ and LGPLv2+
|
License: GPL+ and LGPLv2+
|
||||||
URL: http://fuse.sf.net
|
URL: http://fuse.sf.net
|
||||||
@ -11,6 +11,7 @@ Source1: fuse.conf
|
|||||||
|
|
||||||
Patch1: 0001-fix-chown-and-mknod-failed.patch
|
Patch1: 0001-fix-chown-and-mknod-failed.patch
|
||||||
Patch2: 0002-revert-fuse_daemonize-chdir-to-even-if-not-run.patch
|
Patch2: 0002-revert-fuse_daemonize-chdir-to-even-if-not-run.patch
|
||||||
|
Patch3: 0003-Fix-fd-leak-with-clone_fd.patch
|
||||||
|
|
||||||
BuildRequires: libselinux-devel, pkgconfig, systemd-udev, meson, fdupes
|
BuildRequires: libselinux-devel, pkgconfig, systemd-udev, meson, fdupes
|
||||||
BuildRequires: autoconf, automake, libtool, gettext-devel, ninja-build
|
BuildRequires: autoconf, automake, libtool, gettext-devel, ninja-build
|
||||||
@ -101,6 +102,9 @@ install -p -m 0644 %{SOURCE1} %{buildroot}%{_sysconfdir}
|
|||||||
%{_mandir}/man8/*
|
%{_mandir}/man8/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Dec 7 2022 Zhiqiang Liu <liuzhiqiang26@huawei.com> -3.10.5-5
|
||||||
|
- fix fd leak with clone_fd
|
||||||
|
|
||||||
* Fri Nov 4 2022 zhanchengbin <zhanchengbin1@huawei.com> -3.10.5-4
|
* Fri Nov 4 2022 zhanchengbin <zhanchengbin1@huawei.com> -3.10.5-4
|
||||||
- Synchronize Version
|
- Synchronize Version
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user