Skip to content

Commit 5443d13

Browse files
author
Steve French
committed
various endian fixes to cifs
make modules C=2 M=fs/cifs CF=-D__CHECK_ENDIAN__ Found for example: CHECK fs/cifs/cifssmb.c fs/cifs/cifssmb.c:728:22: warning: incorrect type in assignment (different base types) fs/cifs/cifssmb.c:728:22: expected unsigned short [unsigned] [usertype] Tid fs/cifs/cifssmb.c:728:22: got restricted __le16 [usertype] <noident> fs/cifs/cifssmb.c:1883:45: warning: incorrect type in assignment (different base types) fs/cifs/cifssmb.c:1883:45: expected long long [signed] [usertype] fl_start fs/cifs/cifssmb.c:1883:45: got restricted __le64 [usertype] start fs/cifs/cifssmb.c:1884:54: warning: restricted __le64 degrades to integer fs/cifs/cifssmb.c:1885:58: warning: restricted __le64 degrades to integer fs/cifs/cifssmb.c:1886:43: warning: incorrect type in assignment (different base types) fs/cifs/cifssmb.c:1886:43: expected unsigned int [unsigned] fl_pid fs/cifs/cifssmb.c:1886:43: got restricted __le32 [usertype] pid In checking new smb2 code for missing endian conversions, I noticed some endian errors had crept in over the last few releases into the cifs code (symlink, ntlmssp, posix lock, and also a less problematic warning in fscache). A followon patch will address a few smb2 endian problems. Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Steve French <sfrench@us.ibm.com>
1 parent 6da9791 commit 5443d13

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎fs/cifs/cache.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void cifs_fscache_unregister(void)
5050
*/
5151
struct cifs_server_key {
5252
uint16_t family; /* address family */
53-
uint16_t port; /* IP port */
53+
__be16 port; /* IP port */
5454
union {
5555
struct in_addr ipv4_addr;
5656
struct in6_addr ipv6_addr;

‎fs/cifs/cifssmb.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ CIFSSMBEcho(struct TCP_Server_Info *server)
729729
return rc;
730730

731731
/* set up echo request */
732-
smb->hdr.Tid = cpu_to_le16(0xffff);
732+
smb->hdr.Tid = 0xffff;
733733
smb->hdr.WordCount = 1;
734734
put_unaligned_le16(1, &smb->EchoCount);
735735
put_bcc_le(1, &smb->hdr);
@@ -1884,10 +1884,10 @@ CIFSSMBPosixLock(const int xid, struct cifsTconInfo *tcon,
18841884
__constant_cpu_to_le16(CIFS_WRLCK))
18851885
pLockData->fl_type = F_WRLCK;
18861886

1887-
pLockData->fl_start = parm_data->start;
1888-
pLockData->fl_end = parm_data->start +
1889-
parm_data->length - 1;
1890-
pLockData->fl_pid = parm_data->pid;
1887+
pLockData->fl_start = le64_to_cpu(parm_data->start);
1888+
pLockData->fl_end = pLockData->fl_start +
1889+
le64_to_cpu(parm_data->length) - 1;
1890+
pLockData->fl_pid = le32_to_cpu(parm_data->pid);
18911891
}
18921892
}
18931893

‎fs/cifs/link.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ CIFSQueryMFSymLink(const int xid, struct cifsTconInfo *tcon,
239239
if (rc != 0)
240240
return rc;
241241

242-
if (file_info.EndOfFile != CIFS_MF_SYMLINK_FILE_SIZE) {
242+
if (file_info.EndOfFile != cpu_to_le64(CIFS_MF_SYMLINK_FILE_SIZE)) {
243243
CIFSSMBClose(xid, tcon, netfid);
244244
/* it's not a symlink */
245245
return -EINVAL;
@@ -316,7 +316,7 @@ CIFSCheckMFSymlink(struct cifs_fattr *fattr,
316316
if (rc != 0)
317317
goto out;
318318

319-
if (file_info.EndOfFile != CIFS_MF_SYMLINK_FILE_SIZE) {
319+
if (file_info.EndOfFile != cpu_to_le64(CIFS_MF_SYMLINK_FILE_SIZE)) {
320320
CIFSSMBClose(xid, pTcon, netfid);
321321
/* it's not a symlink */
322322
goto out;

‎fs/cifs/sess.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,8 @@ static int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len,
404404
/* BB spec says that if AvId field of MsvAvTimestamp is populated then
405405
we must set the MIC field of the AUTHENTICATE_MESSAGE */
406406
ses->ntlmssp->server_flags = le32_to_cpu(pblob->NegotiateFlags);
407-
tioffset = cpu_to_le16(pblob->TargetInfoArray.BufferOffset);
408-
tilen = cpu_to_le16(pblob->TargetInfoArray.Length);
407+
tioffset = le32_to_cpu(pblob->TargetInfoArray.BufferOffset);
408+
tilen = le16_to_cpu(pblob->TargetInfoArray.Length);
409409
if (tilen) {
410410
ses->auth_key.response = kmalloc(tilen, GFP_KERNEL);
411411
if (!ses->auth_key.response) {

0 commit comments

Comments
 (0)