[PATCH v2 1/5] fuse: don't wait for a sync-init mount when turning off fasync
From: Yun Wang
Date: Sun Nov 22 2026 - 10:26:32 EST
From: Yun Wang <arsenova@xxxxxxxxx>
Since commit dfb84c330794 ("fuse: allow synchronous FUSE_INIT"),
fuse_dev_fasync() looks the device up with fuse_get_dev(), which waits
until the mount has installed the channel if FUSE_DEV_IOC_SYNC_INIT was
used. open(2) keeps O_ASYNC in f_flags, and __fput() calls
->fasync(-1, file, 0) for every file with FASYNC set. So the last
fput of a sync-init device that was opened with O_ASYNC and never
mounted waits for a mount that can no longer come: until a signal in a
task, and forever in a kworker, which no signal wakes. The last fput
runs in a kworker for example when the unix socket garbage collector
frees a file that was in flight, and then the stuck delayed_fput work
also holds up every later delayed fput: an unrelated tmpfs umount(2)
then fails with EBUSY. /dev/fuse is 0666, so any user can do this.
In v7.1, before commit 9f6f44aa5a58 ("fuse: don't block in
fuse_get_dev() for non-sync_init case"), fuse_get_dev() waited for any
device that wasn't mounted yet, so this didn't even need
FUSE_DEV_IOC_SYNC_INIT.
Only an installed device can be on fiq->fasync, so before the mount
there is nothing to remove. Don't wait when fasync is turned off;
turning it on still waits for the mount as before. Turning it off on a
device that isn't mounted now succeeds instead of failing with -EPERM.
Fixes: dfb84c330794 ("fuse: allow synchronous FUSE_INIT")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Yun Wang <arsenova@xxxxxxxxx>
---
fs/fuse/dev.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 3641abb90d6b..2f6991d0e959 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -2280,10 +2280,23 @@ EXPORT_SYMBOL_GPL(fuse_dev_release);
static int fuse_dev_fasync(int fd, struct file *file, int on)
{
- struct fuse_dev *fud = fuse_get_dev(file);
+ struct fuse_dev *fud;
- if (IS_ERR(fud))
- return PTR_ERR(fud);
+ /*
+ * Only an installed device can be on fiq->fasync, so there is nothing
+ * to remove before the mount. Don't wait for it then: __fput() calls
+ * this for every O_ASYNC file, also one that is never mounted, and
+ * also from a kworker, which no signal ends the wait for.
+ */
+ if (!on) {
+ fud = __fuse_get_dev(file);
+ if (!fud)
+ return 0;
+ } else {
+ fud = fuse_get_dev(file);
+ if (IS_ERR(fud))
+ return PTR_ERR(fud);
+ }
/* No locking - fasync_helper does its own locking */
return fasync_helper(fd, file, on, &fud->chan->iq.fasync);
--
2.56.1