From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796381488; b=mFxJcdI/77bL/4HBYm7WpqsuWvc9MQahHlLQT2/b0ObiO5OlxzaLTvOrq1FoldQnKGwJ A/5eEBr9iWlHEtvyssrvbWPv6IYK4j0wU3rkSocffEHnhKg8FAsQY/lWEVppF6wC9o7N6 B/oLc3tDOjpb/CMEAmryx5hsfHVk2HrV9dT9SyjimktYo32euFncG3HuDfptglaptr5xa hLJxdRzPv28VX5y1TXNFUF1Zuoo+KrcmrB2Nvrwv8vcClkVCt4Wtu6yvSo73Nwn6/Hl+n WBTFsN/pwkgMkuGMLzB5TpmFKt4AJ2N2cs1GtbeKH9NhgEHeiJfbOGX9B9Sbs0Ozh0Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381488; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=YExR4Okg6y3hc4BG0ojtMdW+6Md6nCFcgD66QcHHJIU=; b=NiybdytN58l5qzWEU+lTJLDU/GDMB8oEHdAwNYU+YWy/CslXw144e2BArBnwAsVSrdxU i4ZjODaPynmrrIRadIbd/8sck2lTVrgMY4w0IUk0CisAMqQKfr5gozpBFXR2FpkQzg+6N Gf7wz0lvqOSFuRLq5ATSD1rO5jghmczT94WOiw84ceIj1R9hLYOv7tcviJ1yjfyYqu9LD BiPaRQuP0z1K19ENlgd67XE+6b1itSCSm6CJt8R8IcW6PkffiJVukWj17NMnu4VLnSbmK o3GFKoc9854AB8Lw+9nflkO0s2tpVIdxa/VZpbij+vJbBZFoS+6k08VCXwFVgj2/AoQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=aGUiq8eE; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98CEC606A33B; Fri, 4 Dec 2026 10:51:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=aGUiq8eE Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16C291F000CE; Fri, 4 Dec 2026 10:51:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381488; bh=YExR4Okg6y3hc4BG0ojtMdW+6Md6nCFcgD66QcHHJIU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aGUiq8eEFvvLiwFztfaN/mC5iycPkzL1u6IkRFAvjzDaUy3wkgZYnlgccG+LqW/eS XAPejaY1U34c/v4rt13NFVbknAXs/6rr0w0+57gCzSOIHL8gkYnh8udxJgyuhyL8A6 Phw2Iyf9RaAH7AtuGoD5AiUbnUbGbszwASio7o6M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hengyu Liang , Miklos Szeredi , Sasha Levin Subject: [PATCH 7.3 726/742] fuse: preserve ENOTCONN after failed initialization and disconnect Date: Fri, 4 Dec 2026 19:09:50 +0900 Message-ID: <20261204100654.369234466@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hengyu Liang [ 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 Signed-off-by: Miklos Szeredi [ 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 Signed-off-by: Greg Kroah-Hartman --- fs/fuse/dev.c | 8 ++++++++ fs/fuse/fuse_dev_i.h | 3 +++ fs/fuse/req.c | 14 +++----------- 3 files changed, 14 insertions(+), 11 deletions(-) --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -80,6 +80,10 @@ void fuse_chan_set_initialized(struct fu 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(str if (!fch->connected) goto out; + err = -ECONNREFUSED; + if (fch->conn_refused) + goto out; + req = fuse_request_alloc(fch, GFP_KERNEL); err = -ENOMEM; if (!req) { --- 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; --- a/fs/fuse/req.c +++ b/fs/fuse/req.c @@ -48,19 +48,11 @@ static int fuse_fill_creds(struct fuse_m 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_m 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 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;