* FAILED: patch "[PATCH] fuse: preserve ENOTCONN after failed initialization and" failed to apply to 7.3-stable tree
@ 2026-12-02 13:03 gregkh
2026-12-03 22:17 ` [PATCH 7.3.y] fuse: preserve ENOTCONN after failed initialization and disconnect Sasha Levin
0 siblings, 1 reply; 2+ messages in thread
From: gregkh @ 2026-12-02 13:03 UTC (permalink / raw)
To: hengyul, mszeredi; +Cc: stable
The patch below does not apply to the 7.3-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-7.3.y
git checkout FETCH_HEAD
git cherry-pick -x 2eb2329f9ce7f29f227656cc2686fe6f1879d11c
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026120254-uplifting-daughter-6d2b@gregkh' --subject-prefix 'PATCH 7.3.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 2eb2329f9ce7f29f227656cc2686fe6f1879d11c Mon Sep 17 00:00:00 2001
From: Hengyu Liang <hengyul@cs.unc.edu>
Date: Sat, 17 Oct 2026 05:46:01 -0400
Subject: [PATCH] fuse: preserve ENOTCONN after failed initialization and
disconnect
Commit 794e811d1443 ("fuse: split out filesystem part of request
sending") moved the INIT failure check into fuse_req_prep(), before
the channel checks whether it is still connected.
If a daemon closes /dev/fuse before replying to INIT, aborting the
channel completes INIT with an error. stat() and open() on the mount
then return ECONNREFUSED instead of the previous ENOTCONN. The same
change occurs when INIT is rejected before the daemon closes the fd.
Record INIT failure in the channel before publishing initialized, and
check it in fuse_get_req() after waiting for initialization and checking
for disconnection. This preserves ECONNREFUSED for failed INIT while
the device remains open, and restores ENOTCONN after disconnection.
Set the failure flag only while the channel is connected, since abort
also marks it initialized to wake waiters after a successful INIT.
Fixes: 794e811d1443 ("fuse: split out filesystem part of request sending")
Cc: stable@vger.kernel.org
Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 3641abb90d6b..ec2306c63d0d 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -80,6 +80,10 @@ void fuse_chan_set_initialized(struct fuse_chan *fch, struct fuse_chan_param *pa
fuse_uring_conn_init(fch);
}
+ /* An aborted channel is also marked initialized to wake waiters. */
+ if (!param && fch->connected)
+ fch->conn_refused = true;
+
/* Pairs with smp_load_acquire() readers of fch->initialized */
smp_store_release(&fch->initialized, 1);
wake_up_all(&fch->blocked_waitq);
@@ -130,6 +134,10 @@ static struct fuse_req *fuse_get_req(struct fuse_chan *fch, bool for_background)
if (!fch->connected)
goto out;
+ err = -ECONNREFUSED;
+ if (fch->conn_refused)
+ goto out;
+
req = fuse_request_alloc(fch, GFP_KERNEL);
err = -ENOMEM;
if (!req) {
diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h
index 4b412a76225f..0c078bdc270c 100644
--- a/fs/fuse/fuse_dev_i.h
+++ b/fs/fuse/fuse_dev_i.h
@@ -245,6 +245,9 @@ struct fuse_chan {
/** Is interrupt not implemented by fs? */
bool no_interrupt;
+ /** @conn_refused: INIT failed while the channel was still connected. */
+ bool conn_refused;
+
/* Use io_uring for communication */
unsigned int io_uring;
diff --git a/fs/fuse/req.c b/fs/fuse/req.c
index 6274a23af445..d96b947c61e6 100644
--- a/fs/fuse/req.c
+++ b/fs/fuse/req.c
@@ -49,20 +49,11 @@ static int fuse_fill_creds(struct fuse_mount *fm, struct fuse_args *args,
return 0;
}
-static int fuse_req_prep(struct fuse_mount *fm, struct fuse_args *args,
- const struct mnt_idmap *idmap)
-{
- if (!args->force && fm->fc->conn_error)
- return -ECONNREFUSED;
-
- return fuse_fill_creds(fm, args, idmap);
-}
-
ssize_t __fuse_simple_request(const struct mnt_idmap *idmap, struct fuse_mount *fm,
struct fuse_args *args)
{
struct fuse_conn *fc = fm->fc;
- int err = fuse_req_prep(fm, args, idmap);
+ int err = fuse_fill_creds(fm, args, idmap);
if (err)
return err;
@@ -77,7 +68,7 @@ int fuse_simple_background(struct fuse_mount *fm, struct fuse_args *args, gfp_t
WARN_ON(args->force && !args->nocreds);
- err = fuse_req_prep(fm, args, &invalid_mnt_idmap);
+ err = fuse_fill_creds(fm, args, &invalid_mnt_idmap);
if (err)
return err;
@@ -92,7 +83,7 @@ int fuse_simple_notify_reply(struct fuse_mount *fm, struct fuse_args *args, u64
WARN_ON(args->force && !args->nocreds);
- err = fuse_req_prep(fm, args, &invalid_mnt_idmap);
+ err = fuse_fill_creds(fm, args, &invalid_mnt_idmap);
if (err)
return err;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH 7.3.y] fuse: preserve ENOTCONN after failed initialization and disconnect
2026-12-02 13:03 FAILED: patch "[PATCH] fuse: preserve ENOTCONN after failed initialization and" failed to apply to 7.3-stable tree gregkh
@ 2026-12-03 22:17 ` Sasha Levin
0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2026-12-03 22:17 UTC (permalink / raw)
To: stable; +Cc: Hengyu Liang, Miklos Szeredi, Sasha Levin
From: Hengyu Liang <hengyul@cs.unc.edu>
[ Upstream commit 2eb2329f9ce7f29f227656cc2686fe6f1879d11c ]
Commit 794e811d1443 ("fuse: split out filesystem part of request
sending") moved the INIT failure check into fuse_req_prep(), before
the channel checks whether it is still connected.
If a daemon closes /dev/fuse before replying to INIT, aborting the
channel completes INIT with an error. stat() and open() on the mount
then return ECONNREFUSED instead of the previous ENOTCONN. The same
change occurs when INIT is rejected before the daemon closes the fd.
Record INIT failure in the channel before publishing initialized, and
check it in fuse_get_req() after waiting for initialization and checking
for disconnection. This preserves ECONNREFUSED for failed INIT while
the device remains open, and restores ENOTCONN after disconnection.
Set the failure flag only while the channel is connected, since abort
also marks it initialized to wake waiters after a successful INIT.
Fixes: 794e811d1443 ("fuse: split out filesystem part of request sending")
Cc: stable@vger.kernel.org
Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
[ sashal: adapted the context for the non-const struct mnt_idmap *idmap parameter type in fs/fuse/req.c when removing fuse_req_prep(); the rest matches upstream. ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/fuse/dev.c | 8 ++++++++
fs/fuse/fuse_dev_i.h | 3 +++
fs/fuse/req.c | 14 +++-----------
3 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 60d6e93ed1640..115841edb11f1 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -80,6 +80,10 @@ void fuse_chan_set_initialized(struct fuse_chan *fch, struct fuse_chan_param *pa
fuse_uring_conn_init(fch);
}
+ /* An aborted channel is also marked initialized to wake waiters. */
+ if (!param && fch->connected)
+ fch->conn_refused = true;
+
/* Pairs with smp_load_acquire() readers of fch->initialized */
smp_store_release(&fch->initialized, 1);
wake_up_all(&fch->blocked_waitq);
@@ -130,6 +134,10 @@ static struct fuse_req *fuse_get_req(struct fuse_chan *fch, bool for_background)
if (!fch->connected)
goto out;
+ err = -ECONNREFUSED;
+ if (fch->conn_refused)
+ goto out;
+
req = fuse_request_alloc(fch, GFP_KERNEL);
err = -ENOMEM;
if (!req) {
diff --git a/fs/fuse/fuse_dev_i.h b/fs/fuse/fuse_dev_i.h
index 4b412a76225f8..0c078bdc270c5 100644
--- a/fs/fuse/fuse_dev_i.h
+++ b/fs/fuse/fuse_dev_i.h
@@ -245,6 +245,9 @@ struct fuse_chan {
/** Is interrupt not implemented by fs? */
bool no_interrupt;
+ /** @conn_refused: INIT failed while the channel was still connected. */
+ bool conn_refused;
+
/* Use io_uring for communication */
unsigned int io_uring;
diff --git a/fs/fuse/req.c b/fs/fuse/req.c
index 51cfd64ea1bad..baaffa78af8aa 100644
--- a/fs/fuse/req.c
+++ b/fs/fuse/req.c
@@ -48,19 +48,11 @@ static int fuse_fill_creds(struct fuse_mount *fm, struct fuse_args *args, struct
return 0;
}
-static int fuse_req_prep(struct fuse_mount *fm, struct fuse_args *args, struct mnt_idmap *idmap)
-{
- if (!args->force && fm->fc->conn_error)
- return -ECONNREFUSED;
-
- return fuse_fill_creds(fm, args, idmap);
-}
-
ssize_t __fuse_simple_request(struct mnt_idmap *idmap, struct fuse_mount *fm,
struct fuse_args *args)
{
struct fuse_conn *fc = fm->fc;
- int err = fuse_req_prep(fm, args, idmap);
+ int err = fuse_fill_creds(fm, args, idmap);
if (err)
return err;
@@ -75,7 +67,7 @@ int fuse_simple_background(struct fuse_mount *fm, struct fuse_args *args, gfp_t
WARN_ON(args->force && !args->nocreds);
- err = fuse_req_prep(fm, args, &invalid_mnt_idmap);
+ err = fuse_fill_creds(fm, args, &invalid_mnt_idmap);
if (err)
return err;
@@ -90,7 +82,7 @@ int fuse_simple_notify_reply(struct fuse_mount *fm, struct fuse_args *args, u64
WARN_ON(args->force && !args->nocreds);
- err = fuse_req_prep(fm, args, &invalid_mnt_idmap);
+ err = fuse_fill_creds(fm, args, &invalid_mnt_idmap);
if (err)
return err;
--
2.53.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-03 22:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 13:03 FAILED: patch "[PATCH] fuse: preserve ENOTCONN after failed initialization and" failed to apply to 7.3-stable tree gregkh
2026-12-03 22:17 ` [PATCH 7.3.y] fuse: preserve ENOTCONN after failed initialization and disconnect Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox