From patchwork Thu Aug 23 06:06:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ronnie Sahlberg X-Patchwork-Id: 10573463 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 BA6CC13B6 for ; Thu, 23 Aug 2018 06:06:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1A742BB18 for ; Thu, 23 Aug 2018 06:06:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 957EB2BB9F; Thu, 23 Aug 2018 06:06:57 +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.9 required=2.0 tests=BAYES_00,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 218522BB18 for ; Thu, 23 Aug 2018 06:06:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725960AbeHWJe5 (ORCPT ); Thu, 23 Aug 2018 05:34:57 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34526 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725924AbeHWJe5 (ORCPT ); Thu, 23 Aug 2018 05:34:57 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7478FDFFD; Thu, 23 Aug 2018 06:06:55 +0000 (UTC) Received: from test1135.test.redhat.com (vpn2-54-77.bne.redhat.com [10.64.54.77]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3A292026DE4; Thu, 23 Aug 2018 06:06:54 +0000 (UTC) From: Ronnie Sahlberg To: linux-cifs Cc: Steve French Subject: [PATCH] cifs: fake server->total_read for decrypted smb3 compounds Date: Thu, 23 Aug 2018 16:06:47 +1000 Message-Id: <20180823060647.20439-1-lsahlber@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 23 Aug 2018 06:06:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Thu, 23 Aug 2018 06:06:55 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lsahlber@redhat.com' RCPT:'' 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 When we have decrypted a compounded smb3 packet we need to fake total_read to match the individual pdu's in that compound. Otherwise, if we leave total_read to be the size of the full smb3 transform pdu this will trigger smb2_check_message to flag a length warning. Signed-off-by: Ronnie Sahlberg --- fs/cifs/smb2misc.c | 2 +- fs/cifs/smb2ops.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c index db0453660ff6..1fec74d27525 100644 --- a/fs/cifs/smb2misc.c +++ b/fs/cifs/smb2misc.c @@ -241,7 +241,7 @@ smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr) * Some windows servers (win2016) will pad also the final * PDU in a compound to 8 bytes. */ - if (((clc_len + 7) & ~7) == len) + if (roundup(clc_len, 8) == len) return 0; /* diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index cf3ad04e5bb1..8821990fd521 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -3104,7 +3104,12 @@ receive_encrypted_standard(struct TCP_Server_Info *server, memcpy(next_buffer, tmpbuf + le32_to_cpu(shdr->NextCommand), pdu_length - le32_to_cpu(shdr->NextCommand)); - } + + server->total_read = + le32_to_cpu(shdr->NextCommand); + } else + server->total_read = + pdu_length - sizeof(struct smb2_transform_hdr); mid_entry = smb2_find_mid(server, buf); if (mid_entry == NULL)