From patchwork Fri Feb 1 20:03:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 10793663 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 866831390 for ; Fri, 1 Feb 2019 20:04:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 75FA232C9E for ; Fri, 1 Feb 2019 20:04:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 655E4330BE; Fri, 1 Feb 2019 20:04:38 +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 4CB7332C9E for ; Fri, 1 Feb 2019 20:04:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730697AbfBAUEh (ORCPT ); Fri, 1 Feb 2019 15:04:37 -0500 Received: from mail-pl1-f170.google.com ([209.85.214.170]:40265 "EHLO mail-pl1-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730654AbfBAUEg (ORCPT ); Fri, 1 Feb 2019 15:04:36 -0500 Received: by mail-pl1-f170.google.com with SMTP id u18so3741474plq.7 for ; Fri, 01 Feb 2019 12:04:36 -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=0vG0ItUofS7Hr3Vjltitg5/iFPuTngU7I0QuDylkY/Q=; b=CiMef5fJr44Y9ezp3vg5JIk1Xtalf/6ZekBSo/svRgDpMgNcV01J1IHjg+Cpw/CHgE SAsYxcci74ldeIz/c6cW4zewTvpbHQXXLClSefNzgRHLNI1CW38GMobLpWzAKEsJT7Uu NtgiSB1okkGWlZNZBfq0T0O6waUDlUIRbU4jomEcewCCOlRjcdYUNVvSl3YfPPavv56q /B9Vo2eCDK3eQ3RVPonNU0CZh5WXjSvdWo4b+Px2sksB6bEWmxHmsa/eEZcTYiNl/ume j1BohKyVfJHAdHMzYAyKwr8eLAZ5ozqK8b9bWxTAPtZFgIdWIYlWlj0qYZQD5ucwAda6 bnSg== 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=0vG0ItUofS7Hr3Vjltitg5/iFPuTngU7I0QuDylkY/Q=; b=DqN7WivSsWWmkidsXC5zh3XmE83X2AukYbVjv8GEi7dwUAMosnoj+iVuTp1oEiEXYs MrWeeLqXXglBkZkt/qYOesgglWowrPgnI75dH7iSRYiQMnziNgx9b+iTIm2KUyjPp7aq 5jtU9WBELJiPgJeput5DBRmvaE4HRTbME7D+Px4AceG0lHGfCtyQZjR4Jj+YocR/vMjs pSkfT9d/7rxxsP8RRRmxAvL1F+X+F2bQ1X/3tMnLE2kM3GIDUMif2b0SU5eKWEnEAwDz Pu8FlX5IJ/fR9mItr54A1wISdjHrKIVcUQxsw78GZDK7bd7g6+RJGHk0Pp9mqPGllmkU knfQ== X-Gm-Message-State: AJcUukdUt4dtB0edI3V4hqAwQDxSZaVLaB48m6kxQbOrsJuIu6hXrrQu O+5ct5plfZgm1Z8VkHfWD7zxs6U= X-Google-Smtp-Source: ALg8bN5nZD0fhoCdvrw/hQ4Gr/P4+31SNXzQzVVaOjY6ixsJXJRxYsGy3RBBfZLpFgkWIJj8dIqz5g== X-Received: by 2002:a17:902:8f83:: with SMTP id z3mr39832105plo.328.1549051474900; Fri, 01 Feb 2019 12:04:34 -0800 (PST) Received: from ubuntu-vm.corp.microsoft.com ([2001:4898:80e8:0:a18e:4e9f:6b7c:507d]) by smtp.gmail.com with ESMTPSA id x11sm24247451pfe.72.2019.02.01.12.04.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Feb 2019 12:04:33 -0800 (PST) From: Pavel Shilovsky X-Google-Original-From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Subject: [PATCH 09/23] CIFS: Respect SMB2 hdr preamble size in read responses Date: Fri, 1 Feb 2019 12:03:58 -0800 Message-Id: <1549051452-5968-11-git-send-email-pshilov@microsoft.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549051452-5968-1-git-send-email-pshilov@microsoft.com> References: <1549051452-5968-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 Signed-off-by: Steve French --- 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 d40ded3..0ea06f5 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1612,9 +1612,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 b2849a7..5489f7d 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -3216,10 +3216,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",