[cifs-protocol] Clarification on expected behavior with SMB2 short reads/writes. [120051422002815]

Jeremy Allison jra at samba.org
Tue May 26 21:21:29 UTC 2020


On Thu, May 21, 2020 at 07:12:08PM +0000, Obaid Farooqi wrote:
> Hi Jeremy:
> When you conducted this experiment, what tool on the Windows client you used? 
> Also please upload the wireshark trace to the following link:
> 
> File Transfer - Case 120051422002815
> https://support.microsoft.com/files?workspace=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJ3c2lkIjoiZjk5NGVkMjEtOGRjMS00Yjc5LTlkMmMtZTgyYTQ5NjU0ZTMzIiwic3IiOiIxMjAwNTE0MjIwMDI4MTUiLCJhcHBpZCI6ImU2ZWU0M2ViLTBmYmMtNDU0Ni1iYzUyLTRjMTYxZmNkZjRjNCIsInN2IjoidjEiLCJycyI6IkV4dGVybmFsIiwid3RpZCI6ImY2Y2ZmNjgwLTdkNmItNGZmNC1iY2I4LTBkODlkZmFmNWVlYiIsImlzcyI6Imh0dHBzOi8vYXBpLmR0bW5lYnVsYS5taWNyb3NvZnQuY29tIiwiYXVkIjoiaHR0cDovL3NtYyIsImV4cCI6MTU5Nzg2Mzk2OSwibmJmIjoxNTkwMDg3OTY5fQ.TCJb-9xWE1RZrXp1GDSp1Unx7yHMhzJ2wRb5GgLQo5EOWIofcdIIKOB4LpOaRHPtcjtJd96_OXfx_WRwLW-o0s3XMWYZ9RReQF2RsJQX8EhNXRhwBPsfUXcAKaIl3wS7hHWDdITCSLLzSs2b0vLSVeMe99oM4xEhS6PL95lkKDQp0p0WJOavfmGALp2P9TDKUAt4Frr28kYeRApGqnUW92udk2cM0s9aySc9UkMGmqPiNHQhIxowOGSXvyxu7M6KgTbur62dPriya3w85-d9AILwq_o63xv8xieNQqO6VEdODx9NHrIauUZO9KyaSzEJjlbszoktVdwyEe-ne1MFpA&wid=f994ed21-8dc1-4b79-9d2c-e82a49654e33
> 
> 
> username: 120051422002815_noemail at dtmxfer.onmicrosoft.com
> Password: G[+3G99l

OK. The files are there.

win10short-read.pcapng is the wireshark trace of copying
the file: aaa.txt (a file consisting of 10MB of the letter
'A'). badfile.txt is what I ended up with on the Windows10
client after deliberately returning a short read on one of
the read requests.

$ md5sum aaa.txt
cfc7616fa5ff7bcdd7e3c1a07ae89b7f  aaa.txt

$ md5sum badfile.txt
d2178e7afdd1ee1a170abd46a2696dc0  badfile.txt

Looking at the wireshark trace you can see the read
request at packet 44 - requesting a read of 32768 bytes
at offset 0, and my deliberately short reply (-2 bytes)
at packet 68 - I return 32766 bytes.

The Windows client never goes back for those 2 bytes.

Let me know if you need more info !

To reproduce, add the following patch to any recent
Samba.

diff --git a/source3/smbd/smb2_read.c b/source3/smbd/smb2_read.c
index 3441ac27c0c..f59d3ebcbb9 100644
--- a/source3/smbd/smb2_read.c
+++ b/source3/smbd/smb2_read.c
@@ -419,6 +419,10 @@ NTSTATUS smb2_read_complete(struct tevent_req *req, ssize_t nread, int err)
                (unsigned long)state->in_offset,
                (unsigned long)nread));
 
+       if (state->in_offset == 0 && nread > 2) {
+               nread -= 2;
+       }
+
        state->out_data.length = nread;
        state->out_remaining = 0;

and then copy a file.

Cheers,

	Jeremy.



More information about the cifs-protocol mailing list