All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix guest smb3.1.1 mounts to Samba
@ 2019-03-23  1:01 Steve French
  2019-03-23  3:35 ` Steve French
  0 siblings, 1 reply; 3+ messages in thread
From: Steve French @ 2019-03-23  1:01 UTC (permalink / raw)
  To: ronnie sahlberg, CIFS

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

Add to Ronnie's patch check for null user so we can handle guest
mounts for 3.1.1 to Samba as well



-- 
Thanks,

Steve

[-- Attachment #2: 0001-SMB3-Fix-SMB3.1.1-guest-mounts-to-Samba.patch --]
[-- Type: text/x-patch, Size: 2205 bytes --]

From 5f377dd082fe24ced7fd5a8d31d7fac3af5686b9 Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Fri, 22 Mar 2019 19:52:29 -0500
Subject: [PATCH] SMB3: Fix SMB3.1.1 guest mounts to Samba

Workaround problem with Samba responses to SMB3.1.1
null user (guest) mounts.  The server doesn't set the
expected flag in the session setup response so we have
to do a similar check to what is done in smb3_validate_negotiate
where we also check if the user is a null user.

Note that the commit below tightened the conditions and forced signing
for the SMB2-TreeConnect commands as per MS-SMB2.
However, this should only apply to normal user sessions and not for
cases where there is no user (even if server forgets to set the flag
in the response) since we don't have anything useful to sign with.
This is especially important now that the more secure SMB3.1.1 protocol
is in the default dialect list.

An earlier patch ("cifs: allow guest mounts to work for smb3.11") fixed
the guest mounts to Windows.

    Fixes: 6188f28bf608 ("Tree connect for SMB3.1.1 must be signed for non-encrypted shares")

Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
CC: Stable <stable@vger.kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/smb2pdu.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 8e4a1da95418..4cdf26e39426 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -1631,10 +1631,13 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
 	/*
 	 * 3.11 tcon req must be signed if not encrypted. See MS-SMB2 3.2.4.1.1
 	 * unless it is guest or anonymous user. See MS-SMB2 3.2.5.3.1
+	 * (Samba servers don't always set the flag so also check if null user)
 	 */
 	if ((ses->server->dialect == SMB311_PROT_ID) &&
 	    !smb3_encryption_required(tcon) &&
-	    !(ses->session_flags & (SMB2_SESSION_FLAG_IS_GUEST|SMB2_SESSION_FLAG_IS_NULL)))
+	    !(ses->session_flags &
+		    (SMB2_SESSION_FLAG_IS_GUEST|SMB2_SESSION_FLAG_IS_NULL)) &&
+	    (ses->user_name != NULL))
 		req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED;
 
 	memset(&rqst, 0, sizeof(struct smb_rqst));
-- 
2.17.1


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

* Re: [PATCH] Fix guest smb3.1.1 mounts to Samba
  2019-03-23  1:01 [PATCH] Fix guest smb3.1.1 mounts to Samba Steve French
@ 2019-03-23  3:35 ` Steve French
  2019-03-23 15:36   ` Andreas Hasenack
  0 siblings, 1 reply; 3+ messages in thread
From: Steve French @ 2019-03-23  3:35 UTC (permalink / raw)
  To: ronnie sahlberg, CIFS

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

Version 2 of patch added additional check that it is not krb5 mount
when username is null


On Fri, Mar 22, 2019 at 8:01 PM Steve French <smfrench@gmail.com> wrote:
>
> Add to Ronnie's patch check for null user so we can handle guest
> mounts for 3.1.1 to Samba as well
>
>
>
> --
> Thanks,
>
> Steve



-- 
Thanks,

Steve

[-- Attachment #2: 0001-SMB3-Fix-SMB3.1.1-guest-mounts-to-Samba.patch --]
[-- Type: text/x-patch, Size: 2321 bytes --]

From 49bc93dc3371b9068e1c973f5169ab96c068a787 Mon Sep 17 00:00:00 2001
From: Steve French <stfrench@microsoft.com>
Date: Fri, 22 Mar 2019 22:31:17 -0500
Subject: [PATCH] SMB3: Fix SMB3.1.1 guest mounts to Samba

Workaround problem with Samba responses to SMB3.1.1
null user (guest) mounts.  The server doesn't set the
expected flag in the session setup response so we have
to do a similar check to what is done in smb3_validate_negotiate
where we also check if the user is a null user (but not sec=krb5
since username might not be passed in on mount for Kerberos case).

Note that the commit below tightened the conditions and forced signing
for the SMB2-TreeConnect commands as per MS-SMB2.
However, this should only apply to normal user sessions and not for
cases where there is no user (even if server forgets to set the flag
in the response) since we don't have anything useful to sign with.
This is especially important now that the more secure SMB3.1.1 protocol
is in the default dialect list.

An earlier patch ("cifs: allow guest mounts to work for smb3.11") fixed
the guest mounts to Windows.

    Fixes: 6188f28bf608 ("Tree connect for SMB3.1.1 must be signed for non-encrypted shares")

Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
CC: Stable <stable@vger.kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
---
 fs/cifs/smb2pdu.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 8e4a1da95418..21ac19ff19cb 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -1631,10 +1631,13 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree,
 	/*
 	 * 3.11 tcon req must be signed if not encrypted. See MS-SMB2 3.2.4.1.1
 	 * unless it is guest or anonymous user. See MS-SMB2 3.2.5.3.1
+	 * (Samba servers don't always set the flag so also check if null user)
 	 */
 	if ((ses->server->dialect == SMB311_PROT_ID) &&
 	    !smb3_encryption_required(tcon) &&
-	    !(ses->session_flags & (SMB2_SESSION_FLAG_IS_GUEST|SMB2_SESSION_FLAG_IS_NULL)))
+	    !(ses->session_flags &
+		    (SMB2_SESSION_FLAG_IS_GUEST|SMB2_SESSION_FLAG_IS_NULL)) &&
+	    ((ses->user_name != NULL) || (ses->sectype == Kerberos)))
 		req->sync_hdr.Flags |= SMB2_FLAGS_SIGNED;
 
 	memset(&rqst, 0, sizeof(struct smb_rqst));
-- 
2.17.1


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

* Re: [PATCH] Fix guest smb3.1.1 mounts to Samba
  2019-03-23  3:35 ` Steve French
@ 2019-03-23 15:36   ` Andreas Hasenack
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Hasenack @ 2019-03-23 15:36 UTC (permalink / raw)
  To: Steve French; +Cc: ronnie sahlberg, CIFS

The current for-next branch (I tested
cf7d624f8dcc9b833a8489208b6ef6dcc5dd308b) worked for me:

root@andreas-disco-cifs:~# mount //localhost/pub /mnt -o guest,vers=3.11
root@andreas-disco-cifs:~# mount -t cifs
//localhost/pub on /mnt type cifs
(rw,relatime,vers=3.1.1,sec=none,cache=strict,uid=0,noforceuid,gid=0,noforcegid,addr=127.0.0.1,file_mode=0755,dir_mode=0755,soft,nounix,serverino,mapposix,rsize=4194304,wsize=4194304,bsize=1048576,echo_interval=60,actimeo=1)

root@andreas-disco-cifs:~# uname -a
Linux andreas-disco-cifs 5.1.0-rc1 #2 SMP Sat Mar 23 15:01:59 UTC 2019
x86_64 x86_64 x86_64 GNU/Linux

On Sat, Mar 23, 2019 at 12:35 AM Steve French <smfrench@gmail.com> wrote:
>
> Version 2 of patch added additional check that it is not krb5 mount
> when username is null
>
>
> On Fri, Mar 22, 2019 at 8:01 PM Steve French <smfrench@gmail.com> wrote:
> >
> > Add to Ronnie's patch check for null user so we can handle guest
> > mounts for 3.1.1 to Samba as well
> >
> >
> >
> > --
> > Thanks,
> >
> > Steve
>
>
>
> --
> Thanks,
>
> Steve

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

end of thread, other threads:[~2019-03-23 15:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-23  1:01 [PATCH] Fix guest smb3.1.1 mounts to Samba Steve French
2019-03-23  3:35 ` Steve French
2019-03-23 15:36   ` Andreas Hasenack

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.