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: 961176 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-cifs-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41wv7k0tNyz9s3C for ; Thu, 23 Aug 2018 16:06:57 +1000 (AEST) 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 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)