Skip to content

Commit

Permalink
smb: client: fix null auth
Browse files Browse the repository at this point in the history
commit 270d73e upstream.

Commit abdb174 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: abdb174 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
scottmayhew authored and gregkh committed Aug 23, 2023
1 parent b8e7ee1 commit abcd2a0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/smb/client/fs_context.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit abcd2a0

Please sign in to comment.