diff mbox series

smb: client: fix null auth

Message ID 20230815-fix-cifs-null-auth-v1-1-3cb785216d97@redhat.com (mailing list archive)
State New, archived
Headers show
Series smb: client: fix null auth | expand

Commit Message

Scott Mayhew Aug. 15, 2023, 5:49 p.m. UTC
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(+)


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

Best regards,

Comments

Paulo Alcantara Aug. 15, 2023, 6:40 p.m. UTC | #1
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>
Steve French Aug. 16, 2023, 5:28 a.m. UTC | #2
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>
>
diff mbox series

Patch

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;