From patchwork Sat Jun 8 09:05:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 10983075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CC4FA13AD for ; Sat, 8 Jun 2019 09:05:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5A8228A6D for ; Sat, 8 Jun 2019 09:05:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 936B428B5D; Sat, 8 Jun 2019 09:05:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 113E528A6D for ; Sat, 8 Jun 2019 09:05:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726478AbfFHJFl (ORCPT ); Sat, 8 Jun 2019 05:05:41 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:35413 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbfFHJFl (ORCPT ); Sat, 8 Jun 2019 05:05:41 -0400 Received: by mail-pl1-f193.google.com with SMTP id p1so1734257plo.2 for ; Sat, 08 Jun 2019 02:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=5aCbh0WAoNANdEYNEvN8iUM+F/mYNTL/ue0+dwqWzas=; b=hOh3SfYw7/f59vxt1ecxNYHEha0KOhjSwMRyzFQ7ruhtWz6RcgC6lZlKJixzMvg3x8 gM7YGgfGEMGQ9zWh0PVfiMTx6NmwGGRBDQ+SeiC15XdggR2/AQyOgMwq+TozDc9BPSuK ZfKc9HlJvYbiNDGlzh53FvJpOJYND+/x0OHDjfsoXWecGQoZg+28gCFtknuc2tYZ4YvB f6rz+yJjgPp3GpUE10g8oFZOsLtFcVXjLHa35nDBTxv3hF9pbMTMwTXDarp5ncuu5KaQ jqBiPKTBpy6Zi3VxRf+smQs3ui8T8x1uSnhLQxcTQF8tfmgqQASUvsc6Xf+0UorMnYIX 4bIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=5aCbh0WAoNANdEYNEvN8iUM+F/mYNTL/ue0+dwqWzas=; b=Hf8KHkI9w3t1sHxWwxwucbwDThBHjD44PYnn7HT3DfEO89vQEnWkFq8Dtx+QzxYmK0 cNKwy3BKAlj+PtmLGcPRETsUFr9SnrOfI2naRZrNiRVbQwXJOZa+tV1X5tNWfirK1Hs/ BqE4yyoPcHkeWXxxBldWhwIgDGZhid/RMNlQzXe93fB/HoPqvsoy5Gy5Gx2WQfMjbpeZ AQ9soNNCxehEzk9oYNXBt2DH/pGjJzOcdUZE4J+QF7KKvmxnPohHNRlxufQahjDN1W9V YwenWWCIien9Nyqa4J3Ja3JPmpMHs6Jn0og3IwWa1A4YX5negaQkF83x7i5PpxHCx0fT pFIQ== X-Gm-Message-State: APjAAAVYeQNbp8On4GxPLlK/yCyDDMH2vHKHc7wqoqmV7wUFFBqpaArT zww8SUy0pwr/VtvqTM8hp7b0vTrWS+gCYEXi6lbwSLbG5Ag= X-Google-Smtp-Source: APXvYqxzySyhNt+5UeX/HnxPXmYrFwtyZR6Kr1kZB1gSFKoaG+3lQzjFZwI3rLGIjVyTLHvIIbjGMnIn0qBpmm2kS7o= X-Received: by 2002:a17:902:2a29:: with SMTP id i38mr32530384plb.46.1559984739518; Sat, 08 Jun 2019 02:05:39 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Sat, 8 Jun 2019 04:05:28 -0500 Message-ID: Subject: [PATCH][CIFS] Fix match_server check to allow for multidialect negotiate To: CIFS Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When using multidialect negotiate (default or allowing any smb3 dialect via vers=3) allow matching on existing server session. Before this fix if you mount a second time to a different share on the same server, we will only reuse the existing smb session if a single dialect is requested (e.g. specifying vers=2.1 or vers=3.0 or vers=3.1.1 on the mount command). If a default mount (e.g. not specifying vers=) is done then we will create a new socket connection and SMB3 (or SMB3.1.1) session each time we connect to a different share on the same server rather than reusing the existing one. Signed-off-by: Steve French Reviewed-by: Pavel Shilovsky --- fs/cifs/connect.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns)) From fd5e01a89742bb85d758a6651294a8a20193bc27 Mon Sep 17 00:00:00 2001 From: Steve French Date: Sat, 8 Jun 2019 03:56:29 -0500 Subject: [PATCH] [CIFS] Fix match_server check to allow for multidialect negotiate When using multidialect negotiate (default or allowing any smb3 dialect via vers=3) allow matching on existing server session. Before this fix if you mount a second time to a different share on the same server, we will only reuse the existing smb session if a single dialect is requested (e.g. specifying vers=2.1 or vers=3.0 or vers=3.1.1 on the mount command). If a default mount (e.g. not specifying vers=) is done then we will create a new socket connection and SMB3 (or SMB3.1.1) session each time we connect to a different share on the same server rather than reusing the existing one. Signed-off-by: Steve French --- fs/cifs/connect.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 8c4121da624e..6200207565db 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -2542,8 +2542,25 @@ static int match_server(struct TCP_Server_Info *server, struct smb_vol *vol) if (vol->nosharesock) return 0; - /* BB update this for smb3any and default case */ - if ((server->vals != vol->vals) || (server->ops != vol->ops)) + /* If multidialect negotiation see if existing sessions match one */ + if (strcmp(vol->vals->version_string, SMB3ANY_VERSION_STRING) == 0) { + if (server->vals->protocol_id == SMB20_PROT_ID) + return 0; + else if (server->vals->protocol_id == SMB21_PROT_ID) + return 0; + else if (strcmp(server->vals->version_string, + SMB1_VERSION_STRING) == 0) + return 0; + /* else SMB3 or later, which is fine */ + } else if (strcmp(vol->vals->version_string, + SMBDEFAULT_VERSION_STRING) == 0) { + if (server->vals->protocol_id == SMB20_PROT_ID) + return 0; + else if (strcmp(server->vals->version_string, + SMB1_VERSION_STRING) == 0) + return 0; + /* else SMB2.1 or later, which is fine */ + } else if ((server->vals != vol->vals) || (server->ops != vol->ops)) return 0; if (!net_eq(cifs_net_ns(server), current->nsproxy->net_ns)) -- 2.20.1