From patchwork Tue Feb 2 06:15:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 12060787 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4167DC433E0 for ; Tue, 2 Feb 2021 06:16:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE26864DA3 for ; Tue, 2 Feb 2021 06:16:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231776AbhBBGQU (ORCPT ); Tue, 2 Feb 2021 01:16:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230369AbhBBGQT (ORCPT ); Tue, 2 Feb 2021 01:16:19 -0500 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08A2DC061573 for ; Mon, 1 Feb 2021 22:15:39 -0800 (PST) Received: by mail-lj1-x233.google.com with SMTP id v15so19621600ljk.13 for ; Mon, 01 Feb 2021 22:15:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=BTE1iqfSPceS+T0i+0NmWJq2vzQT5uns+yuR1Nzh6SQ=; b=Ju5sYp3YeHe5SQNr4FWRLGFSQc2+uy9ohFDYhSemt4I5O6gPZ4zX1xXBMg/PcR+elT NImctbpNLLylgD8YKjfkNyecxJcUAW7+aI68Cze5DECZfsi7KERc+2pEcCNKi8dduh1q MiEdiUsBWECT0XcLYadxW2w7EHGWXY8PKiLi/p+IgegjklgppxQAT4F60ukKgX329xpL 9Vne8VMeHjTTznNOq5ICB4dpetVLnRsv+1rtHYBAWjYuZ7i0BH/vZOSNn6a8jpbT//0b SjHeiZQom6JoLgwj8NL9uGxbEwwuKlTukZ+Jy1TIuzKoaw6rE9aqaO4ekjbkNWLruSge opkA== 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:cc; bh=BTE1iqfSPceS+T0i+0NmWJq2vzQT5uns+yuR1Nzh6SQ=; b=gJ/a2kUiOCW1TAwLdpQtsg/kPiMg9BM0/J94MB4FoEJqHth6RrPMTJglNVhAz7Lqa7 2fkVCVhoQ11NNY9LE46dNszaAD5hzv7yJbcjkDUnMHagsh/+pILAHyg2K6uG6OL1sunx LKmJb6Vxb/5mSW6tZF3gZrUaU/2jHwKC9c37TWu93VzBhq4ZXHt/6HvA5Ox4+eFhMGDz LyMRfmbxrsWb88ymgBCuHqPUTIp/RT+ZVWbkCm2wdgurLrCveL7bL7ItsalS3EKEXYzD fosLS9aknFezeUweEi/WzpKLIkEPPtFGtNkefGCAVhEYku9baYOizDQ4ezIy4Po40Nzx +5zg== X-Gm-Message-State: AOAM533faBluSfdTOC8F3B1HSg0sYKIX0/UiB3S8QyKCPOYkDzakOjY0 ib7IoQeX57TXdOhJlci9R9WawrHeSCmiHOy/XaYuBLOcfwio0A== X-Google-Smtp-Source: ABdhPJzMATBFRaKWZIo/xOi0PQfC3P8bS0u9fP29n0ae+m+abdN7qbdNBe+Cld1ak63iERN5dFcyKXpU6HaCkpEycCI= X-Received: by 2002:a05:651c:14a:: with SMTP id c10mr12212809ljd.272.1612246537251; Mon, 01 Feb 2021 22:15:37 -0800 (PST) MIME-Version: 1.0 From: Steve French Date: Tue, 2 Feb 2021 00:15:26 -0600 Message-ID: Subject: PATCH] smb3: include current dialect (SMB3.1.1) when version 3 or greater requested on mount To: CIFS , samba-technical Cc: Pavel Shilovsky Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org SMB3.1.1 is the newest, and preferred dialect, and is included in the requested dialect list by default (ie if no vers= is specified on mount) but it should also be requested if SMB3 or later is requested (vers=3 instead of a specific dialect: vers=2.1, vers=3.02 or vers=3.0). Currently specifying "vers=3" only requests smb3.0 and smb3.02 but this patch fixes it to also request smb3.1.1 dialect, as it is the newest and most secure dialect and is a "version 3 or later" dialect (the intent of "vers=3"). Signed-off-by: Steve French Suggested-by: Pavel Shilovsky Reviewed-by: Pavel Shilovsky Reviewed-by: Shyam Prasad N --- fs/cifs/fs_context.c | 2 +- fs/cifs/smb2pdu.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) pneg_inbuf->Dialects[0] = cpu_to_le16(SMB21_PROT_ID); @@ -1053,7 +1060,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) pneg_inbuf->Dialects[2] = cpu_to_le16(SMB302_PROT_ID); pneg_inbuf->Dialects[3] = cpu_to_le16(SMB311_PROT_ID); pneg_inbuf->DialectCount = cpu_to_le16(4); - /* structure is big enough for 3 dialects */ + /* structure is big enough for 4 dialects */ inbuflen = sizeof(*pneg_inbuf); } else { /* otherwise specific dialect was requested */ From e7055cdca03ea5522992345c9248cdbfed5c9d6a Mon Sep 17 00:00:00 2001 From: Steve French Date: Tue, 2 Feb 2021 00:03:58 -0600 Subject: [PATCH] smb3: negotiate current dialect (SMB3.1.1) when version 3 or greater requested SMB3.1.1 is the newest, and preferred dialect, and is included in the requested dialect list by default (ie if no vers= is specified on mount) but it should also be requested if SMB3 or later is requested (vers=3 instead of a specific dialect: vers=2.1, vers=3.02 or vers=3.0). Currently specifying "vers=3" only requests smb3.0 and smb3.02 but this patch fixes it to also request smb3.1.1 dialect, as it is the newest and most secure dialect and is a "version 3 or later" dialect (the intent of "vers=3" dialect). Signed-off-by: Steve French Suggested-by: Pavel Shilovsky --- fs/cifs/fs_context.c | 2 +- fs/cifs/smb2pdu.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c index 5111aadfdb6b..479c24695281 100644 --- a/fs/cifs/fs_context.c +++ b/fs/cifs/fs_context.c @@ -391,7 +391,7 @@ cifs_parse_smb_version(char *value, struct smb3_fs_context *ctx, bool is_smb3) ctx->vals = &smb3any_values; break; case Smb_default: - ctx->ops = &smb30_operations; /* currently identical with 3.0 */ + ctx->ops = &smb30_operations; ctx->vals = &smbdefault_values; break; default: diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 794fc3b68b4f..52625549c3b5 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -814,8 +814,9 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) SMB3ANY_VERSION_STRING) == 0) { req->Dialects[0] = cpu_to_le16(SMB30_PROT_ID); req->Dialects[1] = cpu_to_le16(SMB302_PROT_ID); - req->DialectCount = cpu_to_le16(2); - total_len += 4; + req->Dialects[2] = cpu_to_le16(SMB311_PROT_ID); + req->DialectCount = cpu_to_le16(3); + total_len += 6; } else if (strcmp(server->vals->version_string, SMBDEFAULT_VERSION_STRING) == 0) { req->Dialects[0] = cpu_to_le16(SMB21_PROT_ID); @@ -848,6 +849,8 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) memcpy(req->ClientGUID, server->client_guid, SMB2_CLIENT_GUID_SIZE); if ((server->vals->protocol_id == SMB311_PROT_ID) || + (strcmp(server->vals->version_string, + SMB3ANY_VERSION_STRING) == 0) || (strcmp(server->vals->version_string, SMBDEFAULT_VERSION_STRING) == 0)) assemble_neg_contexts(req, server, &total_len); @@ -883,6 +886,9 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) cifs_server_dbg(VFS, "SMB2.1 dialect returned but not requested\n"); return -EIO; + } else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) { + server->ops = &smb311_operations; + server->vals = &smb311_values; } } else if (strcmp(server->vals->version_string, SMBDEFAULT_VERSION_STRING) == 0) { @@ -1042,10 +1048,11 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) SMB3ANY_VERSION_STRING) == 0) { pneg_inbuf->Dialects[0] = cpu_to_le16(SMB30_PROT_ID); pneg_inbuf->Dialects[1] = cpu_to_le16(SMB302_PROT_ID); - pneg_inbuf->DialectCount = cpu_to_le16(2); - /* structure is big enough for 3 dialects, sending only 2 */ + pneg_inbuf->Dialects[2] = cpu_to_le16(SMB311_PROT_ID); + pneg_inbuf->DialectCount = cpu_to_le16(3); + /* SMB 2.1 not included so subtract one dialect from len */ inbuflen = sizeof(*pneg_inbuf) - - (2 * sizeof(pneg_inbuf->Dialects[0])); + (sizeof(pneg_inbuf->Dialects[0])); } else if (strcmp(server->vals->version_string, SMBDEFAULT_VERSION_STRING) == 0) { pneg_inbuf->Dialects[0] = cpu_to_le16(SMB21_PROT_ID); @@ -1053,7 +1060,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) pneg_inbuf->Dialects[2] = cpu_to_le16(SMB302_PROT_ID); pneg_inbuf->Dialects[3] = cpu_to_le16(SMB311_PROT_ID); pneg_inbuf->DialectCount = cpu_to_le16(4); - /* structure is big enough for 3 dialects */ + /* structure is big enough for 4 dialects */ inbuflen = sizeof(*pneg_inbuf); } else { /* otherwise specific dialect was requested */ -- 2.27.0