Bug 287431 - [fusefs]: deadlock during unmount if FUSE_INIT never completed
Summary: [fusefs]: deadlock during unmount if FUSE_INIT never completed
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 15.0-CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Alan Somers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-06-10 19:33 UTC by Alan Somers
Modified: 2026-10-14 19:29 UTC (History)
2 users (show)

See Also:
asomers: mfc-stable15+
asomers: mfc-stable14?


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Somers freebsd_committer freebsd_triage 2025-06-10 19:33:59 UTC
The following sequence of events will lead to a deadlock

1) A process mounts a fuse file system but never responds to the FUSE_INIT request.
2) Some other process tries to access the mountpoint.  Many different types of access might trigger this bug, but the easiest example is ls, which will trigger a FUSE_ACCESS request.  That operation will block in fuse_ticket_fetch because FUSE_INIT hasn't completed yet.
3) Some process, possibly the daemon itself, tries to unmount the mount point.  The unmount syscall will block in fuse_vfsop_root because the process from step 2 has the vnode lock for the fuse file system's root vnode.

I have a test case for this already, but not a solution.
Comment 1 commit-hook freebsd_committer freebsd_triage 2026-09-23 22:33:43 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=0bd6348b52e1991fafc55128173c989dab36dfd9

commit 0bd6348b52e1991fafc55128173c989dab36dfd9
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2026-09-15 21:23:50 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2026-09-23 22:32:37 +0000

    fusefs: fix a deadlock caused by daemons that never initialize

    If a daemon never responds to FUSE_INIT, but some process attempts to
    access the mountpoint, and a different process (possibly the daemon
    itself) attempts to unmount, a deadlock would result.

    Fix this bug by blocking any thread that enters fuse_vfsop_root until
    the daemon responds to FUSE_INIT or it times out.  That will block any
    thread attempting to lookup a path in the fuse mountpoint, before it
    even gets to fuse VOPs.  Remove less thorough initialization checks in
    fuse_ticket_fetch and fuse_vnop_access that are no longer necessary.
    And add a test case.

    PR:             287431
    MFC after:      2 weeks
    Sponsored by:   ConnectWise
    Reviewed by:    js
    Differential Revision: https://reviews.freebsd.org/D59737

 sys/fs/fuse/fuse_ipc.c          | 24 +-----------
 sys/fs/fuse/fuse_ipc.h          |  1 -
 sys/fs/fuse/fuse_vfsops.c       | 31 +++++++++++++++
 sys/fs/fuse/fuse_vnops.c        | 14 -------
 tests/sys/fs/fusefs/mockfs.cc   |  8 +++-
 tests/sys/fs/fusefs/mockfs.hh   |  2 +-
 tests/sys/fs/fusefs/pre-init.cc | 86 +++++++++++++++++++++++++++++++++++------
 tests/sys/fs/fusefs/utils.cc    |  2 +-
 tests/sys/fs/fusefs/utils.hh    |  2 +
 9 files changed, 118 insertions(+), 52 deletions(-)
Comment 2 commit-hook freebsd_committer freebsd_triage 2026-10-14 19:07:35 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=169e254b8440c010139b1351f46b70bc7ad3d5cb

commit 169e254b8440c010139b1351f46b70bc7ad3d5cb
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2026-09-15 21:23:50 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2026-10-14 19:03:35 +0000

    fusefs: fix a deadlock caused by daemons that never initialize

    If a daemon never responds to FUSE_INIT, but some process attempts to
    access the mountpoint, and a different process (possibly the daemon
    itself) attempts to unmount, a deadlock would result.

    Fix this bug by blocking any thread that enters fuse_vfsop_root until
    the daemon responds to FUSE_INIT or it times out.  That will block any
    thread attempting to lookup a path in the fuse mountpoint, before it
    even gets to fuse VOPs.  Remove less thorough initialization checks in
    fuse_ticket_fetch and fuse_vnop_access that are no longer necessary.
    And add a test case.

    PR:             287431
    Sponsored by:   ConnectWise
    Reviewed by:    js
    Differential Revision: https://reviews.freebsd.org/D59737

    (cherry picked from commit 0bd6348b52e1991fafc55128173c989dab36dfd9)

 sys/fs/fuse/fuse_ipc.c          | 24 +-----------
 sys/fs/fuse/fuse_ipc.h          |  1 -
 sys/fs/fuse/fuse_vfsops.c       | 31 +++++++++++++++
 sys/fs/fuse/fuse_vnops.c        | 14 -------
 tests/sys/fs/fusefs/mockfs.cc   |  9 ++++-
 tests/sys/fs/fusefs/mockfs.hh   |  2 +-
 tests/sys/fs/fusefs/pre-init.cc | 86 +++++++++++++++++++++++++++++++++++------
 tests/sys/fs/fusefs/utils.cc    |  2 +-
 tests/sys/fs/fusefs/utils.hh    |  2 +
 9 files changed, 119 insertions(+), 52 deletions(-)