From patchwork Tue Jun 25 01:44:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 11014449 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 29288924 for ; Tue, 25 Jun 2019 01:44:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1671D28A8C for ; Tue, 25 Jun 2019 01:44:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07A3F28ACE; Tue, 25 Jun 2019 01:44:19 +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 76BC828A8C for ; Tue, 25 Jun 2019 01:44:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728954AbfFYBoS (ORCPT ); Mon, 24 Jun 2019 21:44:18 -0400 Received: from mail-pl1-f174.google.com ([209.85.214.174]:43614 "EHLO mail-pl1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728104AbfFYBoS (ORCPT ); Mon, 24 Jun 2019 21:44:18 -0400 Received: by mail-pl1-f174.google.com with SMTP id cl9so7875285plb.10 for ; Mon, 24 Jun 2019 18:44:17 -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=Ot0LXBFCVazcXCFhS5snXLm+Lg5dyElM/SZz5OLDKeM=; b=fnQxvjfqQjxgFecyOgiE+ZKPjIfG/IAKL1iv+ch8m308koImBwanG0AhqK+X6T5foy pL69KKuSMoPqca2dfpzTHEkZXCEf6tcpXrUwkYhr9XCL14VpGwWDOpoK8/wjNL9vTbDn nBbBbZD+/QFdrS1/wDavFo/1btSIu9Uq39p1u6Wd5OtV2wf8ncWYgY0200vy7KgRTRLL 31yARZK8EkAXWyttzezlwoSg+EPCtCXuHZsL+s98L4hxx0MUqQ47OXEsjvPJc+Vzvt2Y YPBUTudJUZzSB+40NPuoIFQshzZRSvezmYdd+u3ymPGowZFXEIkVa98Q7nuzlktgv4AX l49Q== 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=Ot0LXBFCVazcXCFhS5snXLm+Lg5dyElM/SZz5OLDKeM=; b=DhQ5y0MFQhFUipTVdBPAF18Gf6jScbQfkzNhSO1wD8pi4arbbE28R3gRnC/QVJq3WQ 9sHyjTMczXtFBZ6Wc6UYWvCUuPWvS77eQbCAndhyvNx7MdGX/XtIgA/Z4Q0Adxb6LFAs e/KleLQTtbRmd7iVBJHpk3VvQ9OoJ6UM3fyV2StHv6zKy0qqT210BHzeNqmisd6e+fzA GuC9fylT3E3+e+sp/F9QZPoZjRVlBXFgwnwObFkfkfnBScMQTnkohQzZPo2Vdgp3qPGN YSiM1pDusXa0lkiA/xdZbIjOOtYn9l/LCCsNTbRvpUr4DGHxMQkivvEk26JTzcwjMSYF t3mw== X-Gm-Message-State: APjAAAVLf74PFcP3zts6d+X4vgROs0LsgUBc0xbnxgJWD3b0bDU+yENT Nq/+yWDC7sZ4iCsyP1QJHqDcuCzAYukpXBwkkWbLQ7Hr X-Google-Smtp-Source: APXvYqx7fmTZHaoiqck+9GsWxEaX9EmdAiXiaovcHqx1Erk9E6I1qt+4WDAwfzXfNsTya7cZ3ilq0LTiRoeX57Zk5bc= X-Received: by 2002:a17:902:20b:: with SMTP id 11mr18737502plc.78.1561427056699; Mon, 24 Jun 2019 18:44:16 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Mon, 24 Jun 2019 20:44:05 -0500 Message-ID: Subject: [PATCH][SMB3] do not negotiate compression information unless explicitly requested by user at mount 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 Since in theory a server could respond with compressed read responses even if not requested on read request (assuming that a compression negcontext is sent in negotiate protocol) - do not send compression information during negotiate protocol unless the user asks for compression explicitly (compression is experimental), and add a mount warning that compression is experimental. From 3d635d89bde9ea033ac72178053abf668c937268 Mon Sep 17 00:00:00 2001 From: Steve French Date: Mon, 24 Jun 2019 20:39:04 -0500 Subject: [PATCH] smb3: do not send compression info by default Since in theory a server could respond with compressed read responses even if not requested on read request (assuming that a compression negcontext is sent in negotiate protocol) - do not send compression information during negotiate protocol unless the user asks for compression explicitly (compression is experimental), and add a mount warning that compression is experimental. Signed-off-by: Steve French --- fs/cifs/cifsglob.h | 1 + fs/cifs/connect.c | 8 ++++++++ fs/cifs/smb2pdu.c | 22 ++++++++++++---------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 90867264ba4e..dd99d0318b77 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -601,6 +601,7 @@ struct smb_vol { __u64 snapshot_time; /* needed for timewarp tokens */ __u32 handle_timeout; /* persistent and durable handle timeout in ms */ unsigned int max_credits; /* smb3 max_credits 10 < credits < 60000 */ + __u16 compression; /* compression algorithm 0xFFFF default 0=disabled */ }; /** diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 54e2b2652c3d..da85a251a609 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -97,6 +97,7 @@ enum { Opt_persistent, Opt_nopersistent, Opt_resilient, Opt_noresilient, Opt_domainauto, Opt_rdma, Opt_modeace, + Opt_compress, /* Mount options which take numeric value */ Opt_backupuid, Opt_backupgid, Opt_uid, @@ -213,6 +214,7 @@ static const match_table_t cifs_mount_option_tokens = { { Opt_echo_interval, "echo_interval=%s" }, { Opt_max_credits, "max_credits=%s" }, { Opt_snapshot, "snapshot=%s" }, + { Opt_compress, "compress=%s" }, { Opt_blank_user, "user=" }, { Opt_blank_user, "username=" }, @@ -1915,6 +1917,11 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, case Opt_rdma: vol->rdma = true; break; + case Opt_compress: + vol->compression = UNKNOWN_TYPE; + cifs_dbg(VFS, + "SMB3 compression support is experimental\n"); + break; /* Numeric Values */ case Opt_backupuid: @@ -2691,6 +2698,7 @@ cifs_get_tcp_session(struct smb_vol *volume_info) tcp_ses->sequence_number = 0; tcp_ses->reconnect_instance = 1; tcp_ses->lstrp = jiffies; + tcp_ses->compress_algorithm = cpu_to_le16(volume_info->compression); spin_lock_init(&tcp_ses->req_lock); INIT_LIST_HEAD(&tcp_ses->tcp_ses_list); INIT_LIST_HEAD(&tcp_ses->smb_ses_list); diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index ab3300a39071..8e289404f6b0 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -521,7 +521,7 @@ build_posix_ctxt(struct smb2_posix_neg_context *pneg_ctxt) static void assemble_neg_contexts(struct smb2_negotiate_req *req, - unsigned int *total_len) + struct TCP_Server_Info *server, unsigned int *total_len) { char *pneg_ctxt = (char *)req; unsigned int ctxt_len; @@ -551,17 +551,19 @@ assemble_neg_contexts(struct smb2_negotiate_req *req, *total_len += ctxt_len; pneg_ctxt += ctxt_len; - build_compression_ctxt((struct smb2_compression_capabilities_context *) + if (server->compress_algorithm) { + build_compression_ctxt((struct smb2_compression_capabilities_context *) pneg_ctxt); - ctxt_len = DIV_ROUND_UP( - sizeof(struct smb2_compression_capabilities_context), 8) * 8; - *total_len += ctxt_len; - pneg_ctxt += ctxt_len; - + ctxt_len = DIV_ROUND_UP( + sizeof(struct smb2_compression_capabilities_context), + 8) * 8; + *total_len += ctxt_len; + pneg_ctxt += ctxt_len; + req->NegotiateContextCount = cpu_to_le16(4); + } else + req->NegotiateContextCount = cpu_to_le16(3); build_posix_ctxt((struct smb2_posix_neg_context *)pneg_ctxt); *total_len += sizeof(struct smb2_posix_neg_context); - - req->NegotiateContextCount = cpu_to_le16(4); } static void decode_preauth_context(struct smb2_preauth_neg_context *ctxt) @@ -829,7 +831,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) if ((ses->server->vals->protocol_id == SMB311_PROT_ID) || (strcmp(ses->server->vals->version_string, SMBDEFAULT_VERSION_STRING) == 0)) - assemble_neg_contexts(req, &total_len); + assemble_neg_contexts(req, server, &total_len); } iov[0].iov_base = (char *)req; iov[0].iov_len = total_len; -- 2.20.1