all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH fuse 1/2] requests: do not reply again after a failed reply
@ 2026-11-30 14:34 Dietmar Maurer
  2026-11-30 14:34 ` [PATCH fuse 2/2] session: keep the session until its last request is answered Dietmar Maurer
  0 siblings, 1 reply; 2+ messages in thread
From: Dietmar Maurer @ 2026-11-30 14:34 UTC (permalink / raw)
  To: pve-devel

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 <dietmar@proxmox.com>
---
 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




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-30 14:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 14:34 [PATCH fuse 1/2] requests: do not reply again after a failed reply Dietmar Maurer
2026-11-30 14:34 ` [PATCH fuse 2/2] session: keep the session until its last request is answered Dietmar Maurer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal