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=1795034796; b=DtYxiDzPPlv+qnNHJXPWd/DcedJUmX6NncSGhYPoY57UoVhYY5jbd5a57uaJbEuUa4XU WInEDxwzT/m0duqQMjycpbf0ACzP8oXwUzCui36A7ExoUjWDApygzW9ucnzBe32SklDCw Mr1d2flx4A4Pnjjzd06YX7lYmTP6mO8kcMeO5Guf1P+cPy8OwISHSnjnY6sRgbgdTsHYV 059HmuDCW/gB6SrDSy5EHr7W7XfsaKwcdXJeHu6RpOwLK7BO5y4MlSgQbZc2/yMk8CWH7 bJ4SsfwunqytbBFRHHxjlBrgtVC4TgEg7HAwOFrErTCB9hnA40hbKvgZyKfXNxfb8kA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795034796; 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=BO+KnkELaj/+quPClK/2eK1kDMSoLlI37p4FFr2CpcM=; b=dIHqUauJku9G18wB4dufqJiNoLXtNTZQ4LxyTeT1BQR9mB9aKEY0qGWh+5MxMH/CY/7/ YXrhlHo2aOFok6DIRKxwYE4qTFX1sahrzwRhydaXtu5IGjo2gZVaBLLeUWsAu+kNh86ib 8APYOkSST00SPu3Js3UTd9s4AL+orKN1IfZTXzvPLzZxpiL5ns0IfGCHkbRqSOlhbvfys +nbslka5KWdHxsm1LwvL5Q8hTo9ItpUMtSvBFh1551v9MuTUMspQMQWe5hrq1BOJGNNLE u0pQVQKZKFurjxeclvDy24a7uPOGyFuYSS5bWQDDmrvGZIY2drFazDfq6UV5YLWOBdA== 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=aCMApQfO; 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 D0E1B606A31C; Wed, 18 Nov 2026 20:46:36 +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=aCMApQfO Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3E591F000C5; Wed, 18 Nov 2026 20:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795034796; bh=BO+KnkELaj/+quPClK/2eK1kDMSoLlI37p4FFr2CpcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=aCMApQfOfCv/ZpLz3bXz1Yu9oxr5NhJj0TpBT2N2PO0KpchUejwSOuiHAT9XqV+Si owcz0IMfuVwUm5mg4GQq8MWzR2nT+Vc6D4Y9OYuTEmb0xF+zTHJVCgo9DSmZ8zu9tk 061pjderjEp4ECy7nRoUthADmQhPWEFVgpVSOflg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Vega , Luxing Yin , Zihan Xi , Frank Sorenson , Paulo Alcantara , Sasha Levin Subject: [PATCH 6.6 0498/3318] smb: client: clean up failed cached directory opens Date: Wed, 18 Nov 2026 15:18:40 +0100 Message-ID: <20261118150331.981792538@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150313.527275416@linuxfoundation.org> References: <20261118150313.527275416@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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zihan Xi [ Upstream commit d2ff5fb93ea83034025850266b5eed391f96b825 ] open_cached_dir() sends CREATE and QUERY_INFO as a compound request. If the CREATE succeeds but a later command returns an error, the function must retain the CREATE FID so common cleanup can issue SMB2_close(). It also must not treat a response error as a valid CREATE. Validate the CREATE response before using its fields, record the FIDs, and mark the handle open before handling errors from later compound commands. Move the -EREMCHG reconnect handling before response validation so a missing response does not hide the reconnect request. Count the handle when it is marked open; confirmed close responses decrement the counter, while existing close retry behavior remains best effort on transport failures. Fixes: b0f6df737a1c ("cifs: cache FILE_ALL_INFO for the shared root handle") Cc: stable@vger.kernel.org Reported-by: Vega Assisted-by: LLM Co-developed-by: Luxing Yin Signed-off-by: Luxing Yin Signed-off-by: Zihan Xi Tested-by: Frank Sorenson Signed-off-by: Paulo Alcantara Signed-off-by: Sasha Levin --- fs/smb/client/cached_dir.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/fs/smb/client/cached_dir.c b/fs/smb/client/cached_dir.c index fbc746813a6f2..bb1358d649499 100644 --- a/fs/smb/client/cached_dir.c +++ b/fs/smb/client/cached_dir.c @@ -8,6 +8,7 @@ #include #include "cifsglob.h" #include "cifsproto.h" +#include "../common/smb2status.h" #include "cifs_debug.h" #include "smb2proto.h" #include "cached_dir.h" @@ -294,25 +295,37 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, rc = compound_send_recv(xid, ses, server, flags, 2, rqst, resp_buftype, rsp_iov); - if (rc) { - if (rc == -EREMCHG) { - tcon->need_reconnect = true; - pr_warn_once("server share %s deleted\n", - tcon->tree_name); - } - goto oshr_free; + if (rc == -EREMCHG) { + tcon->need_reconnect = true; + pr_warn_once("server share %s deleted\n", + tcon->tree_name); } - cfid->is_open = true; - spin_lock(&cfids->cfid_list_lock); + if (!rsp_iov[0].iov_base || rsp_iov[0].iov_len < sizeof(*o_rsp)) { + if (!rc) + rc = -EIO; + goto oshr_free; + } o_rsp = (struct smb2_create_rsp *)rsp_iov[0].iov_base; + if (o_rsp->hdr.Status != STATUS_SUCCESS) { + if (!rc) + rc = -EIO; + goto oshr_free; + } + oparms.fid->persistent_fid = o_rsp->PersistentFileId; oparms.fid->volatile_fid = o_rsp->VolatileFileId; #ifdef CONFIG_CIFS_DEBUG2 oparms.fid->mid = le64_to_cpu(o_rsp->hdr.MessageId); #endif /* CIFS_DEBUG2 */ + cfid->is_open = true; + atomic_inc(&tcon->num_remote_opens); + if (rc) + goto oshr_free; + + spin_lock(&cfids->cfid_list_lock); if (o_rsp->OplockLevel != SMB2_OPLOCK_LEVEL_LEASE) { spin_unlock(&cfids->cfid_list_lock); @@ -378,7 +391,6 @@ int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, close_cached_dir(cfid); } else { *ret_cfid = cfid; - atomic_inc(&tcon->num_remote_opens); } kfree(utf16_path); -- 2.53.0