From patchwork Wed Jan 23 21:10:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 10777897 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 332B16C2 for ; Wed, 23 Jan 2019 21:11:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22F972D7AB for ; Wed, 23 Jan 2019 21:11:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 172D72D7B2; Wed, 23 Jan 2019 21:11:06 +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 B68D72D7AB for ; Wed, 23 Jan 2019 21:11:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726986AbfAWVLF (ORCPT ); Wed, 23 Jan 2019 16:11:05 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:40347 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726345AbfAWVLF (ORCPT ); Wed, 23 Jan 2019 16:11:05 -0500 Received: by mail-pf1-f193.google.com with SMTP id i12so1797298pfo.7 for ; Wed, 23 Jan 2019 13:11:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=JAfa0JuQPeYT0y1DZJoCgVYjJwRFg7nzqNfB27hPUYU=; b=n0l7VKt8TLgzsJOfZrfsCrsY3gSfu3NmsTvnhz8qkTuXrIZLGXAbQ7F3oZS+jftIi3 0N9EmLJqpxbBk+q/2ByXDGSJdmqVgJcAoB6ub4Gt8z+W8p/KU0Oaj+ywfbI8EPN51e8/ q6PGnaJZDrnP4BtWL41QIlVVSPTmPYFJvEm3TngVoaZSrTzgRQyVKrGtKvJQDK0HfTje VkwBdsyhbRb3lfrdl05fhsOVsH74MnXg3eG92JaiVKsjL3C9QHAd4yXBL4mU+k+uV/YX fW+3oE537ETpHiFIpTfBEI/Oo7TGkrXWvPGo17noCTjpWPT1CoHue6bywY+NqiESn/5a BFhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=JAfa0JuQPeYT0y1DZJoCgVYjJwRFg7nzqNfB27hPUYU=; b=tpbuK/mR402T6AE4BkjSwAUyjmODTJ7Oh7aW40wZJPlj1RcHNHGzeF2R6aInH3IooW VFS4Zk6Su7HbQMe6u5Wf/fafl6tH8ncrGXUTfwkCYniivy9miWZQKBgdKoNXo/bNgC4J v3ItqslVLVUMMsxxszy4Cb4B7EGwQVCnjun3YUoSpuNbKxHus/dN0Lev5pyWme3o4xzL 7i5dXp5KPsN+HheB5RsmmXdhsULATBuRDRL+gFTLQS0e/eJmsul7N48lSJBQUzkmHL5h OilB8L34H8uTmNaOjYgSzijqFHRDU1iJQ/j9fU39hS/p9d+pxeJAjhOq8ljuzKEpSUSb LOlg== X-Gm-Message-State: AJcUukf937Exa3ieBN5k8lYq9wPSxDtJLJoXsxs2Vu8bwwmniyYWWPTS JV4MI2JwU5I/720pjDg5S3blnT8= X-Google-Smtp-Source: ALg8bN5Pyjv7BC9b1BGR3m3jqC2WPT2ApNhv4876DnWdc9AUlZ/RuaGFPChqgr3yfVh/s78ij7pLCQ== X-Received: by 2002:aa7:8542:: with SMTP id y2mr3681362pfn.83.1548277863900; Wed, 23 Jan 2019 13:11:03 -0800 (PST) Received: from ubuntu-vm.corp.microsoft.com ([2001:4898:80e8:f:a17f:4e9f:6b7c:507d]) by smtp.gmail.com with ESMTPSA id n73sm28063714pfj.148.2019.01.23.13.11.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Jan 2019 13:11:02 -0800 (PST) From: Pavel Shilovsky X-Google-Original-From: Pavel Shilovsky To: linux-cifs@vger.kernel.org, Steve French , Ronnie Sahlberg Subject: [PATCH 09/15] CIFS: Respect SMB2 hdr preamble size in read responses Date: Wed, 23 Jan 2019 13:10:39 -0800 Message-Id: <1548277845-6746-10-git-send-email-pshilov@microsoft.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1548277845-6746-1-git-send-email-pshilov@microsoft.com> References: <1548277845-6746-1-git-send-email-pshilov@microsoft.com> 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 There are a couple places where we still account for 4 bytes in the beginning of SMB2 packet which is not true in the current code. Fix this to use a header preamble size where possible. Signed-off-by: Pavel Shilovsky --- fs/cifs/cifssmb.c | 7 ++++--- fs/cifs/smb2ops.c | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 920c9f5..c8792d2 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1603,9 +1603,10 @@ cifs_readv_receive(struct TCP_Server_Info *server, struct mid_q_entry *mid) /* set up first two iov for signature check and to get credits */ rdata->iov[0].iov_base = buf; - rdata->iov[0].iov_len = 4; - rdata->iov[1].iov_base = buf + 4; - rdata->iov[1].iov_len = server->total_read - 4; + rdata->iov[0].iov_len = server->vals->header_preamble_size; + rdata->iov[1].iov_base = buf + server->vals->header_preamble_size; + rdata->iov[1].iov_len = + server->total_read - server->vals->header_preamble_size; cifs_dbg(FYI, "0: iov_base=%p iov_len=%zu\n", rdata->iov[0].iov_base, rdata->iov[0].iov_len); cifs_dbg(FYI, "1: iov_base=%p iov_len=%zu\n", diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 73eb0e5..3ee8258 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -3198,10 +3198,10 @@ handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid, /* set up first two iov to get credits */ rdata->iov[0].iov_base = buf; - rdata->iov[0].iov_len = 4; - rdata->iov[1].iov_base = buf + 4; + rdata->iov[0].iov_len = 0; + rdata->iov[1].iov_base = buf; rdata->iov[1].iov_len = - min_t(unsigned int, buf_len, server->vals->read_rsp_size) - 4; + min_t(unsigned int, buf_len, server->vals->read_rsp_size); cifs_dbg(FYI, "0: iov_base=%p iov_len=%zu\n", rdata->iov[0].iov_base, rdata->iov[0].iov_len); cifs_dbg(FYI, "1: iov_base=%p iov_len=%zu\n",