From patchwork Fri Jun 15 13:35:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paulo Alcantara (SUSE)" X-Patchwork-Id: 10466499 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ECFAB60384 for ; Fri, 15 Jun 2018 13:36:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB1D828CF7 for ; Fri, 15 Jun 2018 13:36:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDA0A28DA2; Fri, 15 Jun 2018 13:36:03 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 4188228CF7 for ; Fri, 15 Jun 2018 13:35:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936144AbeFONfx (ORCPT ); Fri, 15 Jun 2018 09:35:53 -0400 Received: from mail.paulo.ac ([34.238.86.106]:60212 "EHLO mail.paulo.ac" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933771AbeFONfx (ORCPT ); Fri, 15 Jun 2018 09:35:53 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.paulo.ac (Postfix) with ESMTP id CC0E5C0A8C9; Fri, 15 Jun 2018 13:35:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at paulo.ac Authentication-Results: mail.paulo.ac (amavisd-new); dkim=pass (1024-bit key) header.d=paulo.ac Received: from mail.paulo.ac ([127.0.0.1]) by localhost (mail.paulo.ac [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fSz7ij-Z98Zf; Fri, 15 Jun 2018 13:35:50 +0000 (UTC) Received: from localhost.localdomain (189.27.156.160.dynamic.adsl.gvt.net.br [189.27.156.160]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.paulo.ac (Postfix) with ESMTPSA id 7E095C0A8C8; Fri, 15 Jun 2018 13:35:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.paulo.ac 7E095C0A8C8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=paulo.ac; s=default; t=1529069750; bh=KT7iJOYBqieRv5h1A2Y0TrQfADOg4gtU4trNvH7KPwc=; h=From:To:Cc:Subject:Date:From; b=ONczXiaY3kWQhyNTSQFwZwz/HoVWoDaLSM1yrmBpBjXfZ+DRFYuOTuH9wGT+kdM3J I+V3TkRVZhpoyWiq+MbijedZDNvXPIMa7pN3M9NgfCtqrHhq5rPArninw+0hZczkX0 dZAf+FCNQ5oj/XKI8dbWPgLgbgLmIWfto5a13XdU= From: Paulo Alcantara To: linux-cifs@vger.kernel.org Cc: smfrench@gmail.com, Paulo Alcantara , Paulo Alcantara Subject: [PATCH] cifs: Fix broken SMB2_TRANSFORM header being sent Date: Fri, 15 Jun 2018 10:35:44 -0300 Message-Id: <20180615133544.7514-1-paulo@paulo.ac> X-Mailer: git-send-email 2.17.1 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 In smb3_init_transform_rq(), 'orig_len' was only counting the request length, but forgot to also include the number of bytes of the data being written. That said, writing or creating files with the 'seal' mount point was broken. Signed-off-by: Paulo Alcantara --- fs/cifs/smb2ops.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index badcfb2f3c22..ea198134fb48 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -2502,6 +2502,14 @@ smb3_init_transform_rq(struct TCP_Server_Info *server, struct smb_rqst *new_rq, for (i = 0; i < old_rq->rq_nvec; i++) orig_len += old_rq->rq_iov[i].iov_len; + if (old_rq->rq_npages) { + orig_len += old_rq->rq_tailsz; + } else { + orig_len += old_rq->rq_pagesz * (old_rq->rq_npages - 1) - + old_rq->rq_offset; + orig_len += old_rq->rq_tailsz; + } + for (i = 0; i < npages; i++) { pages[i] = alloc_page(GFP_KERNEL|__GFP_HIGHMEM); if (!pages[i])