public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] smb: client: Fix match_session bug preventing session reuse" failed to apply to 6.13-stable tree
@ 2025-03-16  7:39 gregkh
  2025-03-17 15:32 ` [PATCH 6.13.y] smb: client: Fix match_session bug preventing session reuse Henrique Carvalho
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: gregkh @ 2025-03-16  7:39 UTC (permalink / raw)
  To: henrique.carvalho, ematsumiya, stfrench; +Cc: stable


The patch below does not apply to the 6.13-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-6.13.y
git checkout FETCH_HEAD
git cherry-pick -x 605b249ea96770ac4fac4b8510a99e0f8442be5e
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2025031652-spider-flying-c68b@gregkh' --subject-prefix 'PATCH 6.13.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 <henrique.carvalho@suse.com>
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

Cc: stable@vger.kernel.org
Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de>
Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>

diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index f917de020dd5..73f93a35eedd 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -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) {


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 6.13.y] smb: client: Fix match_session bug preventing session reuse
  2025-03-16  7:39 FAILED: patch "[PATCH] smb: client: Fix match_session bug preventing session reuse" failed to apply to 6.13-stable tree gregkh
@ 2025-03-17 15:32 ` Henrique Carvalho
  2025-03-17 17:16   ` Sasha Levin
  2025-03-17 18:16 ` Henrique Carvalho
  2025-03-18 18:08 ` [PATCH 6.13.y v3] " Henrique Carvalho
  2 siblings, 1 reply; 8+ messages in thread
From: Henrique Carvalho @ 2025-03-17 15:32 UTC (permalink / raw)
  To: stable; +Cc: Henrique Carvalho, Enzo Matsumiya, Steve French

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

Cc: stable@vger.kernel.org
Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de>
Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 605b249ea96770ac4fac4b8510a99e0f8442be5e)
---
 fs/smb/client/connect.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index eaa6be4456d0..a5d443c42996 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -1873,9 +1873,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;
@@ -1887,11 +1886,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) {
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 6.13.y] smb: client: Fix match_session bug preventing session reuse
  2025-03-17 15:32 ` [PATCH 6.13.y] smb: client: Fix match_session bug preventing session reuse Henrique Carvalho
@ 2025-03-17 17:16   ` Sasha Levin
  0 siblings, 0 replies; 8+ messages in thread
From: Sasha Levin @ 2025-03-17 17:16 UTC (permalink / raw)
  To: stable, henrique.carvalho; +Cc: Sasha Levin

[ Sasha's backport helper bot ]

Hi,

Summary of potential issues:
❌ Build failures detected
⚠️ Found matching upstream commit but patch is missing proper reference to it

Found matching upstream commit: 605b249ea96770ac4fac4b8510a99e0f8442be5e

Note: The patch differs from the upstream commit:
---
1:  605b249ea9677 ! 1:  29e0a26570fa5 smb: client: Fix match_session bug preventing session reuse
    @@ Commit message
         Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de>
         Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
         Signed-off-by: Steve French <stfrench@microsoft.com>
    +    (cherry picked from commit 605b249ea96770ac4fac4b8510a99e0f8442be5e)
     
      ## fs/smb/client/connect.c ##
     @@ fs/smb/client/connect.c: static int match_session(struct cifs_ses *ses,
---

Results of testing on various branches:

| Branch                    | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.13.y       |  Success    |  Failed    |

Build Errors:
Build error for stable/linux-6.13.y:
    fs/smb/client/connect.c: In function 'match_session':
    fs/smb/client/connect.c:1896:14: error: 'IAKerb' undeclared (first use in this function)
     1896 |         case IAKerb:
          |              ^~~~~~
    fs/smb/client/connect.c:1896:14: note: each undeclared identifier is reported only once for each function it appears in
    make[5]: *** [scripts/Makefile.build:196: fs/smb/client/connect.o] Error 1
    make[5]: Target 'fs/smb/client/' not remade because of errors.
    make[4]: *** [scripts/Makefile.build:442: fs/smb/client] Error 2
    make[4]: Target 'fs/smb/' not remade because of errors.
    make[3]: *** [scripts/Makefile.build:442: fs/smb] Error 2
    make[3]: Target 'fs/' not remade because of errors.
    make[2]: *** [scripts/Makefile.build:442: fs] Error 2
    make[2]: Target './' not remade because of errors.
    make[1]: *** [/home/sasha/build/linus-next/Makefile:1989: .] Error 2
    make[1]: Target '__all' not remade because of errors.
    make: *** [Makefile:251: __sub-make] Error 2
    make: Target '__all' not remade because of errors.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 6.13.y] smb: client: Fix match_session bug preventing session reuse
  2025-03-16  7:39 FAILED: patch "[PATCH] smb: client: Fix match_session bug preventing session reuse" failed to apply to 6.13-stable tree gregkh
  2025-03-17 15:32 ` [PATCH 6.13.y] smb: client: Fix match_session bug preventing session reuse Henrique Carvalho
@ 2025-03-17 18:16 ` Henrique Carvalho
  2025-03-17 19:51   ` Sasha Levin
  2025-03-18 16:41   ` Greg KH
  2025-03-18 18:08 ` [PATCH 6.13.y v3] " Henrique Carvalho
  2 siblings, 2 replies; 8+ messages in thread
From: Henrique Carvalho @ 2025-03-17 18:16 UTC (permalink / raw)
  To: stable; +Cc: Henrique Carvalho, Enzo Matsumiya, Steve French

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

Cc: stable@vger.kernel.org
Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de>
Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 605b249ea96770ac4fac4b8510a99e0f8442be5e)
---
 fs/smb/client/connect.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index eaa6be4456d0..c9273a90d58e 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -1873,9 +1873,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;
@@ -1887,11 +1886,19 @@ 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 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) {
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 6.13.y] smb: client: Fix match_session bug preventing session reuse
  2025-03-17 18:16 ` Henrique Carvalho
@ 2025-03-17 19:51   ` Sasha Levin
  2025-03-18 16:41   ` Greg KH
  1 sibling, 0 replies; 8+ messages in thread
From: Sasha Levin @ 2025-03-17 19:51 UTC (permalink / raw)
  To: stable, henrique.carvalho; +Cc: Sasha Levin

[ 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

Note: The patch differs from the upstream commit:
---
1:  605b249ea9677 ! 1:  09e6c5e075985 smb: client: Fix match_session bug preventing session reuse
    @@ Commit message
         Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de>
         Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
         Signed-off-by: Steve French <stfrench@microsoft.com>
    +    (cherry picked from commit 605b249ea96770ac4fac4b8510a99e0f8442be5e)
     
      ## fs/smb/client/connect.c ##
     @@ 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,
     +		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.13.y       |  Success    |  Success   |

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 6.13.y] smb: client: Fix match_session bug preventing session reuse
  2025-03-17 18:16 ` Henrique Carvalho
  2025-03-17 19:51   ` Sasha Levin
@ 2025-03-18 16:41   ` Greg KH
  1 sibling, 0 replies; 8+ messages in thread
From: Greg KH @ 2025-03-18 16:41 UTC (permalink / raw)
  To: Henrique Carvalho; +Cc: stable, Enzo Matsumiya, Steve French

On Mon, Mar 17, 2025 at 03:16:22PM -0300, Henrique Carvalho wrote:
> 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
> 
> Cc: stable@vger.kernel.org
> Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de>
> Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
> Signed-off-by: Steve French <stfrench@microsoft.com>
> (cherry picked from commit 605b249ea96770ac4fac4b8510a99e0f8442be5e)
> ---
>  fs/smb/client/connect.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)

I see 2 different versions of this, with no versioning.  Which one is
correct?

Please fix up and send a v3 with the proper information, as-is I have no
idea what to do :(

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 6.13.y v3] smb: client: Fix match_session bug preventing session reuse
  2025-03-16  7:39 FAILED: patch "[PATCH] smb: client: Fix match_session bug preventing session reuse" failed to apply to 6.13-stable tree gregkh
  2025-03-17 15:32 ` [PATCH 6.13.y] smb: client: Fix match_session bug preventing session reuse Henrique Carvalho
  2025-03-17 18:16 ` Henrique Carvalho
@ 2025-03-18 18:08 ` Henrique Carvalho
  2025-03-18 20:12   ` Sasha Levin
  2 siblings, 1 reply; 8+ messages in thread
From: Henrique Carvalho @ 2025-03-18 18:08 UTC (permalink / raw)
  To: stable; +Cc: Henrique Carvalho, Enzo Matsumiya, Steve French

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

Cc: stable@vger.kernel.org
Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de>
Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
(cherry picked from commit 605b249ea96770ac4fac4b8510a99e0f8442be5e)
---
 fs/smb/client/connect.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index eaa6be4456d0..c9273a90d58e 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -1873,9 +1873,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;
@@ -1887,11 +1886,19 @@ 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 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) {
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 6.13.y v3] smb: client: Fix match_session bug preventing session reuse
  2025-03-18 18:08 ` [PATCH 6.13.y v3] " Henrique Carvalho
@ 2025-03-18 20:12   ` Sasha Levin
  0 siblings, 0 replies; 8+ messages in thread
From: Sasha Levin @ 2025-03-18 20:12 UTC (permalink / raw)
  To: stable, henrique.carvalho; +Cc: Sasha Levin

[ 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

Note: The patch differs from the upstream commit:
---
1:  605b249ea9677 ! 1:  eee0817427b12 smb: client: Fix match_session bug preventing session reuse
    @@ Commit message
         Reviewed-by: Enzo Matsumiya <ematsumiya@suse.de>
         Signed-off-by: Henrique Carvalho <henrique.carvalho@suse.com>
         Signed-off-by: Steve French <stfrench@microsoft.com>
    +    (cherry picked from commit 605b249ea96770ac4fac4b8510a99e0f8442be5e)
     
      ## fs/smb/client/connect.c ##
     @@ 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,
     +		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.13.y       |  Success    |  Success   |

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-03-18 20:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-16  7:39 FAILED: patch "[PATCH] smb: client: Fix match_session bug preventing session reuse" failed to apply to 6.13-stable tree gregkh
2025-03-17 15:32 ` [PATCH 6.13.y] smb: client: Fix match_session bug preventing session reuse Henrique Carvalho
2025-03-17 17:16   ` Sasha Levin
2025-03-17 18:16 ` Henrique Carvalho
2025-03-17 19:51   ` Sasha Levin
2025-03-18 16:41   ` Greg KH
2025-03-18 18:08 ` [PATCH 6.13.y v3] " Henrique Carvalho
2025-03-18 20:12   ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox