smb: client: fix regression with guest option
Subsystems (2)
PATCH 1/1 smb: client: fix regression with guest option
When mounting a CIFS share with 'guest' mount option, mount.cifs(8) will set empty password= and password2= options. Currently we only handle empty strings from user= and password= options, so the mount will fail with
cifs: Bad value for 'password2'
Fix this by handling empty string from password2= option as well.
--- fs/smb/client/fs_context.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/smb/client/fs_context.c +4 -0
@@ -171,6 +171,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {fsparam_string ("username" , Opt_user),fsparam_string ("pass" , Opt_pass),fsparam_string ("password" , Opt_pass), +fsparam_string ("pass2" , Opt_pass2),fsparam_string ("password2" , Opt_pass2),fsparam_string ("ip" , Opt_ip), fsparam_string("addr", Opt_ip),
@@ -1131,6 +1132,9 @@ static int smb3_fs_context_parse_param(struct fs_context *fc, }else if (!strcmp ("user" , param->key) || !strcmp ("username" , param->key)) { skip_parsing = true; opt = Opt_user; + }else if (!strcmp ("pass2" , param->key) || !strcmp ("password2" , param->key)) { + skip_parsing = true; + opt = Opt_pass2; } }
Signature · 1 line
2.48.1
merged into cifs-2.6.git for-next pending additional testing/review
Presumably we could also update cifs-utils (mount.cifs.c) to workaround this as well. Thoughts?
Quoted 44 lines · Paulo Alcantara
When mounting a CIFS share with 'guest' mount option,
mount.cifs(8)will set empty password= and password2= options. Currently we only handle empty strings from user= and password= options, so the mount will fail withcifs: Bad value for 'password2'
Fix this by handling empty string from password2= option as well.
Reported-by Adam Williamson <[email protected]>Fixes 35f834265e0d ("smb3: fix broken reconnect when password changing on the server by allowing password rotation")Signed-off-by Paulo Alcantara (Red Hat) <[email protected]>--- fs/smb/client/fs_context.c | 4 ++++ 1 file changed, 4 insertions(+)fs/smb/client/fs_context.c +4
-1@@ -171,6 +171,7 @@ const struct fs_parameter_spec smb3_fs_parameters[] = {fsparam_string ("username" , Opt_user),fsparam_string ("pass" , Opt_pass),fsparam_string ("password" , Opt_pass), +fsparam_string ("pass2" , Opt_pass2),fsparam_string ("password2" , Opt_pass2),fsparam_string ("ip" , Opt_ip), fsparam_string("addr", Opt_ip),@@ -1131,6 +1132,9 @@ static int smb3_fs_context_parse_param(struct fs_context *fc, }else if (!strcmp ("user" , param->key) || !strcmp ("username" , param->key)) { skip_parsing = true; opt = Opt_user; + }else if (!strcmp ("pass2" , param->key) || !strcmp ("password2" , param->key)) { + skip_parsing = true; + opt = Opt_pass2; } } --2.48.1
Signature · 3 lines
Thanks, Steve
Quoted 4 lines · Steve French
merged into cifs-2.6.git for-next pending additional testing/review
Presumably we could also update cifs-utils (
mount.cifs.c) to workaround this as well. Thoughts?
Yeah, I was going to ask whether just not passing password2 when doing anonymous mount might be an option? That way the new cifs-utils will work with older kernels, rather than being a sudden surprise for anyone who happens to get a new cifs-utils but not a new kernel, for whatever reason...
Signature · 4 lines
Adam Williamson (he/him/his) Fedora QA Fedora Chat: @adamwill:fedora.im | Mastodon: @[email protected] https://www.happyassassin.net
Quoted 10 lines · Adam Williamson
Quoted 4 lines · Steve French
merged into cifs-2.6.git for-next pending additional testing/review
Presumably we could also update cifs-utils (
mount.cifs.c) to workaround this as well. Thoughts?Yeah, I was going to ask whether just not passing password2 when doing anonymous mount might be an option? That way the new cifs-utils will work with older kernels, rather than being a sudden surprise for anyone who happens to get a new cifs-utils but not a new kernel, for whatever
Yes, we could also change cifs-utils to not send both password= and password2= when using guest mount option.
The kernel change is still required in case someone is using mount(2) directly and end up passing an empty password2= option.
Meetakshi sent a patch idea to try (to also fix this in cifs-utils) - will take a look
Quoted 19 lines · Paulo Alcantara
Quoted 10 lines · Adam Williamson
Quoted 4 lines · Steve French
merged into cifs-2.6.git for-next pending additional testing/review
Presumably we could also update cifs-utils (
mount.cifs.c) to workaround this as well. Thoughts?Yeah, I was going to ask whether just not passing password2 when doing anonymous mount might be an option? That way the new cifs-utils will work with older kernels, rather than being a sudden surprise for anyone who happens to get a new cifs-utils but not a new kernel, for whatever
Yes, we could also change cifs-utils to not send both password= and password2= when using guest mount option.
The kernel change is still required in case someone is using mount(2) directly and end up passing an empty password2= option.
Signature · 3 lines
Thanks, Steve
Quoted 2 lines · Steve French
Meetakshi sent a patch idea to try (to also fix this in cifs-utils) - will take a look
Where is the patch?
Something like below would work
mount.cifs.c +8 -2
@@ -200,6 +200,7 @@ struct parsed_mount_info { unsigned int got_domain:1; unsigned int is_krb5:1; unsigned int is_noauth:1; + unsigned int is_guest:1;uid_t sudo_uid; };
@@ -1161,6 +1162,7 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) parsed_info->got_user =1 ; parsed_info->got_password =1 ; parsed_info->got_password2 =1 ; + parsed_info->is_guest =1 ; goto nocopy;case OPT_RO : *filesys_flags |=MS_RDONLY ;
@@ -2334,7 +2336,9 @@ mount_retry:fprintf (stderr,"%s kernel mount options: %s" , thisprogram, options); -if (parsed_info->got_password && !(parsed_info->is_krb5 || parsed_info->is_noauth)) { +if (parsed_info->got_password && + !(parsed_info->is_krb5 || parsed_info->is_noauth || + parsed_info->is_guest)) {/* * Commas have to be doubled, or else they will * look like the parameter separator
@@ -2345,7 +2349,9 @@ mount_retry:fprintf (stderr,",pass=********" ); } -if (parsed_info->got_password2 && !(parsed_info->is_krb5 || parsed_info->is_noauth)) { +if (parsed_info->got_password2 && + !(parsed_info->is_krb5 || parsed_info->is_noauth || + parsed_info->is_guest)) {strlcat (options,",password2=" , options_size);strlcat (options, parsed_info->password2, options_size);if (parsed_info->verboseflag)
Thanks Paulo, created a PR for cifs-utils based on your suggestion
https://github.com/smfrench/smb3-utils/pull/14
Thanks
Meetakshi
Quoted 52 lines · Paulo Alcantara
Quoted 2 lines · Steve French
Meetakshi sent a patch idea to try (to also fix this in cifs-utils) - will take a look
Where is the patch?
Something like below would work
mount.cifs.c +8
-2@@ -200,6 +200,7 @@ struct parsed_mount_info { unsigned int got_domain:1; unsigned int is_krb5:1; unsigned int is_noauth:1; + unsigned int is_guest:1;uid_t sudo_uid; };@@ -1161,6 +1162,7 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) parsed_info->got_user =1 ; parsed_info->got_password =1 ; parsed_info->got_password2 =1 ; + parsed_info->is_guest =1 ; goto nocopy;case OPT_RO : *filesys_flags |=MS_RDONLY ;@@ -2334,7 +2336,9 @@ mount_retry:fprintf (stderr,"%s kernel mount options: %s" , thisprogram, options); -if (parsed_info->got_password && !(parsed_info->is_krb5 || parsed_info->is_noauth)) { +if (parsed_info->got_password && + !(parsed_info->is_krb5 || parsed_info->is_noauth || + parsed_info->is_guest)) {/* * Commas have to be doubled, or else they will * look like the parameter separator @@ -2345,7 +2349,9 @@ mount_retry:fprintf (stderr,",pass=********" ); } -if (parsed_info->got_password2 && !(parsed_info->is_krb5 || parsed_info->is_noauth)) { +if (parsed_info->got_password2 && + !(parsed_info->is_krb5 || parsed_info->is_noauth || + parsed_info->is_guest)) {strlcat (options,",password2=" , options_size);strlcat (options, parsed_info->password2, options_size);if (parsed_info->verboseflag)
Quoted 2 lines · Meetakshi Setiya
Thanks Paulo, created a PR for cifs-utils based on your suggestion
https://github.com/smfrench/smb3-utils/pull/14
LGTM. Thanks!
Made minor updates to the patch (white space cleanup that checkpatch spotted) and added the RB (see attached)
Merged into github smb3-utils for-next branch and also to cifs-utils samba.org for-next
https://git.samba.org/?p=cifs-utils.git;a=shortlog;h=refs/heads/for-next
Quoted 60 lines · Meetakshi Setiya
Thanks Paulo, created a PR for cifs-utils based on your suggestion
https://github.com/smfrench/smb3-utils/pull/14Thanks
MeetakshiQuoted 52 lines · Paulo Alcantara
Quoted 2 lines · Steve French
Meetakshi sent a patch idea to try (to also fix this in cifs-utils) - will take a look
Where is the patch?
Something like below would work
mount.cifs.c +8
-2@@ -200,6 +200,7 @@ struct parsed_mount_info { unsigned int got_domain:1; unsigned int is_krb5:1; unsigned int is_noauth:1; + unsigned int is_guest:1;uid_t sudo_uid; };@@ -1161,6 +1162,7 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) parsed_info->got_user =1 ; parsed_info->got_password =1 ; parsed_info->got_password2 =1 ; + parsed_info->is_guest =1 ; goto nocopy;case OPT_RO : *filesys_flags |=MS_RDONLY ;@@ -2334,7 +2336,9 @@ mount_retry:fprintf (stderr,"%s kernel mount options: %s" , thisprogram, options); -if (parsed_info->got_password && !(parsed_info->is_krb5 || parsed_info->is_noauth)) { +if (parsed_info->got_password && + !(parsed_info->is_krb5 || parsed_info->is_noauth || + parsed_info->is_guest)) {/* * Commas have to be doubled, or else they will * look like the parameter separator @@ -2345,7 +2349,9 @@ mount_retry:fprintf (stderr,",pass=********" ); } -if (parsed_info->got_password2 && !(parsed_info->is_krb5 || parsed_info->is_noauth)) { +if (parsed_info->got_password2 && + !(parsed_info->is_krb5 || parsed_info->is_noauth || + parsed_info->is_guest)) {strlcat (options,",password2=" , options_size);strlcat (options, parsed_info->password2, options_size);if (parsed_info->verboseflag)
Signature · 3 lines
Thanks, Steve
From ac4d6e9cf69e1794dff061d62f727388a3b8b12b Mon Sep 17 00:00:00 2001
From: Meetakshi Setiya <[email protected]>
Date: Sat, 15 Mar 2025 06:49:13 +0000
Subject: [PATCH] Fix regression in mount.cifs with guest mount option
mount.cifs was erroneously passing the empty password and password2 strings to the linux smb client for "guest" mounts. Handling empty password2 has not been implemented on the client yet, which ends up failing the mount with "cifs: Bad value for password2".
This patch contains fixes for the mentioned scenario.
--- mount.cifs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
mount.cifs.c +6 -2
@@ -200,6 +200,7 @@ struct parsed_mount_info { unsigned int got_domain:1; unsigned int is_krb5:1; unsigned int is_noauth:1; + unsigned int is_guest:1;uid_t sudo_uid; };
@@ -1158,6 +1159,7 @@ parse_options(const char *data, struct parsed_mount_info *parsed_info) *filesys_flags &= ~MS_NOEXEC ; goto nocopy;case OPT_GUEST : + parsed_info->is_guest =1 ; parsed_info->got_user =1 ; parsed_info->got_password =1 ; parsed_info->got_password2 =1 ;
@@ -2334,7 +2336,8 @@ mount_retry:fprintf (stderr,"%s kernel mount options: %s" , thisprogram, options); -if (parsed_info->got_password && !(parsed_info->is_krb5 || parsed_info->is_noauth)) { +if (parsed_info->got_password && + !(parsed_info->is_krb5 || parsed_info->is_noauth || parsed_info->is_guest)) {/* * Commas have to be doubled, or else they will * look like the parameter separator
@@ -2345,7 +2348,8 @@ mount_retry:fprintf (stderr,",pass=********" ); } -if (parsed_info->got_password2 && !(parsed_info->is_krb5 || parsed_info->is_noauth)) { +if (parsed_info->got_password2 && + !(parsed_info->is_krb5 || parsed_info->is_noauth || parsed_info->is_guest)) {strlcat (options,",password2=" , options_size);strlcat (options, parsed_info->password2, options_size);if (parsed_info->verboseflag)
Signature · 1 line
2.43.0