From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 304EA1FF0B7 for ; Mon, 30 Nov 2026 15:34:26 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id AC63121709; Mon, 30 Nov 2026 15:34:23 +0100 (CET) From: Dietmar Maurer To: pve-devel@lists.proxmox.com Subject: [PATCH fuse 1/2] requests: do not reply again after a failed reply Date: Mon, 30 Nov 2026 15:34:06 +0100 Message-ID: <20261130143407.328696-1-dietmar@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 AWL -0.468 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 1.274 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Message-ID-Hash: C45H3L752WJC4VS3J274ELAO4N72FFDZ X-Message-ID-Hash: C45H3L752WJC4VS3J274ELAO4N72FFDZ X-MailFrom: dietmar@zilli.proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: libfuse frees a request whenever it sends a reply, also when sending fails. The guard of a request was only disarmed after a successful reply, so a failed one, for example with EBADF after the file system was unmounted, had the guard reply to the freed request once more: a use after free, which crashed with a segmentation fault. Signed-off-by: Dietmar Maurer --- src/requests.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/requests.rs b/src/requests.rs index de835ab..5a189f1 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -60,8 +60,10 @@ fn reply_err(request: RequestGuard, errno: libc::c_int) -> io::Result<()> { macro_rules! reply_result { ($self:ident : $expr:expr) => {{ let rc = unsafe { $expr }; + // libfuse frees the request also when sending the reply failed, so the guard must not + // reply again + let _done = $self.request.into_raw(); if rc == 0 { - let _done = $self.request.into_raw(); Ok(()) } else { Err(io::Error::from_raw_os_error(-rc)) @@ -185,13 +187,7 @@ impl FuseRequest for Lookup { impl Lookup { pub fn reply(self, entry: &sys::EntryParam) -> io::Result<()> { - let rc = unsafe { sys::fuse_reply_entry(self.request.raw, Some(entry)) }; - if rc == 0 { - let _done = self.request.into_raw(); - Ok(()) - } else { - Err(io::Error::from_raw_os_error(-rc)) - } + reply_result!(self: sys::fuse_reply_entry(self.request.raw, Some(entry))) } } -- 2.47.3