smb/client: fix byte order issues on big-endian systems
Subsystems (2)
cover smb/client: fix byte order issues on big-endian systems
From: ZhangGuoDong <[email protected]>
ZhangGuoDong (2):
smb/client: fix little-endian values in diagnostic messages smb/client: fix file name conversion on big-endian systems
fs/smb/client/cifs_unicode.c | 6 +++--- fs/smb/client/cifsacl.c | 3 ++- fs/smb/client/sess.c | 2 +- fs/smb/client/smb1debug.c | 5 +++-- fs/smb/client/smb1misc.c | 4 ++-- fs/smb/client/smb2ops.c | 5 +++-- fs/smb/client/smb2pdu.c | 4 ++-- fs/smb/client/smb2transport.c | 6 +++--- fs/smb/client/transport.c | 2 +- 9 files changed, 20 insertions(+), 17 deletions(-)
Signature · 1 line
2.55.0
PATCH 1/2 smb/client: fix little-endian values in diagnostic messages
From: ZhangGuoDong <[email protected]>
Convert to CPU byte order to avoid incorrect debug log on big-endian architectures.
Signed-off-by ZhangGuoDong <[email protected]>
Reviewed-by ChenXiaoSong <[email protected]>
--- fs/smb/client/cifsacl.c | 3 ++- fs/smb/client/sess.c | 2 +- fs/smb/client/smb1debug.c | 5 +++-- fs/smb/client/smb1misc.c | 4 ++-- fs/smb/client/smb2ops.c | 5 +++-- fs/smb/client/smb2pdu.c | 4 ++-- fs/smb/client/smb2transport.c | 6 +++--- fs/smb/client/transport.c | 2 +- 8 files changed, 17 insertions(+), 14 deletions(-)
fs/smb/client/cifsacl.c +2 -1
@@ -1375,7 +1375,8 @@ static int parse_sec_desc(struct cifs_sb_info *cifs_sb, gsidoffset =le32_to_cpu (pntsd->gsidoffset); dacloffset =le32_to_cpu (pntsd->dacloffset);cifs_dbg (NOISY ,"revision %d type 0x%x ooffset 0x%x goffset 0x%x sacloffset 0x%x dacloffset 0x%x\n" , - pntsd->revision, pntsd->type, osidoffset, gsidoffset, +le16_to_cpu (pntsd->revision),le16_to_cpu (pntsd->type), + osidoffset, gsidoffset,le32_to_cpu (pntsd->sacloffset), dacloffset); fattr->cf_uid = cifs_sb->ctx->linux_uid; fattr->cf_gid = cifs_sb->ctx->linux_gid;
fs/smb/client/sess.c +1 -1
@@ -672,7 +672,7 @@ int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len, }if (pblob->MessageType != NtLmChallenge) {cifs_dbg (VFS ,"Incorrect message type %d\n" , - pblob->MessageType); +le32_to_cpu (pblob->MessageType));return -EINVAL ; }
fs/smb/client/smb1debug.c +3 -2
@@ -15,8 +15,9 @@ void cifs_dump_detail(void *buf, size_t buf_len, struct TCP_Server_Info *server)struct smb_hdr *smb = buf;cifs_dbg (VFS ,"Cmd: %d Err: 0x%x Flags: 0x%x Flgs2: 0x%x Mid: %d Pid: %d Wct: %d\n" , - smb->Command, smb->Status.CifsError, smb->Flags, - smb->Flags2, smb->Mid, smb->Pid, smb->WordCount); + smb->Command,le32_to_cpu (smb->Status.CifsError), smb->Flags, +le16_to_cpu (smb->Flags2),le16_to_cpu (smb->Mid), +le16_to_cpu (smb->Pid), smb->WordCount);if (!server->ops->check_message (buf, buf_len, server->total_read, server)) {cifs_dbg (VFS ,"smb buf %p len %u\n" , smb, server->ops->calc_smb_size (smb));
fs/smb/client/smb1misc.c +2 -2
@@ -95,14 +95,14 @@ is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv) pnotify = (struct file_notify_information *) ((char *)&pSMBr->hdr.Protocol + data_offset);cifs_dbg (FYI ,"dnotify on %s Action: 0x%x\n" , - pnotify->FileName, pnotify->Action); + pnotify->FileName,le32_to_cpu (pnotify->Action));/* cifs_dump_mem("Rcvd notify Data: ",buf, sizeof(struct smb_hdr)+60); */ return true; }if (pSMBr->hdr.Status.CifsError) {cifs_dbg (FYI ,"notify err 0x%x\n" , - pSMBr->hdr.Status.CifsError); +le32_to_cpu (pSMBr->hdr.Status.CifsError));return true; }return false;
fs/smb/client/smb2ops.c +3 -2
@@ -454,8 +454,9 @@ smb2_dump_detail(void *buf, size_t buf_len, struct TCP_Server_Info *server)struct smb2_hdr *shdr = (struct smb2_hdr *)buf;cifs_server_dbg (VFS ,"Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n" , - shdr->Command, shdr->Status, shdr->Flags, shdr->MessageId, - shdr->Id.SyncId.ProcessId); +le16_to_cpu (shdr->Command),le32_to_cpu (shdr->Status), +le32_to_cpu (shdr->Flags),le64_to_cpu (shdr->MessageId), +le32_to_cpu (shdr->Id.SyncId.ProcessId));if (!server->ops->check_message (buf, buf_len, server->total_read, server)) {cifs_server_dbg (VFS ,"smb buf %p len %u\n" , buf, server->ops->calc_smb_size (buf));
fs/smb/client/smb2pdu.c +2 -2
@@ -278,7 +278,7 @@ smb2_reconnect(__le16 smb2_command, struct cifs_tcon *tcon,if (smb2_command !=SMB2_TREE_DISCONNECT ) {spin_unlock (&tcon->tc_lock);cifs_tcon_dbg (FYI ,"can not send cmd %d while umounting\n" , - smb2_command); +le16_to_cpu (smb2_command));return -ENODEV ; } }
@@ -1294,7 +1294,7 @@ SMB2_negotiate(const unsigned int xid, goto neg_exit; } -cifs_dbg (FYI ,"mode 0x%x\n" , rsp->SecurityMode); +cifs_dbg (FYI ,"mode 0x%x\n" ,le16_to_cpu (rsp->SecurityMode));switch (dialect) {case SMB20_PROT_ID :
fs/smb/client/smb2transport.c +3 -3
@@ -380,7 +380,7 @@ generate_smb3signingkey(struct cifs_ses *ses,*/ cifs_dbg (VFS ,"Session Id %*ph\n" , (int )sizeof (ses->Suid), &ses->Suid); -cifs_dbg (VFS ,"Cipher type %d\n" , server->cipher_type); +cifs_dbg (VFS ,"Cipher type %d\n" ,le16_to_cpu (server->cipher_type));cifs_dbg (VFS ,"Session Key %*ph\n" , (int )ses->auth_key.len, ses->auth_key.response); cifs_dbg(VFS, "Signing Key %*ph\n",
@@ -570,7 +570,7 @@ smb2_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)/* Do not need to verify session setups with signature "BSRSPYL " */ if (memcmp (shdr->Signature,"BSRSPYL " ,8 ) ==0 )cifs_dbg (FYI ,"dummy signature received for smb command 0x%x\n" , - shdr->Command); +le16_to_cpu (shdr->Command));/* * Save off the original signature so we can modify the smb and check
@@ -588,7 +588,7 @@ smb2_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server)if (crypto_memneq (server_response_sig, shdr->Signature,SMB2_SIGNATURE_SIZE )) {cifs_dbg (VFS ,"sign fail cmd 0x%x message id 0x%llx\n" , - shdr->Command, shdr->MessageId); +le16_to_cpu (shdr->Command),le64_to_cpu (shdr->MessageId));return -EACCES ; }else return 0 ;
fs/smb/client/transport.c +1 -1
@@ -101,7 +101,7 @@ void __release_mid(struct TCP_Server_Info *server, struct mid_q_entry *midEntry) midEntry->when_sent, midEntry->when_received);if (cifsFYI &CIFS_TIMER ) {pr_debug ("slow rsp: cmd %d mid %llu A: 0x%lx S: 0x%lx R: 0x%lx\n" , - midEntry->command, midEntry->mid, + smb_cmd, midEntry->mid, now - midEntry->when_alloc, now - midEntry->when_sent, now - midEntry->when_received);
Signature · 1 line
2.55.0
PATCH 2/2 smb/client: fix file name conversion on big-endian systems
In reply to ZhangGuoDongFrom: ZhangGuoDong <[email protected]>
Use CPU byte order for temporary UTF-16 buffers to avoid incorrect file name conversion on big-endian architectures.
Fixes b29103076bec ("Fix to convert SURROGATE PAIR")
Signed-off-by ZhangGuoDong <[email protected]>
Reviewed-by ChenXiaoSong <[email protected]>
--- fs/smb/client/cifs_unicode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/smb/client/cifs_unicode.c +3 -3
@@ -92,7 +92,7 @@ convert_sfm_char(const __u16 src_char, char *target)/* * cifs_mapchar - convert a host-endian char to proper char in codepage * @target - where converted character should be copied -* @src_char - 2 byte host-endian source character +* @from - 2 byte host-endian source character * @cp - codepage to which character should be converted * @map_type - How should the 7 NTFS/SMB reserved characters be mapped to UCS2? *
@@ -126,7 +126,7 @@ cifs_mapchar(char *target, const __u16 *from, const struct nls_table *cp,/* convert SURROGATE_PAIR and IVS */ if (strcmp (cp->charset,"utf8" )) goto unknown; - len =utf16s_to_utf8s (from,3 ,UTF16_LITTLE_ENDIAN , target,6 ); + len =utf16s_to_utf8s (from,3 ,UTF16_HOST_ENDIAN , target,6 );if (len <=0 ) goto unknown;return len;
@@ -518,7 +518,7 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen, }else goto unknown; ret =utf8s_to_utf16s (source + i, charlen, -UTF16_LITTLE_ENDIAN , +UTF16_HOST_ENDIAN , wchar_to,6 );if (ret <0 ) goto unknown;
Signature · 1 line
2.55.0