linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] smb: client: fix null auth
@ 2023-08-15 17:49 Scott Mayhew
  2023-08-15 18:40 ` Paulo Alcantara
  0 siblings, 1 reply; 3+ messages in thread
From: Scott Mayhew @ 2023-08-15 17:49 UTC (permalink / raw)
  To: Steve French, Paulo Alcantara, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, Paulo Alcantara (SUSE)
  Cc: Steve French, linux-cifs, samba-technical, linux-kernel, Scott Mayhew

Commit abdb1742a312 removed code that clears ctx->username when
sec=none, so attempting to mount with '-o sec=none' now fails with
-EACCES.  Fix it by adding that logic to the parsing of the 'sec'
option, as well as checking if the mount is using null auth before
setting the username when parsing the 'user' option.

Fixes: abdb1742a312 ("cifs: get rid of mount options string parsing")
Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
 fs/smb/client/fs_context.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index 4946a0c59600..67e16c2ac90e 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -231,6 +231,8 @@ cifs_parse_security_flavors(struct fs_context *fc, char *value, struct smb3_fs_c
 		break;
 	case Opt_sec_none:
 		ctx->nullauth = 1;
+		kfree(ctx->username);
+		ctx->username = NULL;
 		break;
 	default:
 		cifs_errorf(fc, "bad security option: %s\n", value);
@@ -1201,6 +1203,8 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
 	case Opt_user:
 		kfree(ctx->username);
 		ctx->username = NULL;
+		if (ctx->nullauth)
+			break;
 		if (strlen(param->string) == 0) {
 			/* null user, ie. anonymous authentication */
 			ctx->nullauth = 1;

---
base-commit: 91aa6c412d7f85e48aead7b00a7d9e91f5cf5863
change-id: 20230815-fix-cifs-null-auth-40c53f41c327

Best regards,
-- 
Scott Mayhew <smayhew@redhat.com>


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

* Re: [PATCH] smb: client: fix null auth
  2023-08-15 17:49 [PATCH] smb: client: fix null auth Scott Mayhew
@ 2023-08-15 18:40 ` Paulo Alcantara
  2023-08-16  5:28   ` Steve French
  0 siblings, 1 reply; 3+ messages in thread
From: Paulo Alcantara @ 2023-08-15 18:40 UTC (permalink / raw)
  To: Scott Mayhew, Steve French, Ronnie Sahlberg, Shyam Prasad N, Tom Talpey
  Cc: Steve French, linux-cifs, samba-technical, linux-kernel, Scott Mayhew

Scott Mayhew <smayhew@redhat.com> writes:

> Commit abdb1742a312 removed code that clears ctx->username when
> sec=none, so attempting to mount with '-o sec=none' now fails with
> -EACCES.  Fix it by adding that logic to the parsing of the 'sec'
> option, as well as checking if the mount is using null auth before
> setting the username when parsing the 'user' option.
>
> Fixes: abdb1742a312 ("cifs: get rid of mount options string parsing")
> Signed-off-by: Scott Mayhew <smayhew@redhat.com>
> ---
>  fs/smb/client/fs_context.c | 4 ++++
>  1 file changed, 4 insertions(+)

Reviewed-by: Paulo Alcantara (SUSE) <pc@manguebit.com>

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

* Re: [PATCH] smb: client: fix null auth
  2023-08-15 18:40 ` Paulo Alcantara
@ 2023-08-16  5:28   ` Steve French
  0 siblings, 0 replies; 3+ messages in thread
From: Steve French @ 2023-08-16  5:28 UTC (permalink / raw)
  To: Paulo Alcantara
  Cc: Scott Mayhew, Steve French, Ronnie Sahlberg, Shyam Prasad N,
	Tom Talpey, linux-cifs, samba-technical, linux-kernel,
	Steve French

[-- Attachment #1: Type: text/plain, Size: 913 bytes --]

Fixed some checkpatch warnings and added Paulo's RB, and updated
cifs-2.6.git for-next


On Tue, Aug 15, 2023 at 1:42 PM Paulo Alcantara via samba-technical
<samba-technical@lists.samba.org> wrote:
>
> Scott Mayhew <smayhew@redhat.com> writes:
>
> > Commit abdb1742a312 removed code that clears ctx->username when
> > sec=none, so attempting to mount with '-o sec=none' now fails with
> > -EACCES.  Fix it by adding that logic to the parsing of the 'sec'
> > option, as well as checking if the mount is using null auth before
> > setting the username when parsing the 'user' option.
> >
> > Fixes: abdb1742a312 ("cifs: get rid of mount options string parsing")
> > Signed-off-by: Scott Mayhew <smayhew@redhat.com>
> > ---
> >  fs/smb/client/fs_context.c | 4 ++++
> >  1 file changed, 4 insertions(+)
>
> Reviewed-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
>


-- 
Thanks,

Steve

[-- Attachment #2: 0001-smb-client-fix-null-auth.patch --]
[-- Type: text/x-patch, Size: 1603 bytes --]

From 270d73e6507f9c7fff43844d74f86365df000b36 Mon Sep 17 00:00:00 2001
From: Scott Mayhew <smayhew@redhat.com>
Date: Wed, 16 Aug 2023 00:23:56 -0500
Subject: [PATCH] smb: client: fix null auth

Commit abdb1742a312 removed code that clears ctx->username when sec=none, so attempting
to mount with '-o sec=none' now fails with -EACCES.  Fix it by adding that logic to the
parsing of the 'sec' option, as well as checking if the mount is using null auth before
setting the username when parsing the 'user' option.

Fixes: abdb1742a312 ("cifs: get rid of mount options string parsing")
Cc: stable@vger.kernel.org
Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Reviewed-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/smb/client/fs_context.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index 4946a0c59600..67e16c2ac90e 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -231,6 +231,8 @@ cifs_parse_security_flavors(struct fs_context *fc, char *value, struct smb3_fs_c
 		break;
 	case Opt_sec_none:
 		ctx->nullauth = 1;
+		kfree(ctx->username);
+		ctx->username = NULL;
 		break;
 	default:
 		cifs_errorf(fc, "bad security option: %s\n", value);
@@ -1201,6 +1203,8 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
 	case Opt_user:
 		kfree(ctx->username);
 		ctx->username = NULL;
+		if (ctx->nullauth)
+			break;
 		if (strlen(param->string) == 0) {
 			/* null user, ie. anonymous authentication */
 			ctx->nullauth = 1;
-- 
2.34.1


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

end of thread, other threads:[~2023-08-16  5:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-15 17:49 [PATCH] smb: client: fix null auth Scott Mayhew
2023-08-15 18:40 ` Paulo Alcantara
2023-08-16  5:28   ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).