From patchwork Tue Jun 25 09:44:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 11015137 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 F2895924 for ; Tue, 25 Jun 2019 09:44:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E155528736 for ; Tue, 25 Jun 2019 09:44:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D56D028B9B; Tue, 25 Jun 2019 09:44:50 +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 5F30D28B92 for ; Tue, 25 Jun 2019 09:44:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727385AbfFYJou (ORCPT ); Tue, 25 Jun 2019 05:44:50 -0400 Received: from mail-pf1-f176.google.com ([209.85.210.176]:39125 "EHLO mail-pf1-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726551AbfFYJot (ORCPT ); Tue, 25 Jun 2019 05:44:49 -0400 Received: by mail-pf1-f176.google.com with SMTP id j2so9196239pfe.6 for ; Tue, 25 Jun 2019 02:44:49 -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=llU9IFT5EZBFFg3qedfWDR9ytiNbVudrlCrNsGxNuq0=; b=T7gk86sIRLA5bvBEJg8kTtiSLjtMFWgdgTCNaLyHJwigPxOpcpF7Hwp+HfNER5LDdz lQUH3vP0cGj0YYJRHvroAxFwdpzVI1KJtKUur/HIUl1h9mOtjnqy+3CQZKfeZ20o2xJO lfkJz3m0nmyC7dNQneEL8zTWv9eSMAYOlihaAYVVC6GP0gFjOghjJZs+hljTEHajk2qS Cloa7rbqZWebZI/36qa9DAVS5dHjTtkMZ0Vyi9ugFZeU6iA4mmZSKAUy/ZArMZ8zuVYU DTfdTQ9bslHJ+J8czABu/RZwcLGfAdlhNpki7mH02lnM0nMbaNSUxmZRaKsCJzm2Dv0e Tl3w== 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=llU9IFT5EZBFFg3qedfWDR9ytiNbVudrlCrNsGxNuq0=; b=dMRS0Zppsxwn03sFDv7jeR3vLj5+ne65bliS933DEW/VrNZQpdMe2ZQLQngqJhK6p6 cbHNYPIG4rDxwfcnO8vcmhjRoZIh8ewwVNgqjvZMpkjuNHsAS+ufXl1rJ2/d/KHaIBKE lH6Bezy5lh/oQtjoqsxfZE1u8WkOaOwEYlA804K5JWv5lgqoVWbtjBrHdHXQRFLLw7Wq lwkoAPsAstd+HzfD/LiCKmL3XZRI89UyLP+NgRmHLFpspUCOnDb4k898RXv4Vil7UpuU 4Z2iiFHtCH4/iA9St0gWIyr0xQmOZ/3EFMumQ7BeHjlVIDIhbR4qasDnMeg8OfM8+iFr oUxw== X-Gm-Message-State: APjAAAURmjayTBwMJilX+/ioDFKW5extiDrq0r50hdUNMUTncZVTj24a I3l7m/2SQUqbNNoTW+Xf631kHo7UnJTudze0r2UreYj1 X-Google-Smtp-Source: APXvYqwHT/5+4FVcbz49guL9o/LBLM0R/q1CqlXHRuuSyzrWxFHS4N8MINbsyDLNroe6qj8W8MgkcYO0VWZQop8rvSg= X-Received: by 2002:a63:d4c:: with SMTP id 12mr10040740pgn.30.1561455888755; Tue, 25 Jun 2019 02:44:48 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Tue, 25 Jun 2019 04:44:37 -0500 Message-ID: Subject: [PATCH][SMB3.1.1] Send new netname negotiate context To: CIFS , samba-technical 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 Add new SMB3.1.1 netname negotiate context (only sent in request, no response context to parse). See MS-SMB2 2.2.3.1.4 From d5e9271bcc7edc233628e43e523d7826c82eb316 Mon Sep 17 00:00:00 2001 From: Steve French Date: Tue, 25 Jun 2019 04:39:51 -0500 Subject: [PATCH] smb3: Send netname context during negotiate protocol See MS-SMB2 2.2.3.1.4 Allows hostname to be used by load balancers Signed-off-by: Steve French --- fs/cifs/smb2pdu.c | 25 +++++++++++++++++++++++-- fs/cifs/smb2pdu.h | 6 ++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 8e289404f6b0..34d5397a1989 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -495,6 +495,21 @@ build_encrypt_ctxt(struct smb2_encryption_neg_context *pneg_ctxt) pneg_ctxt->Ciphers[1] = SMB2_ENCRYPTION_AES128_CCM; } +static unsigned int +build_netname_ctxt(struct smb2_netname_neg_context *pneg_ctxt, char *hostname) +{ + struct nls_table *cp = load_nls_default(); + + pneg_ctxt->ContextType = SMB2_NETNAME_NEGOTIATE_CONTEXT_ID; + + /* copy up to max of first 100 bytes of server name to NetName field */ + pneg_ctxt->DataLength = cpu_to_le16(2 + + (2 * cifs_strtoUTF16(pneg_ctxt->NetName, hostname, 100, cp))); + /* context size is DataLength + minimal smb2_neg_context */ + return DIV_ROUND_UP(le16_to_cpu(pneg_ctxt->DataLength) + + sizeof(struct smb2_neg_context), 8) * 8; +} + static void build_posix_ctxt(struct smb2_posix_neg_context *pneg_ctxt) { @@ -559,9 +574,15 @@ assemble_neg_contexts(struct smb2_negotiate_req *req, 8) * 8; *total_len += ctxt_len; pneg_ctxt += ctxt_len; - req->NegotiateContextCount = cpu_to_le16(4); + req->NegotiateContextCount = cpu_to_le16(5); } else - req->NegotiateContextCount = cpu_to_le16(3); + req->NegotiateContextCount = cpu_to_le16(4); + + ctxt_len = build_netname_ctxt((struct smb2_netname_neg_context *)pneg_ctxt, + server->hostname); + *total_len += ctxt_len; + pneg_ctxt += ctxt_len; + build_posix_ctxt((struct smb2_posix_neg_context *)pneg_ctxt); *total_len += sizeof(struct smb2_posix_neg_context); } diff --git a/fs/cifs/smb2pdu.h b/fs/cifs/smb2pdu.h index 23524fe947de..6428574963df 100644 --- a/fs/cifs/smb2pdu.h +++ b/fs/cifs/smb2pdu.h @@ -317,6 +317,12 @@ struct smb2_compression_capabilities_context { * For smb2_netname_negotiate_context_id See MS-SMB2 2.2.3.1.4. * Its struct simply contains NetName, an array of Unicode characters */ +struct smb2_netname_neg_context { + __le16 ContextType; /* 0x100 */ + __le16 DataLength; + __le32 Reserved; + __le16 NetName[0]; /* hostname of target converted to UCS-2 */ +} __packed; #define POSIX_CTXT_DATA_LEN 16 struct smb2_posix_neg_context { -- 2.20.1