diff mbox series

cifs: check if SMB2 PDU size has been padded and suppress the warning

Message ID 20180822021924.22872-1-lsahlber@redhat.com
State New
Headers show
Series cifs: check if SMB2 PDU size has been padded and suppress the warning | expand

Commit Message

Ronnie Sahlberg Aug. 22, 2018, 2:19 a.m. UTC
Some SMB2/3 servers, Win2016 but possibly others too, adds padding
not only between PDUs in a compound but also to the final PDU.
This padding extends the PDU to a multiple of 8 bytes.

Check if the unexpected length looks like this might be the case
and avoid triggering the log messages for :

  "SMB2 server sent bad RFC1001 len %d not %d\n"

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/smb2misc.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Aurélien Aptel Aug. 22, 2018, 9:37 a.m. UTC | #1
Ronnie Sahlberg <lsahlber@redhat.com> writes:
> +		 */
> +		if (((clc_len + 7) & ~7) == len)
> +			return 0;

Kind of nitpicking but we could use the roundup() helper ie: roundup(clc_len, 8) == len
It's more readable and compiles to the same thing. Otherwise looks good.

Reviewed-by: Aurelien Aptel <aaptel@suse.com>

Cheers,
diff mbox series

Patch

diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
index 303d4592ebe7..db0453660ff6 100644
--- a/fs/cifs/smb2misc.c
+++ b/fs/cifs/smb2misc.c
@@ -238,6 +238,13 @@  smb2_check_message(char *buf, unsigned int len, struct TCP_Server_Info *srvr)
 			return 0;
 
 		/*
+		 * Some windows servers (win2016) will pad also the final
+		 * PDU in a compound to 8 bytes.
+		 */
+		if (((clc_len + 7) & ~7) == len)
+			return 0;
+
+		/*
 		 * MacOS server pads after SMB2.1 write response with 3 bytes
 		 * of junk. Other servers match RFC1001 len to actual
 		 * SMB2/SMB3 frame length (header + smb2 response specific data)