From patchwork Wed Aug 13 15:49:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Prabhu X-Patchwork-Id: 4719661 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 69E819F375 for ; Wed, 13 Aug 2014 15:49:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 834772015E for ; Wed, 13 Aug 2014 15:49:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 785A32015A for ; Wed, 13 Aug 2014 15:49:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753100AbaHMPtn (ORCPT ); Wed, 13 Aug 2014 11:49:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36398 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752929AbaHMPtm (ORCPT ); Wed, 13 Aug 2014 11:49:42 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7DFnciG009396 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Aug 2014 11:49:38 -0400 Received: from sachin-laptop.redhat.com (vpn1-5-247.ams2.redhat.com [10.36.5.247]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s7DFnZdo031204 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 13 Aug 2014 11:49:37 -0400 From: Sachin Prabhu To: linux-cifs Cc: Steve French , Tom Talpey Subject: [PATCH] cifs: Add per-version guid Date: Wed, 13 Aug 2014 16:49:34 +0100 Message-Id: <1407944975-20653-1-git-send-email-sprabhu@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 39552ea8120a699dbd0360848c4d949f9f0e6deb changes guid on per connection basis. This can cause problems in the future when making multichannel associations. The problem is described by Tom Talpey at https://www.mail-archive.com/linux-cifs@vger.kernel.org/msg09396.html We try and work around this problem by assigning a client guid for each smb2 dialect and use these GUIDs with their corresponding dialects. Signed-off-by: Sachin Prabhu --- fs/cifs/cifsfs.c | 15 +++++++++++++++ fs/cifs/cifsglob.h | 2 +- fs/cifs/connect.c | 3 --- fs/cifs/smb2pdu.c | 10 +++------- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 8883980..fa8a1a4 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -1162,6 +1162,16 @@ cifs_destroy_mids(void) kmem_cache_destroy(cifs_mid_cachep); } +static void init_guids(void) +{ + /* We do not sent a client GUID for SMB2.02 dialect */ + memset(&smb20_values.client_guid, 0, SMB2_CLIENT_GUID_SIZE); + + get_random_bytes(&smb21_values.client_guid, SMB2_CLIENT_GUID_SIZE); + get_random_bytes(&smb30_values.client_guid, SMB2_CLIENT_GUID_SIZE); + get_random_bytes(&smb302_values.client_guid, SMB2_CLIENT_GUID_SIZE); +} + static int __init init_cifs(void) { @@ -1196,6 +1206,11 @@ init_cifs(void) spin_lock_init(&cifs_file_list_lock); spin_lock_init(&GlobalMid_Lock); + +#ifdef CONFIG_CIFS_SMB2 + init_guids(); +#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 0012e1e..1c044f4 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -429,6 +429,7 @@ struct smb_version_values { __u16 signing_enabled; __u16 signing_required; size_t create_lease_size; + __u8 client_guid[SMB2_CLIENT_GUID_SIZE]; }; #define HEADER_SIZE(server) (server->vals->header_size) @@ -564,7 +565,6 @@ 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 03ed8a0..2b8dd80 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -2144,9 +2144,6 @@ 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 42ebc1a..694638c 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -360,12 +360,8 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) req->Capabilities = cpu_to_le32(ses->server->vals->req_capabilities); - /* ClientGUID must be zero for SMB2.02 dialect */ - if (ses->server->vals->protocol_id == SMB20_PROT_ID) - memset(req->ClientGUID, 0, SMB2_CLIENT_GUID_SIZE); - else - memcpy(req->ClientGUID, server->client_guid, - SMB2_CLIENT_GUID_SIZE); + memcpy(req->ClientGUID, &server->vals->client_guid, + SMB2_CLIENT_GUID_SIZE); iov[0].iov_base = (char *)req; /* 4 for rfc1002 length field */ @@ -468,7 +464,7 @@ 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, tcon->ses->server->client_guid, + memcpy(vneg_inbuf.Guid, &tcon->ses->server->vals->client_guid, SMB2_CLIENT_GUID_SIZE); if (tcon->ses->sign)