diff mbox series

cifs: fake server->total_read for decrypted smb3 compounds

Message ID 20180823060647.20439-1-lsahlber@redhat.com
State New
Headers show
Series cifs: fake server->total_read for decrypted smb3 compounds | expand

Commit Message

Ronnie Sahlberg Aug. 23, 2018, 6:06 a.m. UTC
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 <lsahlber@redhat.com>
---
 fs/cifs/smb2misc.c | 2 +-
 fs/cifs/smb2ops.c  | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
diff mbox series

Patch

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)