diff mbox

cifs: Set client guid on per connection basis

Message ID 1399938492-20577-1-git-send-email-sprabhu@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sachin Prabhu May 12, 2014, 11:48 p.m. UTC
When mounting from a Windows 2012R2 server, we hit the following
problem:
1) Mount with any of the following versions - 2.0, 2.1 or 3.0
2) unmount
3) Attempt a mount again using a different SMB version >= 2.0.

You end up with the following failure:
Status code returned 0xc0000203 STATUS_USER_SESSION_DELETED
CIFS VFS: Send error in SessSetup = -5
CIFS VFS: cifs_mount failed w/return code = -5

I cannot reproduce this issue using a Windows 2008 R2 server.

This appears to be caused because we use the same client guid for the
connection on first mount which we then disconnect and attempt to mount
again using a different protocol version. By generating a new guid each
time a new connection is Negotiated, we avoid hitting this problem.

Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
---
 fs/cifs/cifsfs.c   | 8 --------
 fs/cifs/cifsglob.h | 1 +
 fs/cifs/connect.c  | 3 +++
 fs/cifs/smb2pdu.c  | 5 +++--
 fs/cifs/smb2pdu.h  | 2 --
 5 files changed, 7 insertions(+), 12 deletions(-)

Comments

Steve French May 13, 2014, 8:49 p.m. UTC | #1
merged into cifs-2.6.git for-next

but added an additional patch to fix the problem where we are sending
a non-zero ClientGUID for SMB2.02 dialect (where it MUST be zero
according to MS-SMB2, it is non-zero starting in SMB2.1)

On Tue, May 13, 2014 at 1:48 AM, Sachin Prabhu <sprabhu@redhat.com> wrote:
> When mounting from a Windows 2012R2 server, we hit the following
> problem:
> 1) Mount with any of the following versions - 2.0, 2.1 or 3.0
> 2) unmount
> 3) Attempt a mount again using a different SMB version >= 2.0.
>
> You end up with the following failure:
> Status code returned 0xc0000203 STATUS_USER_SESSION_DELETED
> CIFS VFS: Send error in SessSetup = -5
> CIFS VFS: cifs_mount failed w/return code = -5
>
> I cannot reproduce this issue using a Windows 2008 R2 server.
>
> This appears to be caused because we use the same client guid for the
> connection on first mount which we then disconnect and attempt to mount
> again using a different protocol version. By generating a new guid each
> time a new connection is Negotiated, we avoid hitting this problem.
>
> Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
> ---
>  fs/cifs/cifsfs.c   | 8 --------
>  fs/cifs/cifsglob.h | 1 +
>  fs/cifs/connect.c  | 3 +++
>  fs/cifs/smb2pdu.c  | 5 +++--
>  fs/cifs/smb2pdu.h  | 2 --
>  5 files changed, 7 insertions(+), 12 deletions(-)
>
> diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
> index 5be1f99..c80aa5a 100644
> --- a/fs/cifs/cifsfs.c
> +++ b/fs/cifs/cifsfs.c
> @@ -87,10 +87,6 @@ extern mempool_t *cifs_mid_poolp;
>
>  struct workqueue_struct        *cifsiod_wq;
>
> -#ifdef CONFIG_CIFS_SMB2
> -__u8 cifs_client_guid[SMB2_CLIENT_GUID_SIZE];
> -#endif
> -
>  /*
>   * Bumps refcount for cifs super block.
>   * Note that it should be only called if a referece to VFS super block is
> @@ -1192,10 +1188,6 @@ init_cifs(void)
>         spin_lock_init(&cifs_file_list_lock);
>         spin_lock_init(&GlobalMid_Lock);
>
> -#ifdef CONFIG_CIFS_SMB2
> -       get_random_bytes(cifs_client_guid, SMB2_CLIENT_GUID_SIZE);
> -#endif
> -
>         if (cifs_max_pending < 2) {
>                 cifs_max_pending = 2;
>                 cifs_dbg(FYI, "cifs_max_pending set to min of 2\n");
> diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
> index 30f6e92..f74edd2 100644
> --- a/fs/cifs/cifsglob.h
> +++ b/fs/cifs/cifsglob.h
> @@ -559,6 +559,7 @@ struct TCP_Server_Info {
>         int echo_credits;  /* echo reserved slots */
>         int oplock_credits;  /* oplock break reserved slots */
>         bool echoes:1; /* enable echoes */
> +       __u8 client_guid[SMB2_CLIENT_GUID_SIZE]; /* Client GUID */
>  #endif
>         u16 dialect; /* dialect index that server chose */
>         bool oplocks:1; /* enable oplocks */
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 8813ff7..8b8fe9b 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -2144,6 +2144,9 @@ cifs_get_tcp_session(struct smb_vol *volume_info)
>                sizeof(tcp_ses->srcaddr));
>         memcpy(&tcp_ses->dstaddr, &volume_info->dstaddr,
>                 sizeof(tcp_ses->dstaddr));
> +#ifdef CONFIG_CIFS_SMB2
> +       get_random_bytes(tcp_ses->client_guid, SMB2_CLIENT_GUID_SIZE);
> +#endif
>         /*
>          * at this point we are the only ones with the pointer
>          * to the struct since the kernel thread not created yet
> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> index 3802f8c..dc44610 100644
> --- a/fs/cifs/smb2pdu.c
> +++ b/fs/cifs/smb2pdu.c
> @@ -375,7 +375,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
>
>         req->Capabilities = cpu_to_le32(ses->server->vals->req_capabilities);
>
> -       memcpy(req->ClientGUID, cifs_client_guid, SMB2_CLIENT_GUID_SIZE);
> +       memcpy(req->ClientGUID, server->client_guid, SMB2_CLIENT_GUID_SIZE);
>
>         iov[0].iov_base = (char *)req;
>         /* 4 for rfc1002 length field */
> @@ -478,7 +478,8 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
>
>         vneg_inbuf.Capabilities =
>                         cpu_to_le32(tcon->ses->server->vals->req_capabilities);
> -       memcpy(vneg_inbuf.Guid, cifs_client_guid, SMB2_CLIENT_GUID_SIZE);
> +       memcpy(vneg_inbuf.Guid, tcon->ses->server->client_guid,
> +                                       SMB2_CLIENT_GUID_SIZE);
>
>         if (tcon->ses->sign)
>                 vneg_inbuf.SecurityMode =
> diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h
> index 2022c54..743e11e 100644
> --- a/fs/cifs/smb2pdu.h
> +++ b/fs/cifs/smb2pdu.h
> @@ -183,8 +183,6 @@ struct smb2_symlink_err_rsp {
>
>  #define SMB2_CLIENT_GUID_SIZE 16
>
> -extern __u8 cifs_client_guid[SMB2_CLIENT_GUID_SIZE];
> -
>  struct smb2_negotiate_req {
>         struct smb2_hdr hdr;
>         __le16 StructureSize; /* Must be 36 */
> --
> 1.8.4.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tom Talpey May 15, 2014, 6:36 a.m. UTC | #2
V29uJ3QgdGhpcyBuZWVkIHRvIGJlIHVuZG9uZSBmb3IgbXVsdGljaGFubmVsIHN1cHBvcnQ/IFRo
ZSBjbGllbnQgR1VJRCBuZWVkcyB0byBiZSB0aGUgc2FtZSB3aGVuIGNvbm5lY3RpbmcgbXVsdGlw
bGUgY2hhbm5lbHMsIGEgZGlmZmVyZW50IG9uZSB3aWxsIGJyZWFrIGNyb3NzLWNoYW5uZWwgcmVw
bGF5IGRldGVjdGlvbi4NCg0KSXQncyBkZWZpbml0ZWx5IHRydWUgdGhhdCBpZiB5b3UgaW50ZW5k
IHRvIG5lZ290aWF0ZSBhIGRpZmZlcmVudCBkaWFsZWN0LCB0aGVuIHRoZSBjbGllbnQgIEdVSUQg
c2hvdWxkIG5vdCBiZSByZXVzZWQuDQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4g
RnJvbTogbGludXgtY2lmcy1vd25lckB2Z2VyLmtlcm5lbC5vcmcgW21haWx0bzpsaW51eC1jaWZz
LQ0KPiBvd25lckB2Z2VyLmtlcm5lbC5vcmddIE9uIEJlaGFsZiBPZiBTdGV2ZSBGcmVuY2gNCj4g
U2VudDogVHVlc2RheSwgTWF5IDEzLCAyMDE0IDEwOjQ5IFBNDQo+IFRvOiBTYWNoaW4gUHJhYmh1
DQo+IENjOiBsaW51eC1jaWZzDQo+IFN1YmplY3Q6IFJlOiBbUEFUQ0hdIGNpZnM6IFNldCBjbGll
bnQgZ3VpZCBvbiBwZXIgY29ubmVjdGlvbiBiYXNpcw0KPiANCj4gbWVyZ2VkIGlud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1bnN1YnNjcmliZSBsaW51eC1j
aWZzIiBpbiB0aGUNCj4gYm9keSBvZiBhIG1lc3NhZ2UgdG8gbWFqb3Jkb21vQHZnZXIua2VybmVs
Lm9yZyBNb3JlIG1ham9yZG9tbyBpbmZvIGF0DQo+IGh0dHA6Ly92Z2VyLmtlcm5lbC5vcmcvbWFq
b3Jkb21vLWluZm8uaHRtbA0K
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Steve French May 15, 2014, 8:12 a.m. UTC | #3
Would multichannel require a new negotiate protocol? We are only
generating it in get_tcp_session - and would probably not go through
that path when connecting another socket to the original parent
struct.   Currently the model where tcons hang off smb sessions which
hang off tcp sessions looks strange when you consider multiple tcp
connections but have to distinguish the code which connects the first
tcp session for a machine and sets up the parent structure that all
the others (tcons and smb sessions) hang off, from the code which
connects subsequent tcp sessions for multichannel

On Thu, May 15, 2014 at 8:36 AM, Tom Talpey <ttalpey@microsoft.com> wrote:
> Won't this need to be undone for multichannel support? The client GUID needs to be the same when connecting multiple channels, a different one will break cross-channel replay detection.
>
> It's definitely true that if you intend to negotiate a different dialect, then the client  GUID should not be reused.
>
>> -----Original Message-----
>> From: linux-cifs-owner@vger.kernel.org [mailto:linux-cifs-
>> owner@vger.kernel.org] On Behalf Of Steve French
>> Sent: Tuesday, May 13, 2014 10:49 PM
>> To: Sachin Prabhu
>> Cc: linux-cifs
>> Subject: Re: [PATCH] cifs: Set client guid on per connection basis
>>
>> merged into cifs-2.6.git for-next
>>
>> but added an additional patch to fix the problem where we are sending a
>> non-zero ClientGUID for SMB2.02 dialect (where it MUST be zero according
>> to MS-SMB2, it is non-zero starting in SMB2.1)
>>
>> On Tue, May 13, 2014 at 1:48 AM, Sachin Prabhu <sprabhu@redhat.com>
>> wrote:
>> > When mounting from a Windows 2012R2 server, we hit the following
>> > problem:
>> > 1) Mount with any of the following versions - 2.0, 2.1 or 3.0
>> > 2) unmount
>> > 3) Attempt a mount again using a different SMB version >= 2.0.
>> >
>> > You end up with the following failure:
>> > Status code returned 0xc0000203 STATUS_USER_SESSION_DELETED CIFS
>> VFS:
>> > Send error in SessSetup = -5 CIFS VFS: cifs_mount failed w/return code
>> > = -5
>> >
>> > I cannot reproduce this issue using a Windows 2008 R2 server.
>> >
>> > This appears to be caused because we use the same client guid for the
>> > connection on first mount which we then disconnect and attempt to
>> > mount again using a different protocol version. By generating a new
>> > guid each time a new connection is Negotiated, we avoid hitting this
>> problem.
>> >
>> > Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>
>> > ---
>> >  fs/cifs/cifsfs.c   | 8 --------
>> >  fs/cifs/cifsglob.h | 1 +
>> >  fs/cifs/connect.c  | 3 +++
>> >  fs/cifs/smb2pdu.c  | 5 +++--
>> >  fs/cifs/smb2pdu.h  | 2 --
>> >  5 files changed, 7 insertions(+), 12 deletions(-)
>> >
>> > diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index
>> > 5be1f99..c80aa5a 100644
>> > --- a/fs/cifs/cifsfs.c
>> > +++ b/fs/cifs/cifsfs.c
>> > @@ -87,10 +87,6 @@ extern mempool_t *cifs_mid_poolp;
>> >
>> >  struct workqueue_struct        *cifsiod_wq;
>> >
>> > -#ifdef CONFIG_CIFS_SMB2
>> > -__u8 cifs_client_guid[SMB2_CLIENT_GUID_SIZE];
>> > -#endif
>> > -
>> >  /*
>> >   * Bumps refcount for cifs super block.
>> >   * Note that it should be only called if a referece to VFS super
>> > block is @@ -1192,10 +1188,6 @@ init_cifs(void)
>> >         spin_lock_init(&cifs_file_list_lock);
>> >         spin_lock_init(&GlobalMid_Lock);
>> >
>> > -#ifdef CONFIG_CIFS_SMB2
>> > -       get_random_bytes(cifs_client_guid, SMB2_CLIENT_GUID_SIZE);
>> > -#endif
>> > -
>> >         if (cifs_max_pending < 2) {
>> >                 cifs_max_pending = 2;
>> >                 cifs_dbg(FYI, "cifs_max_pending set to min of 2\n");
>> > diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index
>> > 30f6e92..f74edd2 100644
>> > --- a/fs/cifs/cifsglob.h
>> > +++ b/fs/cifs/cifsglob.h
>> > @@ -559,6 +559,7 @@ struct TCP_Server_Info {
>> >         int echo_credits;  /* echo reserved slots */
>> >         int oplock_credits;  /* oplock break reserved slots */
>> >         bool echoes:1; /* enable echoes */
>> > +       __u8 client_guid[SMB2_CLIENT_GUID_SIZE]; /* Client GUID */
>> >  #endif
>> >         u16 dialect; /* dialect index that server chose */
>> >         bool oplocks:1; /* enable oplocks */ diff --git
>> > a/fs/cifs/connect.c b/fs/cifs/connect.c index 8813ff7..8b8fe9b 100644
>> > --- a/fs/cifs/connect.c
>> > +++ b/fs/cifs/connect.c
>> > @@ -2144,6 +2144,9 @@ cifs_get_tcp_session(struct smb_vol
>> *volume_info)
>> >                sizeof(tcp_ses->srcaddr));
>> >         memcpy(&tcp_ses->dstaddr, &volume_info->dstaddr,
>> >                 sizeof(tcp_ses->dstaddr));
>> > +#ifdef CONFIG_CIFS_SMB2
>> > +       get_random_bytes(tcp_ses->client_guid, SMB2_CLIENT_GUID_SIZE);
>> > +#endif
>> >         /*
>> >          * at this point we are the only ones with the pointer
>> >          * to the struct since the kernel thread not created yet diff
>> > --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 3802f8c..dc44610
>> > 100644
>> > --- a/fs/cifs/smb2pdu.c
>> > +++ b/fs/cifs/smb2pdu.c
>> > @@ -375,7 +375,7 @@ SMB2_negotiate(const unsigned int xid, struct
>> > cifs_ses *ses)
>> >
>> >         req->Capabilities =
>> > cpu_to_le32(ses->server->vals->req_capabilities);
>> >
>> > -       memcpy(req->ClientGUID, cifs_client_guid,
>> SMB2_CLIENT_GUID_SIZE);
>> > +       memcpy(req->ClientGUID, server->client_guid,
>> > + SMB2_CLIENT_GUID_SIZE);
>> >
>> >         iov[0].iov_base = (char *)req;
>> >         /* 4 for rfc1002 length field */ @@ -478,7 +478,8 @@ int
>> > smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon
>> > *tcon)
>> >
>> >         vneg_inbuf.Capabilities =
>> >                         cpu_to_le32(tcon->ses->server->vals->req_capabilities);
>> > -       memcpy(vneg_inbuf.Guid, cifs_client_guid,
>> SMB2_CLIENT_GUID_SIZE);
>> > +       memcpy(vneg_inbuf.Guid, tcon->ses->server->client_guid,
>> > +                                       SMB2_CLIENT_GUID_SIZE);
>> >
>> >         if (tcon->ses->sign)
>> >                 vneg_inbuf.SecurityMode = diff --git
>> > a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 2022c54..743e11e 100644
>> > --- a/fs/cifs/smb2pdu.h
>> > +++ b/fs/cifs/smb2pdu.h
>> > @@ -183,8 +183,6 @@ struct smb2_symlink_err_rsp {
>> >
>> >  #define SMB2_CLIENT_GUID_SIZE 16
>> >
>> > -extern __u8 cifs_client_guid[SMB2_CLIENT_GUID_SIZE];
>> > -
>> >  struct smb2_negotiate_req {
>> >         struct smb2_hdr hdr;
>> >         __le16 StructureSize; /* Must be 36 */
>> > --
>> > 1.8.4.2
>> >
>> > --
>> > To unsubscribe from this list: send the line "unsubscribe linux-cifs"
>> > in the body of a message to majordomo@vger.kernel.org More
>> majordomo
>> > info at  http://vger.kernel.org/majordomo-info.html
>>
>>
>>
>> --
>> Thanks,
>>
>> Steve
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the
>> body of a message to majordomo@vger.kernel.org More majordomo info at
>> http://vger.kernel.org/majordomo-info.html
Tom Talpey May 15, 2014, 8:35 a.m. UTC | #4
PiBXb3VsZCBtdWx0aWNoYW5uZWwgcmVxdWlyZSBhIG5ldyBuZWdvdGlhdGUgcHJvdG9jb2w/DQoN
CkEgbmV3IGNvbm5lY3Rpb24gYWx3YXlzIHJlcXVpcmVzIGEgbmVnb3RpYXRlLCBtdWx0aWNoYW5u
ZWwgaXMgbm8gZXhjZXB0aW9uLiBXaGF0J3MgZGlmZmVyZW50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ID4gMS44LjQuMg0KPiA+PiA+DQo+ID4+ID4gLS0NCj4gPj4gPiBUbyB1bnN1
YnNjcmliZSBmcm9tIHRoaXMgbGlzdDogc2VuZCB0aGUgbGluZSAidW5zdWJzY3JpYmUgbGludXgt
Y2lmcyINCj4gPj4gPiBpbiB0aGUgYm9keSBvZiBhIG1lc3NhZ2UgdG8gbWFqb3Jkb21vQHZnZXIu
a2VybmVsLm9yZyBNb3JlDQo+ID4+IG1ham9yZG9tbw0KPiA+PiA+IGluZm8gYXQgIGh0dHA6Ly92
Z2VyLmtlcm5lbC5vcmcvbWFqb3Jkb21vLWluZm8uaHRtbA0KPiA+Pg0KPiA+Pg0KPiA+Pg0KPiA+
PiAtLQ0KPiA+PiBUaGFua3MsDQo+ID4+DQo+ID4+IFN0ZXZlDQo+ID4+IC0tDQo+ID4+IFRvIHVu
c3Vic2NyaWJlIGZyb20gdGhpcyBsaXN0OiBzZW5kIHRoZSBsaW5lICJ1bnN1YnNjcmliZSBsaW51
eC1jaWZzIg0KPiA+PiBpbiB0aGUgYm9keSBvZiBhIG1lc3NhZ2UgdG8gbWFqb3Jkb21vQHZnZXIu
a2VybmVsLm9yZyBNb3JlDQo+IG1ham9yZG9tbw0KPiA+PiBpbmZvIGF0IGh0dHA6Ly92Z2VyLmtl
cm5lbC5vcmcvbWFqb3Jkb21vLWluZm8uaHRtbA0KPiANCj4gDQo+IA0KPiAtLQ0KPiBUaGFua3Ms
DQo+IA0KPiBTdGV2ZQ0K
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tom Talpey May 15, 2014, 11:46 a.m. UTC | #5
Thinking about this a bit more, it seems to me that if you do want to support an explicit dialect selection at mount time, then you may want to check whether you have an existing mount over a different dialect from the client before allowing it. The alternative may be to select a new ClientGUID for the new mount, to avoid the session create failure - but that will mean leasing won't work very well. Might be a tough choice, if you do want this dialect option.

> -----Original Message-----

> From: linux-cifs-owner@vger.kernel.org [mailto:linux-cifs-

> owner@vger.kernel.org] On Behalf Of Tom Talpey

> Sent: Thursday, May 15, 2014 10:35 AM

> To: Steve French

> Cc: Sachin Prabhu; linux-cifs

> Subject: RE: [PATCH] cifs: Set client guid on per connection basis

> 

> > Would multichannel require a new negotiate protocol?

> 

> A new connection always requires a negotiate, multichannel is no exception.

> What's different is that to make a multichannel association, the client should

> provide the original ClientGUID, and establish the same dialect and

> capabilities as the original connection. The session bind needs these in order

> join appropriately on the new multichannel.

> 

> The ClientGUID is mostly for supporting leases, and if you swizzle it per-

> connection then clients will start breaking their own leases when using

> multichannel. There is also some enforcement at session setup/bind time, as

> documented in MS-SMB2 3.3.5.3.3:

> 

> "The server MUST look up all existing connections from the client in the

> global ConnectionList where Connection.ClientGuid matches

> Session.Connection.ClientGuid. For any matching Connection, if

> Connection.Dialect is not the same as Session.Connection.Dialect, the server

> SHOULD<228> close the newly created Session, as specified in section

> 3.3.4.12, by providing Session.SessionGlobalId as the input parameter, and

> fail the session setup request with STATUS_USER_SESSION_DELETED."

> 

> 

> I guess if you only call get_tcp_session once, then you might be ok (that's

> your call). I was just pointing out that a new ClientGUID per-*connection*

> will get in the way for you later, because multichannel reuses sessions on

> many connections. Normally the protocol specifies a single ClientGUID which

> is used for all connections from a given client.

> 

> 

> > -----Original Message-----

> > From: Steve French [mailto:smfrench@gmail.com]

> > Sent: Thursday, May 15, 2014 10:12 AM

> > To: Tom Talpey

> > Cc: Sachin Prabhu; linux-cifs

> > Subject: Re: [PATCH] cifs: Set client guid on per connection basis

> >

> > Would multichannel require a new negotiate protocol? We are only

> > generating it in get_tcp_session - and would probably not go through

> > that path when connecting another socket to the original parent

> > struct.   Currently the model where tcons hang off smb sessions which

> > hang off tcp sessions looks strange when you consider multiple tcp

> > connections but have to distinguish the code which connects the first

> > tcp session for a machine and sets up the parent structure that all

> > the others (tcons and smb sessions) hang off, from the code which

> > connects subsequent tcp sessions for multichannel

> >

> > On Thu, May 15, 2014 at 8:36 AM, Tom Talpey <ttalpey@microsoft.com>

> > wrote:

> > > Won't this need to be undone for multichannel support? The client

> > > GUID

> > needs to be the same when connecting multiple channels, a different

> > one will break cross-channel replay detection.

> > >

> > > It's definitely true that if you intend to negotiate a different

> > > dialect, then

> > the client  GUID should not be reused.

> > >

> > >> -----Original Message-----

> > >> From: linux-cifs-owner@vger.kernel.org [mailto:linux-cifs-

> > >> owner@vger.kernel.org] On Behalf Of Steve French

> > >> Sent: Tuesday, May 13, 2014 10:49 PM

> > >> To: Sachin Prabhu

> > >> Cc: linux-cifs

> > >> Subject: Re: [PATCH] cifs: Set client guid on per connection basis

> > >>

> > >> merged into cifs-2.6.git for-next

> > >>

> > >> but added an additional patch to fix the problem where we are

> > >> sending a non-zero ClientGUID for SMB2.02 dialect (where it MUST be

> > >> zero according to MS-SMB2, it is non-zero starting in SMB2.1)

> > >>

> > >> On Tue, May 13, 2014 at 1:48 AM, Sachin Prabhu

> <sprabhu@redhat.com>

> > >> wrote:

> > >> > When mounting from a Windows 2012R2 server, we hit the following

> > >> > problem:

> > >> > 1) Mount with any of the following versions - 2.0, 2.1 or 3.0

> > >> > 2) unmount

> > >> > 3) Attempt a mount again using a different SMB version >= 2.0.

> > >> >

> > >> > You end up with the following failure:

> > >> > Status code returned 0xc0000203 STATUS_USER_SESSION_DELETED

> CIFS

> > >> VFS:

> > >> > Send error in SessSetup = -5 CIFS VFS: cifs_mount failed w/return

> > >> > code = -5

> > >> >

> > >> > I cannot reproduce this issue using a Windows 2008 R2 server.

> > >> >

> > >> > This appears to be caused because we use the same client guid for

> > >> > the connection on first mount which we then disconnect and

> > >> > attempt to mount again using a different protocol version. By

> > >> > generating a new guid each time a new connection is Negotiated,

> > >> > we avoid hitting this

> > >> problem.

> > >> >

> > >> > Signed-off-by: Sachin Prabhu <sprabhu@redhat.com>

> > >> > ---

> > >> >  fs/cifs/cifsfs.c   | 8 --------

> > >> >  fs/cifs/cifsglob.h | 1 +

> > >> >  fs/cifs/connect.c  | 3 +++

> > >> >  fs/cifs/smb2pdu.c  | 5 +++--

> > >> >  fs/cifs/smb2pdu.h  | 2 --

> > >> >  5 files changed, 7 insertions(+), 12 deletions(-)

> > >> >

> > >> > diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index

> > >> > 5be1f99..c80aa5a 100644

> > >> > --- a/fs/cifs/cifsfs.c

> > >> > +++ b/fs/cifs/cifsfs.c

> > >> > @@ -87,10 +87,6 @@ extern mempool_t *cifs_mid_poolp;

> > >> >

> > >> >  struct workqueue_struct        *cifsiod_wq;

> > >> >

> > >> > -#ifdef CONFIG_CIFS_SMB2

> > >> > -__u8 cifs_client_guid[SMB2_CLIENT_GUID_SIZE];

> > >> > -#endif

> > >> > -

> > >> >  /*

> > >> >   * Bumps refcount for cifs super block.

> > >> >   * Note that it should be only called if a referece to VFS super

> > >> > block is @@ -1192,10 +1188,6 @@ init_cifs(void)

> > >> >         spin_lock_init(&cifs_file_list_lock);

> > >> >         spin_lock_init(&GlobalMid_Lock);

> > >> >

> > >> > -#ifdef CONFIG_CIFS_SMB2

> > >> > -       get_random_bytes(cifs_client_guid, SMB2_CLIENT_GUID_SIZE);

> > >> > -#endif

> > >> > -

> > >> >         if (cifs_max_pending < 2) {

> > >> >                 cifs_max_pending = 2;

> > >> >                 cifs_dbg(FYI, "cifs_max_pending set to min of

> > >> > 2\n"); diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index

> > >> > 30f6e92..f74edd2 100644

> > >> > --- a/fs/cifs/cifsglob.h

> > >> > +++ b/fs/cifs/cifsglob.h

> > >> > @@ -559,6 +559,7 @@ struct TCP_Server_Info {

> > >> >         int echo_credits;  /* echo reserved slots */

> > >> >         int oplock_credits;  /* oplock break reserved slots */

> > >> >         bool echoes:1; /* enable echoes */

> > >> > +       __u8 client_guid[SMB2_CLIENT_GUID_SIZE]; /* Client GUID

> > >> > + */

> > >> >  #endif

> > >> >         u16 dialect; /* dialect index that server chose */

> > >> >         bool oplocks:1; /* enable oplocks */ diff --git

> > >> > a/fs/cifs/connect.c b/fs/cifs/connect.c index 8813ff7..8b8fe9b

> > >> > 100644

> > >> > --- a/fs/cifs/connect.c

> > >> > +++ b/fs/cifs/connect.c

> > >> > @@ -2144,6 +2144,9 @@ cifs_get_tcp_session(struct smb_vol

> > >> *volume_info)

> > >> >                sizeof(tcp_ses->srcaddr));

> > >> >         memcpy(&tcp_ses->dstaddr, &volume_info->dstaddr,

> > >> >                 sizeof(tcp_ses->dstaddr));

> > >> > +#ifdef CONFIG_CIFS_SMB2

> > >> > +       get_random_bytes(tcp_ses->client_guid,

> > >> > +SMB2_CLIENT_GUID_SIZE); #endif

> > >> >         /*

> > >> >          * at this point we are the only ones with the pointer

> > >> >          * to the struct since the kernel thread not created yet

> > >> > diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index

> > >> > 3802f8c..dc44610

> > >> > 100644

> > >> > --- a/fs/cifs/smb2pdu.c

> > >> > +++ b/fs/cifs/smb2pdu.c

> > >> > @@ -375,7 +375,7 @@ SMB2_negotiate(const unsigned int xid, struct

> > >> > cifs_ses *ses)

> > >> >

> > >> >         req->Capabilities =

> > >> > cpu_to_le32(ses->server->vals->req_capabilities);

> > >> >

> > >> > -       memcpy(req->ClientGUID, cifs_client_guid,

> > >> SMB2_CLIENT_GUID_SIZE);

> > >> > +       memcpy(req->ClientGUID, server->client_guid,

> > >> > + SMB2_CLIENT_GUID_SIZE);

> > >> >

> > >> >         iov[0].iov_base = (char *)req;

> > >> >         /* 4 for rfc1002 length field */ @@ -478,7 +478,8 @@ int

> > >> > smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon

> > >> > *tcon)

> > >> >

> > >> >         vneg_inbuf.Capabilities =

> > >> >                         cpu_to_le32(tcon->ses->server->vals->req_capabilities);

> > >> > -       memcpy(vneg_inbuf.Guid, cifs_client_guid,

> > >> SMB2_CLIENT_GUID_SIZE);

> > >> > +       memcpy(vneg_inbuf.Guid, tcon->ses->server->client_guid,

> > >> > +                                       SMB2_CLIENT_GUID_SIZE);

> > >> >

> > >> >         if (tcon->ses->sign)

> > >> >                 vneg_inbuf.SecurityMode = diff --git

> > >> > a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 2022c54..743e11e

> > >> > 100644

> > >> > --- a/fs/cifs/smb2pdu.h

> > >> > +++ b/fs/cifs/smb2pdu.h

> > >> > @@ -183,8 +183,6 @@ struct smb2_symlink_err_rsp {

> > >> >

> > >> >  #define SMB2_CLIENT_GUID_SIZE 16

> > >> >

> > >> > -extern __u8 cifs_client_guid[SMB2_CLIENT_GUID_SIZE];

> > >> > -

> > >> >  struct smb2_negotiate_req {

> > >> >         struct smb2_hdr hdr;

> > >> >         __le16 StructureSize; /* Must be 36 */

> > >> > --

> > >> > 1.8.4.2

> > >> >

> > >> > --

> > >> > To unsubscribe from this list: send the line "unsubscribe linux-cifs"

> > >> > in the body of a message to majordomo@vger.kernel.org More

> > >> majordomo

> > >> > info at  http://vger.kernel.org/majordomo-info.html

> > >>

> > >>

> > >>

> > >> --

> > >> Thanks,

> > >>

> > >> Steve

> > >> --

> > >> To unsubscribe from this list: send the line "unsubscribe linux-cifs"

> > >> in the body of a message to majordomo@vger.kernel.org More

> > majordomo

> > >> info at http://vger.kernel.org/majordomo-info.html

> >

> >

> >

> > --

> > Thanks,

> >

> > Steve

> N     r  y   b X  ?v ^ )?{.n +    { r' {ay ?? ,j   f   h   z  w       j:+v   w j m         zZ+     ?j"

> ! i
diff mbox

Patch

diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 5be1f99..c80aa5a 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -87,10 +87,6 @@  extern mempool_t *cifs_mid_poolp;
 
 struct workqueue_struct	*cifsiod_wq;
 
-#ifdef CONFIG_CIFS_SMB2
-__u8 cifs_client_guid[SMB2_CLIENT_GUID_SIZE];
-#endif
-
 /*
  * Bumps refcount for cifs super block.
  * Note that it should be only called if a referece to VFS super block is
@@ -1192,10 +1188,6 @@  init_cifs(void)
 	spin_lock_init(&cifs_file_list_lock);
 	spin_lock_init(&GlobalMid_Lock);
 
-#ifdef CONFIG_CIFS_SMB2
-	get_random_bytes(cifs_client_guid, SMB2_CLIENT_GUID_SIZE);
-#endif
-
 	if (cifs_max_pending < 2) {
 		cifs_max_pending = 2;
 		cifs_dbg(FYI, "cifs_max_pending set to min of 2\n");
diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
index 30f6e92..f74edd2 100644
--- a/fs/cifs/cifsglob.h
+++ b/fs/cifs/cifsglob.h
@@ -559,6 +559,7 @@  struct TCP_Server_Info {
 	int echo_credits;  /* echo reserved slots */
 	int oplock_credits;  /* oplock break reserved slots */
 	bool echoes:1; /* enable echoes */
+	__u8 client_guid[SMB2_CLIENT_GUID_SIZE]; /* Client GUID */
 #endif
 	u16 dialect; /* dialect index that server chose */
 	bool oplocks:1; /* enable oplocks */
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 8813ff7..8b8fe9b 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -2144,6 +2144,9 @@  cifs_get_tcp_session(struct smb_vol *volume_info)
 	       sizeof(tcp_ses->srcaddr));
 	memcpy(&tcp_ses->dstaddr, &volume_info->dstaddr,
 		sizeof(tcp_ses->dstaddr));
+#ifdef CONFIG_CIFS_SMB2
+	get_random_bytes(tcp_ses->client_guid, SMB2_CLIENT_GUID_SIZE);
+#endif
 	/*
 	 * at this point we are the only ones with the pointer
 	 * to the struct since the kernel thread not created yet
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 3802f8c..dc44610 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -375,7 +375,7 @@  SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses)
 
 	req->Capabilities = cpu_to_le32(ses->server->vals->req_capabilities);
 
-	memcpy(req->ClientGUID, cifs_client_guid, SMB2_CLIENT_GUID_SIZE);
+	memcpy(req->ClientGUID, server->client_guid, SMB2_CLIENT_GUID_SIZE);
 
 	iov[0].iov_base = (char *)req;
 	/* 4 for rfc1002 length field */
@@ -478,7 +478,8 @@  int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon)
 
 	vneg_inbuf.Capabilities =
 			cpu_to_le32(tcon->ses->server->vals->req_capabilities);
-	memcpy(vneg_inbuf.Guid, cifs_client_guid, SMB2_CLIENT_GUID_SIZE);
+	memcpy(vneg_inbuf.Guid, tcon->ses->server->client_guid,
+					SMB2_CLIENT_GUID_SIZE);
 
 	if (tcon->ses->sign)
 		vneg_inbuf.SecurityMode =
diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h
index 2022c54..743e11e 100644
--- a/fs/cifs/smb2pdu.h
+++ b/fs/cifs/smb2pdu.h
@@ -183,8 +183,6 @@  struct smb2_symlink_err_rsp {
 
 #define SMB2_CLIENT_GUID_SIZE 16
 
-extern __u8 cifs_client_guid[SMB2_CLIENT_GUID_SIZE];
-
 struct smb2_negotiate_req {
 	struct smb2_hdr hdr;
 	__le16 StructureSize; /* Must be 36 */