public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Miklos Szeredi <mszeredi@redhat.com>,
	linux-fsdevel@vger.kernel.org, Bernd Schubert <bernd@bsbernd.com>
Subject: Re: [PATCH v2 3/6] fuse: don't require /dev/fuse fd to be kept open during mount
Date: Tue, 17 Mar 2026 16:39:13 -0700	[thread overview]
Message-ID: <20260317233913.GS6069@frogsfrogsfrogs> (raw)
In-Reply-To: <CAJfpeguqNU_Q62vDS6nL_w3wBtGU8osE4d9pRFKFMVq-ATRFMw@mail.gmail.com>

On Mon, Mar 16, 2026 at 12:29:53PM +0100, Miklos Szeredi wrote:
> On Sat, 14 Mar 2026 at 00:09, Darrick J. Wong <djwong@kernel.org> wrote:
> 
> > Hrmm, is this https://github.com/libfuse/libfuse/pull/1367 ?
> 
> Right.
> 
> > Which syscall causes the synchronous FUSE_INIT to be sent?  Is it
> > FSCONFIG_CMD_CREATE?
> 
> Yes.
> 
> > > The reason is that while all other threads will exit, the mounting
> > > thread (or process) will keep the device fd open, which will prevent
> > > an abort from happening.
> >
> > So I guess what's happening here is that the main thread calls
> > FSCONFIG_CMD_CREATE, which sends the synchronous FUSE_INIT to the worker
> > pool.  One of the worker threads starts working on the FUSE_INIT reply
> > and crashes.  All the *workers* terminate and close the fuse dev fd,
> > leaving just the main thread.
> >
> > AFAICT, the main thread is stuck in fsconfig() here:
> >
> >         /* Any signal may interrupt this */
> >                 err = wait_event_interruptible(req->waitq,
> >                                 test_bit(FR_FINISHED, &req->flags))
> >
> > so there's still an open ref to the fuse dev fd, which prevents anyone
> > from aborting the FUSE_INIT request so that FR_FINISH gets set?
> 
> Yes.
> 
> >  And now
> > we're just hosed?  Wouldn't the SIGCHLD interrupt the wait?  Or are we
> > stuck someplace else?
> 
> The FUSE_INIT request is in FR_SENT state, and fuse doesn't allow
> interrupting such requests without the cooperation of the server.
> 
> We could special case FUSE_INIT (and probably a number of other
> request types) that are safe to kill without the server's consent.
> Will look into this.

I wonder if there's a way to have a wait_event_killable that will wake
up if the process exits without being killed by a signal?  Or does it
already do that...

> >
> > > This is a regression from the async mount case, where the mount was done
> > > first, and the FUSE_INIT processing afterwards, in which case there's no
> > > such recursive syscall keeping the fd open.
> >
> > Is this hang possible if you're using mount(2) with synchronous
> > FUSE_INIT?
> 
> Yes.

Yikes.  I guess at least there's the echo > .../abort solution below.

> > > The solution is twofold:
> > >
> > >  a) use unshare(CLONE_FILES) in the mounting thread
> >
> > Is this after starting up the worker threads?  I guess that means the
> > worker threads retain their fuse dev fds even though...
> >
> > >     and close the device fd
> > >     after fsconfig(fs_fd, FSCONFIG_SET_STRING, "fd", ...)
> >
> > ...the main thread closes the fuse dev fd before FSCONFIG_CMD_CREATE.
> > What if that main thread needs to use the fuse dev fd after this point?
> > Or, what if userspace doesn't cooperate and unshare()/close()?  Can this
> > hang be broken by kill -9, at least?
> 
> No, only
> 
>   echo > /sys/fs/fuse/connections/NN/abort
> 
> >
> > >  b) only reference the fuse_dev from fs_context not the device file itself
> >
> > Can you set an abort timeout on the FUSE_INIT request?
> 
> I don't like timeouts, but yes, we could.

<nod> Or *some* means of figuring out that one of the other threads has
crashed the process, so we might as well cancel the wait_event?

> >
> > Perhaps my broader question is, what /does/ happen if a fuse server
> > thread starts processing a request and crashes out before replying?  I
> > guess that means the request is never completed, but in the case of
> > !(synchronous FUSE_INIT) we'd just see the whole server terminate, which
> > would then release the fuse dev fd?
> 
> Right.

(I forget, what was the purpose of synchronous FUSE_INIT?)

--D

> Thanks,
> Miklos

  reply	other threads:[~2026-03-17 23:39 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12 19:39 [PATCH v2 0/6] fuse: fix hang with sync init Miklos Szeredi
2026-03-12 19:39 ` [PATCH v2 1/6] fuse: create fuse_dev on /dev/fuse open instead of mount Miklos Szeredi
2026-03-13 22:05   ` Darrick J. Wong
2026-03-16 10:04     ` Miklos Szeredi
2026-03-19 23:36   ` Mark Brown
2026-03-12 19:40 ` [PATCH v2 2/6] fuse: add refcount to fuse_dev Miklos Szeredi
2026-03-13 22:28   ` Darrick J. Wong
2026-03-16 10:50     ` Miklos Szeredi
2026-03-12 19:40 ` [PATCH v2 3/6] fuse: don't require /dev/fuse fd to be kept open during mount Miklos Szeredi
2026-03-13 23:09   ` Darrick J. Wong
2026-03-16 11:29     ` Miklos Szeredi
2026-03-17 23:39       ` Darrick J. Wong [this message]
2026-03-17 23:49         ` Joanne Koong
2026-03-18 22:15           ` Bernd Schubert
2026-03-18 23:18             ` Joanne Koong
2026-03-12 19:40 ` [PATCH v2 4/6] fuse: clean up device cloning Miklos Szeredi
2026-03-13 23:59   ` Darrick J. Wong
2026-03-16 11:40     ` Miklos Szeredi
2026-03-12 19:40 ` [PATCH v2 5/6] fuse: alloc pqueue before installing fc Miklos Szeredi
2026-03-12 19:40 ` [PATCH v2 6/6] fuse: support FSCONFIG_SET_FD for "fd" option Miklos Szeredi
2026-03-13 12:03   ` kernel test robot
2026-03-14  0:10   ` Darrick J. Wong
2026-03-14 17:22   ` kernel test robot
2026-03-12 23:04 ` [PATCH v2 0/6] fuse: fix hang with sync init Bernd Schubert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260317233913.GS6069@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=bernd@bsbernd.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=mszeredi@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox