diff options
-rw-r--r-- | fs/cifs/cifsencrypt.c | 2 | ||||
-rw-r--r-- | fs/cifs/cifspdu.h | 6 | ||||
-rw-r--r-- | fs/cifs/cifssmb.c | 123 | ||||
-rw-r--r-- | fs/cifs/connect.c | 12 | ||||
-rw-r--r-- | fs/cifs/misc.c | 8 | ||||
-rw-r--r-- | fs/cifs/sess.c | 5 | ||||
-rw-r--r-- | fs/cifs/transport.c | 47 |
7 files changed, 102 insertions, 101 deletions
diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c index e7c59314894f..45c3f78c8f81 100644 --- a/fs/cifs/cifsencrypt.c +++ b/fs/cifs/cifsencrypt.c | |||
@@ -60,7 +60,7 @@ static int cifs_calculate_signature(const struct smb_hdr *cifs_pdu, | |||
60 | server->session_key.response, server->session_key.len); | 60 | server->session_key.response, server->session_key.len); |
61 | 61 | ||
62 | crypto_shash_update(&server->secmech.sdescmd5->shash, | 62 | crypto_shash_update(&server->secmech.sdescmd5->shash, |
63 | cifs_pdu->Protocol, cifs_pdu->smb_buf_length); | 63 | cifs_pdu->Protocol, be32_to_cpu(cifs_pdu->smb_buf_length)); |
64 | 64 | ||
65 | rc = crypto_shash_final(&server->secmech.sdescmd5->shash, signature); | 65 | rc = crypto_shash_final(&server->secmech.sdescmd5->shash, signature); |
66 | 66 | ||
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h index b5c8cc5d7a7f..eac95e26d696 100644 --- a/fs/cifs/cifspdu.h +++ b/fs/cifs/cifspdu.h | |||
@@ -397,9 +397,9 @@ | |||
397 | #define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */ | 397 | #define GETU32(var) (*((__u32 *)var)) /* BB check for endian issues */ |
398 | 398 | ||
399 | struct smb_hdr { | 399 | struct smb_hdr { |
400 | __u32 smb_buf_length; /* big endian on wire *//* BB length is only two | 400 | __be32 smb_buf_length; /* BB length is only two (rarely three) bytes, |
401 | or three bytes - with one or two byte type preceding it that are | 401 | with one or two byte "type" preceding it that will be |
402 | zero - we could mask the type byte off just in case BB */ | 402 | zero - we could mask the type byte off */ |
403 | __u8 Protocol[4]; | 403 | __u8 Protocol[4]; |
404 | __u8 Command; | 404 | __u8 Command; |
405 | union { | 405 | union { |
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 64dad47641a1..88004094ebd1 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
@@ -358,6 +358,13 @@ vt2_err: | |||
358 | return -EINVAL; | 358 | return -EINVAL; |
359 | } | 359 | } |
360 | 360 | ||
361 | static inline void inc_rfc1001_len(void *pSMB, int count) | ||
362 | { | ||
363 | struct smb_hdr *hdr = (struct smb_hdr *)pSMB; | ||
364 | |||
365 | be32_add_cpu(&hdr->smb_buf_length, count); | ||
366 | } | ||
367 | |||
361 | int | 368 | int |
362 | CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) | 369 | CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) |
363 | { | 370 | { |
@@ -410,7 +417,7 @@ CIFSSMBNegotiate(unsigned int xid, struct cifsSesInfo *ses) | |||
410 | count += strlen(protocols[i].name) + 1; | 417 | count += strlen(protocols[i].name) + 1; |
411 | /* null at end of source and target buffers anyway */ | 418 | /* null at end of source and target buffers anyway */ |
412 | } | 419 | } |
413 | pSMB->hdr.smb_buf_length += count; | 420 | inc_rfc1001_len(pSMB, count); |
414 | pSMB->ByteCount = cpu_to_le16(count); | 421 | pSMB->ByteCount = cpu_to_le16(count); |
415 | 422 | ||
416 | rc = SendReceive(xid, ses, (struct smb_hdr *) pSMB, | 423 | rc = SendReceive(xid, ses, (struct smb_hdr *) pSMB, |
@@ -731,7 +738,7 @@ CIFSSMBEcho(struct TCP_Server_Info *server) | |||
731 | put_unaligned_le16(1, &smb->EchoCount); | 738 | put_unaligned_le16(1, &smb->EchoCount); |
732 | put_bcc_le(1, &smb->hdr); | 739 | put_bcc_le(1, &smb->hdr); |
733 | smb->Data[0] = 'a'; | 740 | smb->Data[0] = 'a'; |
734 | smb->hdr.smb_buf_length += 3; | 741 | inc_rfc1001_len(smb, 3); |
735 | 742 | ||
736 | rc = cifs_call_async(server, (struct smb_hdr *)smb, | 743 | rc = cifs_call_async(server, (struct smb_hdr *)smb, |
737 | cifs_echo_callback, server); | 744 | cifs_echo_callback, server); |
@@ -849,7 +856,7 @@ PsxDelete: | |||
849 | pSMB->TotalParameterCount = pSMB->ParameterCount; | 856 | pSMB->TotalParameterCount = pSMB->ParameterCount; |
850 | pSMB->InformationLevel = cpu_to_le16(SMB_POSIX_UNLINK); | 857 | pSMB->InformationLevel = cpu_to_le16(SMB_POSIX_UNLINK); |
851 | pSMB->Reserved4 = 0; | 858 | pSMB->Reserved4 = 0; |
852 | pSMB->hdr.smb_buf_length += byte_count; | 859 | inc_rfc1001_len(pSMB, byte_count); |
853 | pSMB->ByteCount = cpu_to_le16(byte_count); | 860 | pSMB->ByteCount = cpu_to_le16(byte_count); |
854 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 861 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
855 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | 862 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); |
@@ -895,7 +902,7 @@ DelFileRetry: | |||
895 | pSMB->SearchAttributes = | 902 | pSMB->SearchAttributes = |
896 | cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM); | 903 | cpu_to_le16(ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM); |
897 | pSMB->BufferFormat = 0x04; | 904 | pSMB->BufferFormat = 0x04; |
898 | pSMB->hdr.smb_buf_length += name_len + 1; | 905 | inc_rfc1001_len(pSMB, name_len + 1); |
899 | pSMB->ByteCount = cpu_to_le16(name_len + 1); | 906 | pSMB->ByteCount = cpu_to_le16(name_len + 1); |
900 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 907 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
901 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | 908 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); |
@@ -939,7 +946,7 @@ RmDirRetry: | |||
939 | } | 946 | } |
940 | 947 | ||
941 | pSMB->BufferFormat = 0x04; | 948 | pSMB->BufferFormat = 0x04; |
942 | pSMB->hdr.smb_buf_length += name_len + 1; | 949 | inc_rfc1001_len(pSMB, name_len + 1); |
943 | pSMB->ByteCount = cpu_to_le16(name_len + 1); | 950 | pSMB->ByteCount = cpu_to_le16(name_len + 1); |
944 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 951 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
945 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | 952 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); |
@@ -982,7 +989,7 @@ MkDirRetry: | |||
982 | } | 989 | } |
983 | 990 | ||
984 | pSMB->BufferFormat = 0x04; | 991 | pSMB->BufferFormat = 0x04; |
985 | pSMB->hdr.smb_buf_length += name_len + 1; | 992 | inc_rfc1001_len(pSMB, name_len + 1); |
986 | pSMB->ByteCount = cpu_to_le16(name_len + 1); | 993 | pSMB->ByteCount = cpu_to_le16(name_len + 1); |
987 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 994 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
988 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | 995 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); |
@@ -1060,7 +1067,7 @@ PsxCreat: | |||
1060 | pSMB->TotalParameterCount = pSMB->ParameterCount; | 1067 | pSMB->TotalParameterCount = pSMB->ParameterCount; |
1061 | pSMB->InformationLevel = cpu_to_le16(SMB_POSIX_OPEN); | 1068 | pSMB->InformationLevel = cpu_to_le16(SMB_POSIX_OPEN); |
1062 | pSMB->Reserved4 = 0; | 1069 | pSMB->Reserved4 = 0; |
1063 | pSMB->hdr.smb_buf_length += byte_count; | 1070 | inc_rfc1001_len(pSMB, byte_count); |
1064 | pSMB->ByteCount = cpu_to_le16(byte_count); | 1071 | pSMB->ByteCount = cpu_to_le16(byte_count); |
1065 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 1072 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
1066 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | 1073 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); |
@@ -1225,7 +1232,7 @@ OldOpenRetry: | |||
1225 | pSMB->Sattr = cpu_to_le16(ATTR_HIDDEN | ATTR_SYSTEM | ATTR_DIRECTORY); | 1232 | pSMB->Sattr = cpu_to_le16(ATTR_HIDDEN | ATTR_SYSTEM | ATTR_DIRECTORY); |
1226 | pSMB->OpenFunction = cpu_to_le16(convert_disposition(openDisposition)); | 1233 | pSMB->OpenFunction = cpu_to_le16(convert_disposition(openDisposition)); |
1227 | count += name_len; | 1234 | count += name_len; |
1228 | pSMB->hdr.smb_buf_length += count; | 1235 | inc_rfc1001_len(pSMB, count); |
1229 | 1236 | ||
1230 | pSMB->ByteCount = cpu_to_le16(count); | 1237 | pSMB->ByteCount = cpu_to_le16(count); |
1231 | /* long_op set to 1 to allow for oplock break timeouts */ | 1238 | /* long_op set to 1 to allow for oplock break timeouts */ |
@@ -1338,7 +1345,7 @@ openRetry: | |||
1338 | SECURITY_CONTEXT_TRACKING | SECURITY_EFFECTIVE_ONLY; | 1345 | SECURITY_CONTEXT_TRACKING | SECURITY_EFFECTIVE_ONLY; |
1339 | 1346 | ||
1340 | count += name_len; | 1347 | count += name_len; |
1341 | pSMB->hdr.smb_buf_length += count; | 1348 | inc_rfc1001_len(pSMB, count); |
1342 | 1349 | ||
1343 | pSMB->ByteCount = cpu_to_le16(count); | 1350 | pSMB->ByteCount = cpu_to_le16(count); |
1344 | /* long_op set to 1 to allow for oplock break timeouts */ | 1351 | /* long_op set to 1 to allow for oplock break timeouts */ |
@@ -1423,7 +1430,7 @@ CIFSSMBRead(const int xid, struct cifsTconInfo *tcon, const int netfid, | |||
1423 | } | 1430 | } |
1424 | 1431 | ||
1425 | iov[0].iov_base = (char *)pSMB; | 1432 | iov[0].iov_base = (char *)pSMB; |
1426 | iov[0].iov_len = pSMB->hdr.smb_buf_length + 4; | 1433 | iov[0].iov_len = be32_to_cpu(pSMB->hdr.smb_buf_length) + 4; |
1427 | rc = SendReceive2(xid, tcon->ses, iov, 1 /* num iovecs */, | 1434 | rc = SendReceive2(xid, tcon->ses, iov, 1 /* num iovecs */, |
1428 | &resp_buf_type, CIFS_LOG_ERROR); | 1435 | &resp_buf_type, CIFS_LOG_ERROR); |
1429 | cifs_stats_inc(&tcon->num_reads); | 1436 | cifs_stats_inc(&tcon->num_reads); |
@@ -1557,7 +1564,7 @@ CIFSSMBWrite(const int xid, struct cifsTconInfo *tcon, | |||
1557 | 1564 | ||
1558 | pSMB->DataLengthLow = cpu_to_le16(bytes_sent & 0xFFFF); | 1565 | pSMB->DataLengthLow = cpu_to_le16(bytes_sent & 0xFFFF); |
1559 | pSMB->DataLengthHigh = cpu_to_le16(bytes_sent >> 16); | 1566 | pSMB->DataLengthHigh = cpu_to_le16(bytes_sent >> 16); |
1560 | pSMB->hdr.smb_buf_length += byte_count; | 1567 | inc_rfc1001_len(pSMB, byte_count); |
1561 | 1568 | ||
1562 | if (wct == 14) | 1569 | if (wct == 14) |
1563 | pSMB->ByteCount = cpu_to_le16(byte_count); | 1570 | pSMB->ByteCount = cpu_to_le16(byte_count); |
@@ -1641,11 +1648,12 @@ CIFSSMBWrite2(const int xid, struct cifsTconInfo *tcon, | |||
1641 | 1648 | ||
1642 | pSMB->DataLengthLow = cpu_to_le16(count & 0xFFFF); | 1649 | pSMB->DataLengthLow = cpu_to_le16(count & 0xFFFF); |
1643 | pSMB->DataLengthHigh = cpu_to_le16(count >> 16); | 1650 | pSMB->DataLengthHigh = cpu_to_le16(count >> 16); |
1644 | smb_hdr_len = pSMB->hdr.smb_buf_length + 1; /* hdr + 1 byte pad */ | 1651 | /* header + 1 byte pad */ |
1652 | smb_hdr_len = be32_to_cpu(pSMB->hdr.smb_buf_length) + 1; | ||
1645 | if (wct == 14) | 1653 | if (wct == 14) |
1646 | pSMB->hdr.smb_buf_length += count+1; | 1654 | inc_rfc1001_len(pSMB, count + 1); |
1647 | else /* wct == 12 */ | 1655 | else /* wct == 12 */ |
1648 | pSMB->hdr.smb_buf_length += count+5; /* smb data starts later */ | 1656 | inc_rfc1001_len(pSMB, count + 5); /* smb data starts later */ |
1649 | if (wct == 14) | 1657 | if (wct == 14) |
1650 | pSMB->ByteCount = cpu_to_le16(count + 1); | 1658 | pSMB->ByteCount = cpu_to_le16(count + 1); |
1651 | else /* wct == 12 */ /* bigger pad, smaller smb hdr, keep offset ok */ { | 1659 | else /* wct == 12 */ /* bigger pad, smaller smb hdr, keep offset ok */ { |
@@ -1745,7 +1753,7 @@ CIFSSMBLock(const int xid, struct cifsTconInfo *tcon, | |||
1745 | /* oplock break */ | 1753 | /* oplock break */ |
1746 | count = 0; | 1754 | count = 0; |
1747 | } | 1755 | } |
1748 | pSMB->hdr.smb_buf_length += count; | 1756 | inc_rfc1001_len(pSMB, count); |
1749 | pSMB->ByteCount = cpu_to_le16(count); | 1757 | pSMB->ByteCount = cpu_to_le16(count); |
1750 | 1758 | ||
1751 | if (waitFlag) { | 1759 | if (waitFlag) { |
@@ -1836,14 +1844,14 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon, | |||
1836 | pSMB->Fid = smb_file_id; | 1844 | pSMB->Fid = smb_file_id; |
1837 | pSMB->InformationLevel = cpu_to_le16(SMB_SET_POSIX_LOCK); | 1845 | pSMB->InformationLevel = cpu_to_le16(SMB_SET_POSIX_LOCK); |
1838 | pSMB->Reserved4 = 0; | 1846 | pSMB->Reserved4 = 0; |
1839 | pSMB->hdr.smb_buf_length += byte_count; | 1847 | inc_rfc1001_len(pSMB, byte_count); |
1840 | pSMB->ByteCount = cpu_to_le16(byte_count); | 1848 | pSMB->ByteCount = cpu_to_le16(byte_count); |
1841 | if (waitFlag) { | 1849 | if (waitFlag) { |
1842 | rc = SendReceiveBlockingLock(xid, tcon, (struct smb_hdr *) pSMB, | 1850 | rc = SendReceiveBlockingLock(xid, tcon, (struct smb_hdr *) pSMB, |
1843 | (struct smb_hdr *) pSMBr, &bytes_returned); | 1851 | (struct smb_hdr *) pSMBr, &bytes_returned); |
1844 | } else { | 1852 | } else { |
1845 | iov[0].iov_base = (char *)pSMB; | 1853 | iov[0].iov_base = (char *)pSMB; |
1846 | iov[0].iov_len = pSMB->hdr.smb_buf_length + 4; | 1854 | iov[0].iov_len = be32_to_cpu(pSMB->hdr.smb_buf_length) + 4; |
1847 | rc = SendReceive2(xid, tcon->ses, iov, 1 /* num iovecs */, | 1855 | rc = SendReceive2(xid, tcon->ses, iov, 1 /* num iovecs */, |
1848 | &resp_buf_type, timeout); | 1856 | &resp_buf_type, timeout); |
1849 | pSMB = NULL; /* request buf already freed by SendReceive2. Do | 1857 | pSMB = NULL; /* request buf already freed by SendReceive2. Do |
@@ -2009,7 +2017,7 @@ renameRetry: | |||
2009 | } | 2017 | } |
2010 | 2018 | ||
2011 | count = 1 /* 1st signature byte */ + name_len + name_len2; | 2019 | count = 1 /* 1st signature byte */ + name_len + name_len2; |
2012 | pSMB->hdr.smb_buf_length += count; | 2020 | inc_rfc1001_len(pSMB, count); |
2013 | pSMB->ByteCount = cpu_to_le16(count); | 2021 | pSMB->ByteCount = cpu_to_le16(count); |
2014 | 2022 | ||
2015 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 2023 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -2089,7 +2097,7 @@ int CIFSSMBRenameOpenFile(const int xid, struct cifsTconInfo *pTcon, | |||
2089 | pSMB->InformationLevel = | 2097 | pSMB->InformationLevel = |
2090 | cpu_to_le16(SMB_SET_FILE_RENAME_INFORMATION); | 2098 | cpu_to_le16(SMB_SET_FILE_RENAME_INFORMATION); |
2091 | pSMB->Reserved4 = 0; | 2099 | pSMB->Reserved4 = 0; |
2092 | pSMB->hdr.smb_buf_length += byte_count; | 2100 | inc_rfc1001_len(pSMB, byte_count); |
2093 | pSMB->ByteCount = cpu_to_le16(byte_count); | 2101 | pSMB->ByteCount = cpu_to_le16(byte_count); |
2094 | rc = SendReceive(xid, pTcon->ses, (struct smb_hdr *) pSMB, | 2102 | rc = SendReceive(xid, pTcon->ses, (struct smb_hdr *) pSMB, |
2095 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | 2103 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); |
@@ -2156,7 +2164,7 @@ copyRetry: | |||
2156 | } | 2164 | } |
2157 | 2165 | ||
2158 | count = 1 /* 1st signature byte */ + name_len + name_len2; | 2166 | count = 1 /* 1st signature byte */ + name_len + name_len2; |
2159 | pSMB->hdr.smb_buf_length += count; | 2167 | inc_rfc1001_len(pSMB, count); |
2160 | pSMB->ByteCount = cpu_to_le16(count); | 2168 | pSMB->ByteCount = cpu_to_le16(count); |
2161 | 2169 | ||
2162 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 2170 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -2246,7 +2254,7 @@ createSymLinkRetry: | |||
2246 | pSMB->DataOffset = cpu_to_le16(offset); | 2254 | pSMB->DataOffset = cpu_to_le16(offset); |
2247 | pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_UNIX_LINK); | 2255 | pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_UNIX_LINK); |
2248 | pSMB->Reserved4 = 0; | 2256 | pSMB->Reserved4 = 0; |
2249 | pSMB->hdr.smb_buf_length += byte_count; | 2257 | inc_rfc1001_len(pSMB, byte_count); |
2250 | pSMB->ByteCount = cpu_to_le16(byte_count); | 2258 | pSMB->ByteCount = cpu_to_le16(byte_count); |
2251 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 2259 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
2252 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | 2260 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); |
@@ -2332,7 +2340,7 @@ createHardLinkRetry: | |||
2332 | pSMB->DataOffset = cpu_to_le16(offset); | 2340 | pSMB->DataOffset = cpu_to_le16(offset); |
2333 | pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_UNIX_HLINK); | 2341 | pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_UNIX_HLINK); |
2334 | pSMB->Reserved4 = 0; | 2342 | pSMB->Reserved4 = 0; |
2335 | pSMB->hdr.smb_buf_length += byte_count; | 2343 | inc_rfc1001_len(pSMB, byte_count); |
2336 | pSMB->ByteCount = cpu_to_le16(byte_count); | 2344 | pSMB->ByteCount = cpu_to_le16(byte_count); |
2337 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 2345 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
2338 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | 2346 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); |
@@ -2403,7 +2411,7 @@ winCreateHardLinkRetry: | |||
2403 | } | 2411 | } |
2404 | 2412 | ||
2405 | count = 1 /* string type byte */ + name_len + name_len2; | 2413 | count = 1 /* string type byte */ + name_len + name_len2; |
2406 | pSMB->hdr.smb_buf_length += count; | 2414 | inc_rfc1001_len(pSMB, count); |
2407 | pSMB->ByteCount = cpu_to_le16(count); | 2415 | pSMB->ByteCount = cpu_to_le16(count); |
2408 | 2416 | ||
2409 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 2417 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -2474,7 +2482,7 @@ querySymLinkRetry: | |||
2474 | pSMB->ParameterCount = pSMB->TotalParameterCount; | 2482 | pSMB->ParameterCount = pSMB->TotalParameterCount; |
2475 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_UNIX_LINK); | 2483 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_UNIX_LINK); |
2476 | pSMB->Reserved4 = 0; | 2484 | pSMB->Reserved4 = 0; |
2477 | pSMB->hdr.smb_buf_length += byte_count; | 2485 | inc_rfc1001_len(pSMB, byte_count); |
2478 | pSMB->ByteCount = cpu_to_le16(byte_count); | 2486 | pSMB->ByteCount = cpu_to_le16(byte_count); |
2479 | 2487 | ||
2480 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 2488 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -2821,7 +2829,7 @@ queryAclRetry: | |||
2821 | pSMB->ParameterCount = pSMB->TotalParameterCount; | 2829 | pSMB->ParameterCount = pSMB->TotalParameterCount; |
2822 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_POSIX_ACL); | 2830 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_POSIX_ACL); |
2823 | pSMB->Reserved4 = 0; | 2831 | pSMB->Reserved4 = 0; |
2824 | pSMB->hdr.smb_buf_length += byte_count; | 2832 | inc_rfc1001_len(pSMB, byte_count); |
2825 | pSMB->ByteCount = cpu_to_le16(byte_count); | 2833 | pSMB->ByteCount = cpu_to_le16(byte_count); |
2826 | 2834 | ||
2827 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 2835 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -2915,7 +2923,7 @@ setAclRetry: | |||
2915 | pSMB->ParameterCount = cpu_to_le16(params); | 2923 | pSMB->ParameterCount = cpu_to_le16(params); |
2916 | pSMB->TotalParameterCount = pSMB->ParameterCount; | 2924 | pSMB->TotalParameterCount = pSMB->ParameterCount; |
2917 | pSMB->Reserved4 = 0; | 2925 | pSMB->Reserved4 = 0; |
2918 | pSMB->hdr.smb_buf_length += byte_count; | 2926 | inc_rfc1001_len(pSMB, byte_count); |
2919 | pSMB->ByteCount = cpu_to_le16(byte_count); | 2927 | pSMB->ByteCount = cpu_to_le16(byte_count); |
2920 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 2928 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
2921 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | 2929 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); |
@@ -2973,7 +2981,7 @@ GetExtAttrRetry: | |||
2973 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_ATTR_FLAGS); | 2981 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_ATTR_FLAGS); |
2974 | pSMB->Pad = 0; | 2982 | pSMB->Pad = 0; |
2975 | pSMB->Fid = netfid; | 2983 | pSMB->Fid = netfid; |
2976 | pSMB->hdr.smb_buf_length += byte_count; | 2984 | inc_rfc1001_len(pSMB, byte_count); |
2977 | pSMB->t2.ByteCount = cpu_to_le16(byte_count); | 2985 | pSMB->t2.ByteCount = cpu_to_le16(byte_count); |
2978 | 2986 | ||
2979 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 2987 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -3131,9 +3139,9 @@ CIFSSMBGetCIFSACL(const int xid, struct cifsTconInfo *tcon, __u16 fid, | |||
3131 | pSMB->AclFlags = cpu_to_le32(CIFS_ACL_OWNER | CIFS_ACL_GROUP | | 3139 | pSMB->AclFlags = cpu_to_le32(CIFS_ACL_OWNER | CIFS_ACL_GROUP | |
3132 | CIFS_ACL_DACL); | 3140 | CIFS_ACL_DACL); |
3133 | pSMB->ByteCount = cpu_to_le16(11); /* 3 bytes pad + 8 bytes parm */ | 3141 | pSMB->ByteCount = cpu_to_le16(11); /* 3 bytes pad + 8 bytes parm */ |
3134 | pSMB->hdr.smb_buf_length += 11; | 3142 | inc_rfc1001_len(pSMB, 11); |
3135 | iov[0].iov_base = (char *)pSMB; | 3143 | iov[0].iov_base = (char *)pSMB; |
3136 | iov[0].iov_len = pSMB->hdr.smb_buf_length + 4; | 3144 | iov[0].iov_len = be32_to_cpu(pSMB->hdr.smb_buf_length) + 4; |
3137 | 3145 | ||
3138 | rc = SendReceive2(xid, tcon->ses, iov, 1 /* num iovec */, &buf_type, | 3146 | rc = SendReceive2(xid, tcon->ses, iov, 1 /* num iovec */, &buf_type, |
3139 | 0); | 3147 | 0); |
@@ -3242,10 +3250,9 @@ setCifsAclRetry: | |||
3242 | memcpy((char *) &pSMBr->hdr.Protocol + data_offset, | 3250 | memcpy((char *) &pSMBr->hdr.Protocol + data_offset, |
3243 | (char *) pntsd, | 3251 | (char *) pntsd, |
3244 | acllen); | 3252 | acllen); |
3245 | pSMB->hdr.smb_buf_length += (byte_count + data_count); | 3253 | inc_rfc1001_len(pSMB, byte_count + data_count); |
3246 | |||
3247 | } else | 3254 | } else |
3248 | pSMB->hdr.smb_buf_length += byte_count; | 3255 | inc_rfc1001_len(pSMB, byte_count); |
3249 | 3256 | ||
3250 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 3257 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
3251 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | 3258 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); |
@@ -3296,7 +3303,7 @@ QInfRetry: | |||
3296 | } | 3303 | } |
3297 | pSMB->BufferFormat = 0x04; | 3304 | pSMB->BufferFormat = 0x04; |
3298 | name_len++; /* account for buffer type byte */ | 3305 | name_len++; /* account for buffer type byte */ |
3299 | pSMB->hdr.smb_buf_length += (__u16) name_len; | 3306 | inc_rfc1001_len(pSMB, (__u16)name_len); |
3300 | pSMB->ByteCount = cpu_to_le16(name_len); | 3307 | pSMB->ByteCount = cpu_to_le16(name_len); |
3301 | 3308 | ||
3302 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 3309 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -3371,7 +3378,7 @@ QFileInfoRetry: | |||
3371 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO); | 3378 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO); |
3372 | pSMB->Pad = 0; | 3379 | pSMB->Pad = 0; |
3373 | pSMB->Fid = netfid; | 3380 | pSMB->Fid = netfid; |
3374 | pSMB->hdr.smb_buf_length += byte_count; | 3381 | inc_rfc1001_len(pSMB, byte_count); |
3375 | 3382 | ||
3376 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 3383 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
3377 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | 3384 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); |
@@ -3458,7 +3465,7 @@ QPathInfoRetry: | |||
3458 | else | 3465 | else |
3459 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO); | 3466 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO); |
3460 | pSMB->Reserved4 = 0; | 3467 | pSMB->Reserved4 = 0; |
3461 | pSMB->hdr.smb_buf_length += byte_count; | 3468 | inc_rfc1001_len(pSMB, byte_count); |
3462 | pSMB->ByteCount = cpu_to_le16(byte_count); | 3469 | pSMB->ByteCount = cpu_to_le16(byte_count); |
3463 | 3470 | ||
3464 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 3471 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -3539,7 +3546,7 @@ UnixQFileInfoRetry: | |||
3539 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC); | 3546 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC); |
3540 | pSMB->Pad = 0; | 3547 | pSMB->Pad = 0; |
3541 | pSMB->Fid = netfid; | 3548 | pSMB->Fid = netfid; |
3542 | pSMB->hdr.smb_buf_length += byte_count; | 3549 | inc_rfc1001_len(pSMB, byte_count); |
3543 | 3550 | ||
3544 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 3551 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
3545 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | 3552 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); |
@@ -3624,7 +3631,7 @@ UnixQPathInfoRetry: | |||
3624 | pSMB->ParameterCount = pSMB->TotalParameterCount; | 3631 | pSMB->ParameterCount = pSMB->TotalParameterCount; |
3625 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC); | 3632 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_UNIX_BASIC); |
3626 | pSMB->Reserved4 = 0; | 3633 | pSMB->Reserved4 = 0; |
3627 | pSMB->hdr.smb_buf_length += byte_count; | 3634 | inc_rfc1001_len(pSMB, byte_count); |
3628 | pSMB->ByteCount = cpu_to_le16(byte_count); | 3635 | pSMB->ByteCount = cpu_to_le16(byte_count); |
3629 | 3636 | ||
3630 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 3637 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -3738,7 +3745,7 @@ findFirstRetry: | |||
3738 | 3745 | ||
3739 | /* BB what should we set StorageType to? Does it matter? BB */ | 3746 | /* BB what should we set StorageType to? Does it matter? BB */ |
3740 | pSMB->SearchStorageType = 0; | 3747 | pSMB->SearchStorageType = 0; |
3741 | pSMB->hdr.smb_buf_length += byte_count; | 3748 | inc_rfc1001_len(pSMB, byte_count); |
3742 | pSMB->ByteCount = cpu_to_le16(byte_count); | 3749 | pSMB->ByteCount = cpu_to_le16(byte_count); |
3743 | 3750 | ||
3744 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 3751 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -3867,7 +3874,7 @@ int CIFSFindNext(const int xid, struct cifsTconInfo *tcon, | |||
3867 | byte_count = params + 1 /* pad */ ; | 3874 | byte_count = params + 1 /* pad */ ; |
3868 | pSMB->TotalParameterCount = cpu_to_le16(params); | 3875 | pSMB->TotalParameterCount = cpu_to_le16(params); |
3869 | pSMB->ParameterCount = pSMB->TotalParameterCount; | 3876 | pSMB->ParameterCount = pSMB->TotalParameterCount; |
3870 | pSMB->hdr.smb_buf_length += byte_count; | 3877 | inc_rfc1001_len(pSMB, byte_count); |
3871 | pSMB->ByteCount = cpu_to_le16(byte_count); | 3878 | pSMB->ByteCount = cpu_to_le16(byte_count); |
3872 | 3879 | ||
3873 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 3880 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -4029,7 +4036,7 @@ GetInodeNumberRetry: | |||
4029 | pSMB->ParameterCount = pSMB->TotalParameterCount; | 4036 | pSMB->ParameterCount = pSMB->TotalParameterCount; |
4030 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_INTERNAL_INFO); | 4037 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_INTERNAL_INFO); |
4031 | pSMB->Reserved4 = 0; | 4038 | pSMB->Reserved4 = 0; |
4032 | pSMB->hdr.smb_buf_length += byte_count; | 4039 | inc_rfc1001_len(pSMB, byte_count); |
4033 | pSMB->ByteCount = cpu_to_le16(byte_count); | 4040 | pSMB->ByteCount = cpu_to_le16(byte_count); |
4034 | 4041 | ||
4035 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 4042 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -4253,7 +4260,7 @@ getDFSRetry: | |||
4253 | pSMB->ParameterCount = cpu_to_le16(params); | 4260 | pSMB->ParameterCount = cpu_to_le16(params); |
4254 | pSMB->TotalParameterCount = pSMB->ParameterCount; | 4261 | pSMB->TotalParameterCount = pSMB->ParameterCount; |
4255 | pSMB->MaxReferralLevel = cpu_to_le16(3); | 4262 | pSMB->MaxReferralLevel = cpu_to_le16(3); |
4256 | pSMB->hdr.smb_buf_length += byte_count; | 4263 | inc_rfc1001_len(pSMB, byte_count); |
4257 | pSMB->ByteCount = cpu_to_le16(byte_count); | 4264 | pSMB->ByteCount = cpu_to_le16(byte_count); |
4258 | 4265 | ||
4259 | rc = SendReceive(xid, ses, (struct smb_hdr *) pSMB, | 4266 | rc = SendReceive(xid, ses, (struct smb_hdr *) pSMB, |
@@ -4327,7 +4334,7 @@ oldQFSInfoRetry: | |||
4327 | pSMB->Reserved3 = 0; | 4334 | pSMB->Reserved3 = 0; |
4328 | pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); | 4335 | pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); |
4329 | pSMB->InformationLevel = cpu_to_le16(SMB_INFO_ALLOCATION); | 4336 | pSMB->InformationLevel = cpu_to_le16(SMB_INFO_ALLOCATION); |
4330 | pSMB->hdr.smb_buf_length += byte_count; | 4337 | inc_rfc1001_len(pSMB, byte_count); |
4331 | pSMB->ByteCount = cpu_to_le16(byte_count); | 4338 | pSMB->ByteCount = cpu_to_le16(byte_count); |
4332 | 4339 | ||
4333 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 4340 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -4406,7 +4413,7 @@ QFSInfoRetry: | |||
4406 | pSMB->Reserved3 = 0; | 4413 | pSMB->Reserved3 = 0; |
4407 | pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); | 4414 | pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); |
4408 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FS_SIZE_INFO); | 4415 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FS_SIZE_INFO); |
4409 | pSMB->hdr.smb_buf_length += byte_count; | 4416 | inc_rfc1001_len(pSMB, byte_count); |
4410 | pSMB->ByteCount = cpu_to_le16(byte_count); | 4417 | pSMB->ByteCount = cpu_to_le16(byte_count); |
4411 | 4418 | ||
4412 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 4419 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -4486,7 +4493,7 @@ QFSAttributeRetry: | |||
4486 | pSMB->Reserved3 = 0; | 4493 | pSMB->Reserved3 = 0; |
4487 | pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); | 4494 | pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); |
4488 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FS_ATTRIBUTE_INFO); | 4495 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FS_ATTRIBUTE_INFO); |
4489 | pSMB->hdr.smb_buf_length += byte_count; | 4496 | inc_rfc1001_len(pSMB, byte_count); |
4490 | pSMB->ByteCount = cpu_to_le16(byte_count); | 4497 | pSMB->ByteCount = cpu_to_le16(byte_count); |
4491 | 4498 | ||
4492 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 4499 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -4557,7 +4564,7 @@ QFSDeviceRetry: | |||
4557 | pSMB->Reserved3 = 0; | 4564 | pSMB->Reserved3 = 0; |
4558 | pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); | 4565 | pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); |
4559 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FS_DEVICE_INFO); | 4566 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FS_DEVICE_INFO); |
4560 | pSMB->hdr.smb_buf_length += byte_count; | 4567 | inc_rfc1001_len(pSMB, byte_count); |
4561 | pSMB->ByteCount = cpu_to_le16(byte_count); | 4568 | pSMB->ByteCount = cpu_to_le16(byte_count); |
4562 | 4569 | ||
4563 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 4570 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -4626,7 +4633,7 @@ QFSUnixRetry: | |||
4626 | pSMB->Reserved3 = 0; | 4633 | pSMB->Reserved3 = 0; |
4627 | pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); | 4634 | pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); |
4628 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_CIFS_UNIX_INFO); | 4635 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_CIFS_UNIX_INFO); |
4629 | pSMB->hdr.smb_buf_length += byte_count; | 4636 | inc_rfc1001_len(pSMB, byte_count); |
4630 | pSMB->ByteCount = cpu_to_le16(byte_count); | 4637 | pSMB->ByteCount = cpu_to_le16(byte_count); |
4631 | 4638 | ||
4632 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 4639 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -4709,7 +4716,7 @@ SETFSUnixRetry: | |||
4709 | pSMB->ClientUnixMinor = cpu_to_le16(CIFS_UNIX_MINOR_VERSION); | 4716 | pSMB->ClientUnixMinor = cpu_to_le16(CIFS_UNIX_MINOR_VERSION); |
4710 | pSMB->ClientUnixCap = cpu_to_le64(cap); | 4717 | pSMB->ClientUnixCap = cpu_to_le64(cap); |
4711 | 4718 | ||
4712 | pSMB->hdr.smb_buf_length += byte_count; | 4719 | inc_rfc1001_len(pSMB, byte_count); |
4713 | pSMB->ByteCount = cpu_to_le16(byte_count); | 4720 | pSMB->ByteCount = cpu_to_le16(byte_count); |
4714 | 4721 | ||
4715 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 4722 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -4771,7 +4778,7 @@ QFSPosixRetry: | |||
4771 | pSMB->Reserved3 = 0; | 4778 | pSMB->Reserved3 = 0; |
4772 | pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); | 4779 | pSMB->SubCommand = cpu_to_le16(TRANS2_QUERY_FS_INFORMATION); |
4773 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_POSIX_FS_INFO); | 4780 | pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_POSIX_FS_INFO); |
4774 | pSMB->hdr.smb_buf_length += byte_count; | 4781 | inc_rfc1001_len(pSMB, byte_count); |
4775 | pSMB->ByteCount = cpu_to_le16(byte_count); | 4782 | pSMB->ByteCount = cpu_to_le16(byte_count); |
4776 | 4783 | ||
4777 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 4784 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -4897,7 +4904,7 @@ SetEOFRetry: | |||
4897 | pSMB->ParameterCount = cpu_to_le16(params); | 4904 | pSMB->ParameterCount = cpu_to_le16(params); |
4898 | pSMB->TotalParameterCount = pSMB->ParameterCount; | 4905 | pSMB->TotalParameterCount = pSMB->ParameterCount; |
4899 | pSMB->Reserved4 = 0; | 4906 | pSMB->Reserved4 = 0; |
4900 | pSMB->hdr.smb_buf_length += byte_count; | 4907 | inc_rfc1001_len(pSMB, byte_count); |
4901 | parm_data->FileSize = cpu_to_le64(size); | 4908 | parm_data->FileSize = cpu_to_le64(size); |
4902 | pSMB->ByteCount = cpu_to_le16(byte_count); | 4909 | pSMB->ByteCount = cpu_to_le16(byte_count); |
4903 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 4910 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -4976,7 +4983,7 @@ CIFSSMBSetFileSize(const int xid, struct cifsTconInfo *tcon, __u64 size, | |||
4976 | cpu_to_le16(SMB_SET_FILE_END_OF_FILE_INFO); | 4983 | cpu_to_le16(SMB_SET_FILE_END_OF_FILE_INFO); |
4977 | } | 4984 | } |
4978 | pSMB->Reserved4 = 0; | 4985 | pSMB->Reserved4 = 0; |
4979 | pSMB->hdr.smb_buf_length += byte_count; | 4986 | inc_rfc1001_len(pSMB, byte_count); |
4980 | pSMB->ByteCount = cpu_to_le16(byte_count); | 4987 | pSMB->ByteCount = cpu_to_le16(byte_count); |
4981 | rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); | 4988 | rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); |
4982 | if (rc) { | 4989 | if (rc) { |
@@ -5044,7 +5051,7 @@ CIFSSMBSetFileInfo(const int xid, struct cifsTconInfo *tcon, | |||
5044 | else | 5051 | else |
5045 | pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_BASIC_INFO); | 5052 | pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_BASIC_INFO); |
5046 | pSMB->Reserved4 = 0; | 5053 | pSMB->Reserved4 = 0; |
5047 | pSMB->hdr.smb_buf_length += byte_count; | 5054 | inc_rfc1001_len(pSMB, byte_count); |
5048 | pSMB->ByteCount = cpu_to_le16(byte_count); | 5055 | pSMB->ByteCount = cpu_to_le16(byte_count); |
5049 | memcpy(data_offset, data, sizeof(FILE_BASIC_INFO)); | 5056 | memcpy(data_offset, data, sizeof(FILE_BASIC_INFO)); |
5050 | rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); | 5057 | rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); |
@@ -5103,7 +5110,7 @@ CIFSSMBSetFileDisposition(const int xid, struct cifsTconInfo *tcon, | |||
5103 | pSMB->Fid = fid; | 5110 | pSMB->Fid = fid; |
5104 | pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_DISPOSITION_INFO); | 5111 | pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_DISPOSITION_INFO); |
5105 | pSMB->Reserved4 = 0; | 5112 | pSMB->Reserved4 = 0; |
5106 | pSMB->hdr.smb_buf_length += byte_count; | 5113 | inc_rfc1001_len(pSMB, byte_count); |
5107 | pSMB->ByteCount = cpu_to_le16(byte_count); | 5114 | pSMB->ByteCount = cpu_to_le16(byte_count); |
5108 | *data_offset = delete_file ? 1 : 0; | 5115 | *data_offset = delete_file ? 1 : 0; |
5109 | rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); | 5116 | rc = SendReceiveNoRsp(xid, tcon->ses, (struct smb_hdr *) pSMB, 0); |
@@ -5176,7 +5183,7 @@ SetTimesRetry: | |||
5176 | else | 5183 | else |
5177 | pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_BASIC_INFO); | 5184 | pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_BASIC_INFO); |
5178 | pSMB->Reserved4 = 0; | 5185 | pSMB->Reserved4 = 0; |
5179 | pSMB->hdr.smb_buf_length += byte_count; | 5186 | inc_rfc1001_len(pSMB, byte_count); |
5180 | memcpy(data_offset, data, sizeof(FILE_BASIC_INFO)); | 5187 | memcpy(data_offset, data, sizeof(FILE_BASIC_INFO)); |
5181 | pSMB->ByteCount = cpu_to_le16(byte_count); | 5188 | pSMB->ByteCount = cpu_to_le16(byte_count); |
5182 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 5189 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -5228,7 +5235,7 @@ SetAttrLgcyRetry: | |||
5228 | } | 5235 | } |
5229 | pSMB->attr = cpu_to_le16(dos_attrs); | 5236 | pSMB->attr = cpu_to_le16(dos_attrs); |
5230 | pSMB->BufferFormat = 0x04; | 5237 | pSMB->BufferFormat = 0x04; |
5231 | pSMB->hdr.smb_buf_length += name_len + 1; | 5238 | inc_rfc1001_len(pSMB, name_len + 1); |
5232 | pSMB->ByteCount = cpu_to_le16(name_len + 1); | 5239 | pSMB->ByteCount = cpu_to_le16(name_len + 1); |
5233 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 5240 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
5234 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | 5241 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); |
@@ -5333,7 +5340,7 @@ CIFSSMBUnixSetFileInfo(const int xid, struct cifsTconInfo *tcon, | |||
5333 | pSMB->Fid = fid; | 5340 | pSMB->Fid = fid; |
5334 | pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_UNIX_BASIC); | 5341 | pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_UNIX_BASIC); |
5335 | pSMB->Reserved4 = 0; | 5342 | pSMB->Reserved4 = 0; |
5336 | pSMB->hdr.smb_buf_length += byte_count; | 5343 | inc_rfc1001_len(pSMB, byte_count); |
5337 | pSMB->ByteCount = cpu_to_le16(byte_count); | 5344 | pSMB->ByteCount = cpu_to_le16(byte_count); |
5338 | 5345 | ||
5339 | cifs_fill_unix_set_info(data_offset, args); | 5346 | cifs_fill_unix_set_info(data_offset, args); |
@@ -5409,7 +5416,7 @@ setPermsRetry: | |||
5409 | pSMB->TotalDataCount = pSMB->DataCount; | 5416 | pSMB->TotalDataCount = pSMB->DataCount; |
5410 | pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_UNIX_BASIC); | 5417 | pSMB->InformationLevel = cpu_to_le16(SMB_SET_FILE_UNIX_BASIC); |
5411 | pSMB->Reserved4 = 0; | 5418 | pSMB->Reserved4 = 0; |
5412 | pSMB->hdr.smb_buf_length += byte_count; | 5419 | inc_rfc1001_len(pSMB, byte_count); |
5413 | 5420 | ||
5414 | cifs_fill_unix_set_info(data_offset, args); | 5421 | cifs_fill_unix_set_info(data_offset, args); |
5415 | 5422 | ||
@@ -5494,7 +5501,7 @@ QAllEAsRetry: | |||
5494 | pSMB->ParameterCount = pSMB->TotalParameterCount; | 5501 | pSMB->ParameterCount = pSMB->TotalParameterCount; |
5495 | pSMB->InformationLevel = cpu_to_le16(SMB_INFO_QUERY_ALL_EAS); | 5502 | pSMB->InformationLevel = cpu_to_le16(SMB_INFO_QUERY_ALL_EAS); |
5496 | pSMB->Reserved4 = 0; | 5503 | pSMB->Reserved4 = 0; |
5497 | pSMB->hdr.smb_buf_length += byte_count; | 5504 | inc_rfc1001_len(pSMB, byte_count); |
5498 | pSMB->ByteCount = cpu_to_le16(byte_count); | 5505 | pSMB->ByteCount = cpu_to_le16(byte_count); |
5499 | 5506 | ||
5500 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 5507 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
@@ -5707,7 +5714,7 @@ SetEARetry: | |||
5707 | pSMB->ParameterCount = cpu_to_le16(params); | 5714 | pSMB->ParameterCount = cpu_to_le16(params); |
5708 | pSMB->TotalParameterCount = pSMB->ParameterCount; | 5715 | pSMB->TotalParameterCount = pSMB->ParameterCount; |
5709 | pSMB->Reserved4 = 0; | 5716 | pSMB->Reserved4 = 0; |
5710 | pSMB->hdr.smb_buf_length += byte_count; | 5717 | inc_rfc1001_len(pSMB, byte_count); |
5711 | pSMB->ByteCount = cpu_to_le16(byte_count); | 5718 | pSMB->ByteCount = cpu_to_le16(byte_count); |
5712 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, | 5719 | rc = SendReceive(xid, tcon->ses, (struct smb_hdr *) pSMB, |
5713 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); | 5720 | (struct smb_hdr *) pSMBr, &bytes_returned, 0); |
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index acd1e3c887e1..5d331cdd0b27 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c | |||
@@ -324,12 +324,12 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB) | |||
324 | return -EPROTO; | 324 | return -EPROTO; |
325 | put_bcc_le(byte_count, pTargetSMB); | 325 | put_bcc_le(byte_count, pTargetSMB); |
326 | 326 | ||
327 | byte_count = pTargetSMB->smb_buf_length; | 327 | byte_count = be32_to_cpu(pTargetSMB->smb_buf_length); |
328 | byte_count += total_in_buf2; | 328 | byte_count += total_in_buf2; |
329 | /* don't allow buffer to overflow */ | 329 | /* don't allow buffer to overflow */ |
330 | if (byte_count > CIFSMaxBufSize) | 330 | if (byte_count > CIFSMaxBufSize) |
331 | return -ENOBUFS; | 331 | return -ENOBUFS; |
332 | pTargetSMB->smb_buf_length = byte_count; | 332 | pTargetSMB->smb_buf_length = cpu_to_be32(byte_count); |
333 | 333 | ||
334 | memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2); | 334 | memcpy(data_area_of_target, data_area_of_buf2, total_in_buf2); |
335 | 335 | ||
@@ -496,8 +496,7 @@ incomplete_rcv: | |||
496 | /* Note that FC 1001 length is big endian on the wire, | 496 | /* Note that FC 1001 length is big endian on the wire, |
497 | but we convert it here so it is always manipulated | 497 | but we convert it here so it is always manipulated |
498 | as host byte order */ | 498 | as host byte order */ |
499 | pdu_length = be32_to_cpu((__force __be32)smb_buffer->smb_buf_length); | 499 | pdu_length = be32_to_cpu(smb_buffer->smb_buf_length); |
500 | smb_buffer->smb_buf_length = pdu_length; | ||
501 | 500 | ||
502 | cFYI(1, "rfc1002 length 0x%x", pdu_length+4); | 501 | cFYI(1, "rfc1002 length 0x%x", pdu_length+4); |
503 | 502 | ||
@@ -2297,7 +2296,7 @@ ip_rfc1001_connect(struct TCP_Server_Info *server) | |||
2297 | smb_buf = (struct smb_hdr *)ses_init_buf; | 2296 | smb_buf = (struct smb_hdr *)ses_init_buf; |
2298 | 2297 | ||
2299 | /* sizeof RFC1002_SESSION_REQUEST with no scope */ | 2298 | /* sizeof RFC1002_SESSION_REQUEST with no scope */ |
2300 | smb_buf->smb_buf_length = 0x81000044; | 2299 | smb_buf->smb_buf_length = cpu_to_be32(0x81000044); |
2301 | rc = smb_send(server, smb_buf, 0x44); | 2300 | rc = smb_send(server, smb_buf, 0x44); |
2302 | kfree(ses_init_buf); | 2301 | kfree(ses_init_buf); |
2303 | /* | 2302 | /* |
@@ -3100,7 +3099,8 @@ CIFSTCon(unsigned int xid, struct cifsSesInfo *ses, | |||
3100 | bcc_ptr += strlen("?????"); | 3099 | bcc_ptr += strlen("?????"); |
3101 | bcc_ptr += 1; | 3100 | bcc_ptr += 1; |
3102 | count = bcc_ptr - &pSMB->Password[0]; | 3101 | count = bcc_ptr - &pSMB->Password[0]; |
3103 | pSMB->hdr.smb_buf_length += count; | 3102 | pSMB->hdr.smb_buf_length = cpu_to_be32(be32_to_cpu( |
3103 | pSMB->hdr.smb_buf_length) + count); | ||
3104 | pSMB->ByteCount = cpu_to_le16(count); | 3104 | pSMB->ByteCount = cpu_to_le16(count); |
3105 | 3105 | ||
3106 | rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, &length, | 3106 | rc = SendReceive(xid, ses, smb_buffer, smb_buffer_response, &length, |
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index 0c684ae4c071..533f863067e5 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c | |||
@@ -304,12 +304,10 @@ header_assemble(struct smb_hdr *buffer, char smb_command /* command */ , | |||
304 | 304 | ||
305 | memset(temp, 0, 256); /* bigger than MAX_CIFS_HDR_SIZE */ | 305 | memset(temp, 0, 256); /* bigger than MAX_CIFS_HDR_SIZE */ |
306 | 306 | ||
307 | buffer->smb_buf_length = | 307 | buffer->smb_buf_length = cpu_to_be32( |
308 | (2 * word_count) + sizeof(struct smb_hdr) - | 308 | (2 * word_count) + sizeof(struct smb_hdr) - |
309 | 4 /* RFC 1001 length field does not count */ + | 309 | 4 /* RFC 1001 length field does not count */ + |
310 | 2 /* for bcc field itself */ ; | 310 | 2 /* for bcc field itself */) ; |
311 | /* Note that this is the only network field that has to be converted | ||
312 | to big endian and it is done just before we send it */ | ||
313 | 311 | ||
314 | buffer->Protocol[0] = 0xFF; | 312 | buffer->Protocol[0] = 0xFF; |
315 | buffer->Protocol[1] = 'S'; | 313 | buffer->Protocol[1] = 'S'; |
@@ -424,7 +422,7 @@ check_smb_hdr(struct smb_hdr *smb, __u16 mid) | |||
424 | int | 422 | int |
425 | checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length) | 423 | checkSMB(struct smb_hdr *smb, __u16 mid, unsigned int length) |
426 | { | 424 | { |
427 | __u32 len = smb->smb_buf_length; | 425 | __u32 len = be32_to_cpu(smb->smb_buf_length); |
428 | __u32 clc_len; /* calculated length */ | 426 | __u32 clc_len; /* calculated length */ |
429 | cFYI(0, "checkSMB Length: 0x%x, smb_buf_length: 0x%x", length, len); | 427 | cFYI(0, "checkSMB Length: 0x%x, smb_buf_length: 0x%x", length, len); |
430 | 428 | ||
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index b6ff84af81a4..1daadade4d3c 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c | |||
@@ -621,7 +621,7 @@ ssetup_ntlmssp_authenticate: | |||
621 | and rest of bcc area. This allows us to avoid | 621 | and rest of bcc area. This allows us to avoid |
622 | a large buffer 17K allocation */ | 622 | a large buffer 17K allocation */ |
623 | iov[0].iov_base = (char *)pSMB; | 623 | iov[0].iov_base = (char *)pSMB; |
624 | iov[0].iov_len = smb_buf->smb_buf_length + 4; | 624 | iov[0].iov_len = be32_to_cpu(smb_buf->smb_buf_length) + 4; |
625 | 625 | ||
626 | /* setting this here allows the code at the end of the function | 626 | /* setting this here allows the code at the end of the function |
627 | to free the request buffer if there's an error */ | 627 | to free the request buffer if there's an error */ |
@@ -859,7 +859,8 @@ ssetup_ntlmssp_authenticate: | |||
859 | iov[2].iov_len = (long) bcc_ptr - (long) str_area; | 859 | iov[2].iov_len = (long) bcc_ptr - (long) str_area; |
860 | 860 | ||
861 | count = iov[1].iov_len + iov[2].iov_len; | 861 | count = iov[1].iov_len + iov[2].iov_len; |
862 | smb_buf->smb_buf_length += count; | 862 | smb_buf->smb_buf_length = |
863 | cpu_to_be32(be32_to_cpu(smb_buf->smb_buf_length) + count); | ||
863 | 864 | ||
864 | put_bcc_le(count, smb_buf); | 865 | put_bcc_le(count, smb_buf); |
865 | 866 | ||
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 46d8756f2b24..19df0e5af122 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c | |||
@@ -129,7 +129,7 @@ smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec) | |||
129 | unsigned int len = iov[0].iov_len; | 129 | unsigned int len = iov[0].iov_len; |
130 | unsigned int total_len; | 130 | unsigned int total_len; |
131 | int first_vec = 0; | 131 | int first_vec = 0; |
132 | unsigned int smb_buf_length = smb_buffer->smb_buf_length; | 132 | unsigned int smb_buf_length = be32_to_cpu(smb_buffer->smb_buf_length); |
133 | struct socket *ssocket = server->ssocket; | 133 | struct socket *ssocket = server->ssocket; |
134 | 134 | ||
135 | if (ssocket == NULL) | 135 | if (ssocket == NULL) |
@@ -144,17 +144,10 @@ smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec) | |||
144 | else | 144 | else |
145 | smb_msg.msg_flags = MSG_NOSIGNAL; | 145 | smb_msg.msg_flags = MSG_NOSIGNAL; |
146 | 146 | ||
147 | /* smb header is converted in header_assemble. bcc and rest of SMB word | ||
148 | area, and byte area if necessary, is converted to littleendian in | ||
149 | cifssmb.c and RFC1001 len is converted to bigendian in smb_send | ||
150 | Flags2 is converted in SendReceive */ | ||
151 | |||
152 | |||
153 | total_len = 0; | 147 | total_len = 0; |
154 | for (i = 0; i < n_vec; i++) | 148 | for (i = 0; i < n_vec; i++) |
155 | total_len += iov[i].iov_len; | 149 | total_len += iov[i].iov_len; |
156 | 150 | ||
157 | smb_buffer->smb_buf_length = cpu_to_be32(smb_buffer->smb_buf_length); | ||
158 | cFYI(1, "Sending smb: total_len %d", total_len); | 151 | cFYI(1, "Sending smb: total_len %d", total_len); |
159 | dump_smb(smb_buffer, len); | 152 | dump_smb(smb_buffer, len); |
160 | 153 | ||
@@ -243,7 +236,7 @@ smb_sendv(struct TCP_Server_Info *server, struct kvec *iov, int n_vec) | |||
243 | 236 | ||
244 | /* Don't want to modify the buffer as a | 237 | /* Don't want to modify the buffer as a |
245 | side effect of this call. */ | 238 | side effect of this call. */ |
246 | smb_buffer->smb_buf_length = smb_buf_length; | 239 | smb_buffer->smb_buf_length = cpu_to_be32(smb_buf_length); |
247 | 240 | ||
248 | return rc; | 241 | return rc; |
249 | } | 242 | } |
@@ -387,7 +380,7 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_hdr *in_buf, | |||
387 | #ifdef CONFIG_CIFS_STATS2 | 380 | #ifdef CONFIG_CIFS_STATS2 |
388 | atomic_inc(&server->inSend); | 381 | atomic_inc(&server->inSend); |
389 | #endif | 382 | #endif |
390 | rc = smb_send(server, in_buf, in_buf->smb_buf_length); | 383 | rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); |
391 | #ifdef CONFIG_CIFS_STATS2 | 384 | #ifdef CONFIG_CIFS_STATS2 |
392 | atomic_dec(&server->inSend); | 385 | atomic_dec(&server->inSend); |
393 | mid->when_sent = jiffies; | 386 | mid->when_sent = jiffies; |
@@ -422,7 +415,7 @@ SendReceiveNoRsp(const unsigned int xid, struct cifsSesInfo *ses, | |||
422 | int resp_buf_type; | 415 | int resp_buf_type; |
423 | 416 | ||
424 | iov[0].iov_base = (char *)in_buf; | 417 | iov[0].iov_base = (char *)in_buf; |
425 | iov[0].iov_len = in_buf->smb_buf_length + 4; | 418 | iov[0].iov_len = be32_to_cpu(in_buf->smb_buf_length) + 4; |
426 | flags |= CIFS_NO_RESP; | 419 | flags |= CIFS_NO_RESP; |
427 | rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags); | 420 | rc = SendReceive2(xid, ses, iov, 1, &resp_buf_type, flags); |
428 | cFYI(DBG2, "SendRcvNoRsp flags %d rc %d", flags, rc); | 421 | cFYI(DBG2, "SendRcvNoRsp flags %d rc %d", flags, rc); |
@@ -488,7 +481,7 @@ send_nt_cancel(struct TCP_Server_Info *server, struct smb_hdr *in_buf, | |||
488 | int rc = 0; | 481 | int rc = 0; |
489 | 482 | ||
490 | /* -4 for RFC1001 length and +2 for BCC field */ | 483 | /* -4 for RFC1001 length and +2 for BCC field */ |
491 | in_buf->smb_buf_length = sizeof(struct smb_hdr) - 4 + 2; | 484 | in_buf->smb_buf_length = cpu_to_be32(sizeof(struct smb_hdr) - 4 + 2); |
492 | in_buf->Command = SMB_COM_NT_CANCEL; | 485 | in_buf->Command = SMB_COM_NT_CANCEL; |
493 | in_buf->WordCount = 0; | 486 | in_buf->WordCount = 0; |
494 | put_bcc_le(0, in_buf); | 487 | put_bcc_le(0, in_buf); |
@@ -499,7 +492,7 @@ send_nt_cancel(struct TCP_Server_Info *server, struct smb_hdr *in_buf, | |||
499 | mutex_unlock(&server->srv_mutex); | 492 | mutex_unlock(&server->srv_mutex); |
500 | return rc; | 493 | return rc; |
501 | } | 494 | } |
502 | rc = smb_send(server, in_buf, in_buf->smb_buf_length); | 495 | rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); |
503 | mutex_unlock(&server->srv_mutex); | 496 | mutex_unlock(&server->srv_mutex); |
504 | 497 | ||
505 | cFYI(1, "issued NT_CANCEL for mid %u, rc = %d", | 498 | cFYI(1, "issued NT_CANCEL for mid %u, rc = %d", |
@@ -612,7 +605,7 @@ SendReceive2(const unsigned int xid, struct cifsSesInfo *ses, | |||
612 | return rc; | 605 | return rc; |
613 | } | 606 | } |
614 | 607 | ||
615 | receive_len = midQ->resp_buf->smb_buf_length; | 608 | receive_len = be32_to_cpu(midQ->resp_buf->smb_buf_length); |
616 | 609 | ||
617 | if (receive_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) { | 610 | if (receive_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) { |
618 | cERROR(1, "Frame too large received. Length: %d Xid: %d", | 611 | cERROR(1, "Frame too large received. Length: %d Xid: %d", |
@@ -698,9 +691,10 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses, | |||
698 | to the same server. We may make this configurable later or | 691 | to the same server. We may make this configurable later or |
699 | use ses->maxReq */ | 692 | use ses->maxReq */ |
700 | 693 | ||
701 | if (in_buf->smb_buf_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { | 694 | if (be32_to_cpu(in_buf->smb_buf_length) > CIFSMaxBufSize + |
695 | MAX_CIFS_HDR_SIZE - 4) { | ||
702 | cERROR(1, "Illegal length, greater than maximum frame, %d", | 696 | cERROR(1, "Illegal length, greater than maximum frame, %d", |
703 | in_buf->smb_buf_length); | 697 | be32_to_cpu(in_buf->smb_buf_length)); |
704 | return -EIO; | 698 | return -EIO; |
705 | } | 699 | } |
706 | 700 | ||
@@ -733,7 +727,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses, | |||
733 | #ifdef CONFIG_CIFS_STATS2 | 727 | #ifdef CONFIG_CIFS_STATS2 |
734 | atomic_inc(&ses->server->inSend); | 728 | atomic_inc(&ses->server->inSend); |
735 | #endif | 729 | #endif |
736 | rc = smb_send(ses->server, in_buf, in_buf->smb_buf_length); | 730 | rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); |
737 | #ifdef CONFIG_CIFS_STATS2 | 731 | #ifdef CONFIG_CIFS_STATS2 |
738 | atomic_dec(&ses->server->inSend); | 732 | atomic_dec(&ses->server->inSend); |
739 | midQ->when_sent = jiffies; | 733 | midQ->when_sent = jiffies; |
@@ -768,7 +762,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses, | |||
768 | return rc; | 762 | return rc; |
769 | } | 763 | } |
770 | 764 | ||
771 | receive_len = midQ->resp_buf->smb_buf_length; | 765 | receive_len = be32_to_cpu(midQ->resp_buf->smb_buf_length); |
772 | 766 | ||
773 | if (receive_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) { | 767 | if (receive_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) { |
774 | cERROR(1, "Frame too large received. Length: %d Xid: %d", | 768 | cERROR(1, "Frame too large received. Length: %d Xid: %d", |
@@ -781,7 +775,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses, | |||
781 | 775 | ||
782 | if (midQ->resp_buf && out_buf | 776 | if (midQ->resp_buf && out_buf |
783 | && (midQ->midState == MID_RESPONSE_RECEIVED)) { | 777 | && (midQ->midState == MID_RESPONSE_RECEIVED)) { |
784 | out_buf->smb_buf_length = receive_len; | 778 | out_buf->smb_buf_length = cpu_to_be32(receive_len); |
785 | memcpy((char *)out_buf + 4, | 779 | memcpy((char *)out_buf + 4, |
786 | (char *)midQ->resp_buf + 4, | 780 | (char *)midQ->resp_buf + 4, |
787 | receive_len); | 781 | receive_len); |
@@ -800,7 +794,7 @@ SendReceive(const unsigned int xid, struct cifsSesInfo *ses, | |||
800 | } | 794 | } |
801 | } | 795 | } |
802 | 796 | ||
803 | *pbytes_returned = out_buf->smb_buf_length; | 797 | *pbytes_returned = be32_to_cpu(out_buf->smb_buf_length); |
804 | 798 | ||
805 | /* BB special case reconnect tid and uid here? */ | 799 | /* BB special case reconnect tid and uid here? */ |
806 | rc = map_smb_to_linux_error(out_buf, 0 /* no log */ ); | 800 | rc = map_smb_to_linux_error(out_buf, 0 /* no log */ ); |
@@ -877,9 +871,10 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon, | |||
877 | to the same server. We may make this configurable later or | 871 | to the same server. We may make this configurable later or |
878 | use ses->maxReq */ | 872 | use ses->maxReq */ |
879 | 873 | ||
880 | if (in_buf->smb_buf_length > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) { | 874 | if (be32_to_cpu(in_buf->smb_buf_length) > CIFSMaxBufSize + |
875 | MAX_CIFS_HDR_SIZE - 4) { | ||
881 | cERROR(1, "Illegal length, greater than maximum frame, %d", | 876 | cERROR(1, "Illegal length, greater than maximum frame, %d", |
882 | in_buf->smb_buf_length); | 877 | be32_to_cpu(in_buf->smb_buf_length)); |
883 | return -EIO; | 878 | return -EIO; |
884 | } | 879 | } |
885 | 880 | ||
@@ -910,7 +905,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon, | |||
910 | #ifdef CONFIG_CIFS_STATS2 | 905 | #ifdef CONFIG_CIFS_STATS2 |
911 | atomic_inc(&ses->server->inSend); | 906 | atomic_inc(&ses->server->inSend); |
912 | #endif | 907 | #endif |
913 | rc = smb_send(ses->server, in_buf, in_buf->smb_buf_length); | 908 | rc = smb_send(ses->server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); |
914 | #ifdef CONFIG_CIFS_STATS2 | 909 | #ifdef CONFIG_CIFS_STATS2 |
915 | atomic_dec(&ses->server->inSend); | 910 | atomic_dec(&ses->server->inSend); |
916 | midQ->when_sent = jiffies; | 911 | midQ->when_sent = jiffies; |
@@ -977,7 +972,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon, | |||
977 | if (rc != 0) | 972 | if (rc != 0) |
978 | return rc; | 973 | return rc; |
979 | 974 | ||
980 | receive_len = midQ->resp_buf->smb_buf_length; | 975 | receive_len = be32_to_cpu(midQ->resp_buf->smb_buf_length); |
981 | if (receive_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) { | 976 | if (receive_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) { |
982 | cERROR(1, "Frame too large received. Length: %d Xid: %d", | 977 | cERROR(1, "Frame too large received. Length: %d Xid: %d", |
983 | receive_len, xid); | 978 | receive_len, xid); |
@@ -993,7 +988,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon, | |||
993 | goto out; | 988 | goto out; |
994 | } | 989 | } |
995 | 990 | ||
996 | out_buf->smb_buf_length = receive_len; | 991 | out_buf->smb_buf_length = cpu_to_be32(receive_len); |
997 | memcpy((char *)out_buf + 4, | 992 | memcpy((char *)out_buf + 4, |
998 | (char *)midQ->resp_buf + 4, | 993 | (char *)midQ->resp_buf + 4, |
999 | receive_len); | 994 | receive_len); |
@@ -1012,7 +1007,7 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifsTconInfo *tcon, | |||
1012 | } | 1007 | } |
1013 | } | 1008 | } |
1014 | 1009 | ||
1015 | *pbytes_returned = out_buf->smb_buf_length; | 1010 | *pbytes_returned = be32_to_cpu(out_buf->smb_buf_length); |
1016 | 1011 | ||
1017 | /* BB special case reconnect tid and uid here? */ | 1012 | /* BB special case reconnect tid and uid here? */ |
1018 | rc = map_smb_to_linux_error(out_buf, 0 /* no log */ ); | 1013 | rc = map_smb_to_linux_error(out_buf, 0 /* no log */ ); |