FAILED: patch "[PATCH] smb: client: Fix match_session bug preventing session reuse" 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 605b249ea96770ac4fac4b8510a99e0f8442be5e
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025031653-guide-earthen-3c35@gregkh' --subject-prefix 'PATCH 6.6.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 605b249ea96770ac4fac4b8510a99e0f8442be5e Mon Sep 17 00:00:00 2001
From: Henrique Carvalho <[email protected]>
Date: Tue, 11 Mar 2025 15:23:59 -0300
Subject: [PATCH] smb: client: Fix match_session bug preventing session reuse
Fix a bug in match_session() that can causes the session to not be reused in some cases.
Reproduction steps:
mount.cifs //server/share /mnt/a -o credentials=creds mount.cifs //server/share /mnt/b -o credentials=creds,sec=ntlmssp cat /proc/fs/cifs/DebugData | grep SessionId | wc -l
mount.cifs //server/share /mnt/b -o credentials=creds,sec=ntlmssp mount.cifs //server/share /mnt/a -o credentials=creds cat /proc/fs/cifs/DebugData | grep SessionId | wc -l
fs/smb/client/connect.c +12 -4
@@ -1825,9 +1825,8 @@ static int match_session(struct cifs_ses *ses, struct smb3_fs_context *ctx, bool match_super) { -if (ctx->sectype != Unspecified && - ctx->sectype != ses->sectype) -return 0 ; +struct TCP_Server_Info *server = ses->server; +enum securityEnum ctx_sec, ses_sec;if (!match_super && ctx->dfs_root_ses != ses->dfs_root_ses)return 0 ;
@@ -1839,11 +1838,20 @@ static int match_session(struct cifs_ses *ses,if (ses->chan_max < ctx->max_channels)return 0 ; -switch (ses->sectype) { + ctx_sec = server->ops->select_sectype (server, ctx->sectype); + ses_sec = server->ops->select_sectype (server, ses->sectype); + +if (ctx_sec != ses_sec) +return 0 ; + +switch (ctx_sec) { +case IAKerb:case Kerberos:if (!uid_eq (ctx->cred_uid, ses->cred_uid))return 0 ;break ; +case NTLMv2: +case RawNTLMSSP:default :/* NULL username means anonymous session */ if (ses->user_name ==NULL ) {
PATCH 1/1 smb: client: Fix match_session bug preventing session reuse
Fix a bug in match_session() that can causes the session to not be reused in some cases.
Reproduction steps:
mount.cifs //server/share /mnt/a -o credentials=creds mount.cifs //server/share /mnt/b -o credentials=creds,sec=ntlmssp cat /proc/fs/cifs/DebugData | grep SessionId | wc -l
mount.cifs //server/share /mnt/b -o credentials=creds,sec=ntlmssp mount.cifs //server/share /mnt/a -o credentials=creds cat /proc/fs/cifs/DebugData | grep SessionId | wc -l
--- fs/smb/client/connect.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
fs/smb/client/connect.c +11 -4
@@ -1884,9 +1884,8 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx,/* this function must be called with ses_lock and chan_lock held */ static int match_session (struct cifs_ses *ses,struct smb3_fs_context *ctx) { -if (ctx->sectype != Unspecified && - ctx->sectype != ses->sectype) -return 0 ; +struct TCP_Server_Info *server = ses->server; +enum securityEnum ctx_sec, ses_sec;if (ctx->dfs_root_ses != ses->dfs_root_ses)return 0 ;
@@ -1898,11 +1897,19 @@ static int match_session(struct cifs_ses *ses, struct smb3_fs_context *ctx)if (ses->chan_max < ctx->max_channels)return 0 ; -switch (ses->sectype) { + ctx_sec = server->ops->select_sectype (server, ctx->sectype); + ses_sec = server->ops->select_sectype (server, ses->sectype); + +if (ctx_sec != ses_sec) +return 0 ; + +switch (ctx_sec) {case Kerberos:if (!uid_eq (ctx->cred_uid, ses->cred_uid))return 0 ;break ; +case NTLMv2: +case RawNTLMSSP:default :/* NULL username means anonymous session */ if (ses->user_name ==NULL ) {
Signature · 1 line
2.47.0
Re: [PATCH 6.6.y] smb: client: Fix match_session bug preventing session reuse
[ Sasha's backport helper bot ]
Hi,
Summary of potential issues:
⚠️ Found matching upstream commit but patch is missing proper reference to it
Found matching upstream commit: 605b249ea96770ac4fac4b8510a99e0f8442be5e
Status in newer kernel trees:
6.13.y | Present (different SHA1: 4a133bda03ec)
6.12.y | Present (different SHA1: 3d48d46299be)
Note: The patch differs from the upstream commit:
---
1: 605b249ea9677 ! 1: 4bb32947f2ce5 smb: client: Fix match_session bug preventing session reuse
@@ Commit message
+ (cherry picked from commit 605b249ea96770ac4fac4b8510a99e0f8442be5e)
## fs/smb/client/connect.c ##
-@@ fs/smb/client/connect.c: static int match_session(struct cifs_ses *ses,
- struct smb3_fs_context *ctx,
- bool match_super)
+@@ fs/smb/client/connect.c: cifs_get_tcp_session(struct smb3_fs_context *ctx,
+ /* this function must be called with ses_lock and chan_lock held */
+ static int match_session(struct cifs_ses *ses, struct smb3_fs_context *ctx) {
- if (ctx->sectype != Unspecified &&
- ctx->sectype != ses->sectype)
@@ fs/smb/client/connect.c: static int match_session(struct cifs_ses *ses,
+ struct TCP_Server_Info *server = ses->server;
+ enum securityEnum ctx_sec, ses_sec;
- if (!match_super && ctx->dfs_root_ses != ses->dfs_root_ses)
+ if (ctx->dfs_root_ses != ses->dfs_root_ses)
return 0;
-@@ fs/smb/client/connect.c: static int match_session(struct cifs_ses *ses,
+@@ fs/smb/client/connect.c: static int match_session(struct cifs_ses *ses, struct smb3_fs_context *ctx)
if (ses->chan_max < ctx->max_channels)
return 0;
@@ fs/smb/client/connect.c: static int match_session(struct cifs_ses *ses,
+ return 0;
+
+ switch (ctx_sec) {
-+ case IAKerb:
case Kerberos:
if (!uid_eq(ctx->cred_uid, ses->cred_uid))
return 0;
---
Results of testing on various branches:
| Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-6.6.y | Success | Success |