FAILED: patch "[PATCH] smb: client: clean up failed cached directory opens" failed to apply to 6.6-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.6-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 <[email protected]>.
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-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x d2ff5fb93ea83034025850266b5eed391f96b825
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026092937-truce-superhero-2529@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From d2ff5fb93ea83034025850266b5eed391f96b825 Mon Sep 17 00:00:00 2001
From: Zihan Xi <[email protected]>
Date: Wed, 16 Sep 2026 15:29:27 +0000
Subject: [PATCH] smb: client: clean up failed cached directory opens
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.
fs/smb/client/cached_dir.c +22 -10
@@ -8,6 +8,7 @@#include <linux/namei.h> #include "cifsglob.h" #include "cifsproto.h" +#include "../common/smb2status.h" #include "cifs_debug.h" #include "smb2proto.h" #include "cached_dir.h"
@@ -323,25 +324,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); - } +if (rc == -EREMCHG ) { + tcon->need_reconnect = true; +pr_warn_once ("server share %s deleted\n" , + tcon->tree_name); + } + +if (!rsp_iov[0 ].iov_base || rsp_iov[0 ].iov_len <sizeof (*o_rsp)) { +if (!rc) + rc = -EIO ; goto oshr_free; } - cfid->is_open = true; - -spin_lock (&cfids->cfid_list_lock); 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);
@@ -408,7 +421,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);
Sasha Levin
maintainerPATCH 1/2 smb: move SMB2 Status code to common header file
From: ChenXiaoSong <[email protected]>
[ Upstream commit 78181a5504a401e421e65d0257a33f904e0e7c29 ]
There are only 4 different definitions between the client and server:
- STATUS_SERVER_UNAVAILABLE: from client/smb2status.h
- STATUS_FILE_NOT_AVAILABLE: from client/smb2status.h
- STATUS_NO_PREAUTH_INTEGRITY_HASH_OVERLAP: from server/smbstatus.h
- STATUS_INVALID_LOCK_RANGE: from server/smbstatus.h
Rename client/smb2status.h to common/smb2status.h, and merge the 2 different definitions of server to common header file.
Stable-dep-of: d2ff5fb93ea8 ("smb: client: clean up failed cached directory opens")
---
fs/smb/client/smb2file.c | 2 +-
fs/smb/client/smb2inode.c | 2 +-
fs/smb/client/smb2maperror.c | 2 +-
fs/smb/client/smb2misc.c | 2 +-
fs/smb/client/smb2ops.c | 2 +-
fs/smb/client/smb2pdu.c | 2 +-
fs/smb/client/smb2transport.c | 2 +-
fs/smb/{client => common}/smb2status.h | 2 +
fs/smb/server/oplock.c | 2 +-
fs/smb/server/server.c | 2 +-
fs/smb/server/smb2misc.c | 2 +-
fs/smb/server/smb2pdu.c | 2 +-
fs/smb/server/smb_common.c | 2 +-
fs/smb/server/smbstatus.h | 1822 ------------------------
fs/smb/server/transport_rdma.c | 2 +-
15 files changed, 15 insertions(+), 1835 deletions(-)
rename fs/smb/{client => common}/smb2status.h (99%)
delete mode 100644 fs/smb/server/smbstatus.hfs/smb/client/smb2file.c +1 -1
@@ -21,7 +21,7 @@#include "cifs_unicode.h" #include "fscache.h" #include "smb2proto.h" -#include "smb2status.h" +#include "../common/smb2status.h" static struct smb2_symlink_err_rsp *symlink_data (const struct kvec *iov) {
fs/smb/client/smb2inode.c +1 -1
@@ -24,7 +24,7 @@#include "smb2pdu.h" #include "smb2proto.h" #include "cached_dir.h" -#include "smb2status.h" +#include "../common/smb2status.h" static inline __u32 file_create_options (struct dentry *dentry) {
fs/smb/client/smb2maperror.c +1 -1
@@ -12,7 +12,7 @@#include "cifs_debug.h" #include "smb2pdu.h" #include "smb2proto.h" -#include "smb2status.h" +#include "../common/smb2status.h" #include "smb2glob.h" #include "trace.h"
fs/smb/client/smb2misc.c +1 -1
@@ -13,7 +13,7 @@#include "smb2proto.h" #include "cifs_debug.h" #include "cifs_unicode.h" -#include "smb2status.h" +#include "../common/smb2status.h" #include "smb2glob.h" #include "nterr.h" #include "cached_dir.h"
fs/smb/client/smb2ops.c +1 -1
@@ -21,7 +21,7 @@#include "cifsproto.h" #include "cifs_debug.h" #include "cifs_unicode.h" -#include "smb2status.h" +#include "../common/smb2status.h" #include "smb2glob.h" #include "cifs_ioctl.h" #include "smbdirect.h"
fs/smb/client/smb2pdu.c +1 -1
@@ -30,7 +30,7 @@#include "cifs_unicode.h" #include "cifs_debug.h" #include "ntlmssp.h" -#include "smb2status.h" +#include "../common/smb2status.h" #include "smb2glob.h" #include "cifspdu.h" #include "cifs_spnego.h"
fs/smb/client/smb2transport.c +1 -1
@@ -24,7 +24,7 @@#include "cifsproto.h" #include "smb2proto.h" #include "cifs_debug.h" -#include "smb2status.h" +#include "../common/smb2status.h" #include "smb2glob.h" static int
fs/smb/common/smb2status.h renamed from fs/smb/client/smb2status.h +2 -0
@@ -1769,3 +1769,5 @@ struct ntstatus {#define STATUS_IPSEC_INVALID_PACKET cpu_to_le32(0xC0360005)#define STATUS_IPSEC_INTEGRITY_CHECK_FAILED cpu_to_le32(0xC0360006)#define STATUS_IPSEC_CLEAR_TEXT_DROP cpu_to_le32(0xC0360007) +#define STATUS_NO_PREAUTH_INTEGRITY_HASH_OVERLAP cpu_to_le32(0xC05D0000) +#define STATUS_INVALID_LOCK_RANGE cpu_to_le32(0xC00001a1)
fs/smb/server/oplock.c +1 -1
@@ -10,7 +10,7 @@#include "oplock.h" #include "smb_common.h" -#include "smbstatus.h" +#include "../common/smb2status.h" #include "connection.h" #include "mgmt/user_session.h" #include "mgmt/share_config.h"
fs/smb/server/server.c +1 -1
@@ -15,7 +15,7 @@#include "server.h" #include "smb_common.h" -#include "smbstatus.h" +#include "../common/smb2status.h" #include "connection.h" #include "transport_ipc.h" #include "mgmt/user_session.h"
fs/smb/server/smb2misc.c +1 -1
@@ -7,7 +7,7 @@#include "glob.h" #include "nterr.h" #include "smb_common.h" -#include "smbstatus.h" +#include "../common/smb2status.h" #include "mgmt/user_session.h" #include "connection.h"
fs/smb/server/smb2pdu.c +1 -1
@@ -31,7 +31,7 @@#include "server.h" #include "smb_common.h" -#include "smbstatus.h" +#include "../common/smb2status.h" #include "ksmbd_work.h" #include "mgmt/user_config.h" #include "mgmt/share_config.h"
fs/smb/server/smb_common.c +1 -1
@@ -9,7 +9,7 @@#include "smb_common.h" #include "server.h" #include "misc.h" -#include "smbstatus.h" +#include "../common/smb2status.h" #include "connection.h" #include "ksmbd_work.h" #include "mgmt/user_session.h"
fs/smb/server/smbstatus.h deleted +0 -1822
1,822 lines not on this page · raw message
fs/smb/server/transport_rdma.c +1 -1
@@ -21,7 +21,7 @@#include "glob.h" #include "connection.h" #include "smb_common.h" -#include "smbstatus.h" +#include "../common/smb2status.h" #include "transport_rdma.h" #define SMB_DIRECT_PORT_IWARP 5445
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 smb: client: clean up failed cached directory opens
From: Zihan Xi <[email protected]>
[ 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.
--- fs/smb/client/cached_dir.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-)
fs/smb/client/cached_dir.c +22 -10
@@ -8,6 +8,7 @@#include <linux/namei.h> #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);
Signature · 1 line
2.53.0