linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][CIFS] Workaround MacOS server problem with SMB2.1 write response
@ 2014-08-12 14:19 Steve French
  2014-08-14 19:30 ` Jeff Layton
  0 siblings, 1 reply; 9+ messages in thread
From: Steve French @ 2014-08-12 14:19 UTC (permalink / raw)
  To: linux-cifs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-fsdevel,
	samba-technical

Writes fail to Mac servers with SMB2.1 mounts (works with cifs though) due
to them sending an incorrect RFC1001 length. Workaround this problem.
MacOS server sends a write response with 3 bytes of pad beyond the end
of the SMB itself.  The RFC1001 length is 3 bytes more than
the sum of the SMB2.1 header length + the write reponse.

Since we have seen a few other examples where servers have
padded responses strangely (oplock break and create),
allow servers to send a padded SMB2/SMB3 response to allow
for rounding (up to 15 bytes).

Signed-off-by: Steve French <smfrench-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 fs/cifs/smb2misc.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c
index f2e6ac2..da05beb 100644
--- a/fs/cifs/smb2misc.c
+++ b/fs/cifs/smb2misc.c
@@ -181,6 +181,12 @@ smb2_check_message(char *buf, unsigned int length)
         /* server can return one byte more */
         if (clc_len == 4 + len + 1)
             return 0;
+
+        /* MacOS server pads after SMB2.1 write response with 3 bytes */
+        /* of junk. Allow server to pad up to 15 bytes of junk at end */
+        if ((clc_len < 4 + len) && (clc_len > 4 + len - 16))
+            return 0;
+
         return 1;
     }
     return 0;

-- 
Thanks,

Steve

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-08-14 21:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-12 14:19 [PATCH][CIFS] Workaround MacOS server problem with SMB2.1 write response Steve French
2014-08-14 19:30 ` Jeff Layton
     [not found]   ` <20140814153015.030657f7-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2014-08-14 19:35     ` Jeremy Allison
2014-08-14 20:26       ` Steve French
     [not found]         ` <CAH2r5muwftfpt2kjvf4fM78X6JZ5H-Kt415+Z2AojTDUkPrArA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-08-14 20:40           ` Jeff Layton
2014-08-14 20:44             ` Jeremy Allison
2014-08-14 21:15               ` Steve French
     [not found]                 ` <CAH2r5mtE5efZKnroxXerfWLEgGdx-6Wry4788HiPKUaa+bhhLg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-08-14 21:21                   ` Jeremy Allison
2014-08-14 20:37     ` Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).