Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: ZhangGuoDong <zhang.guodong@linux.dev>
To: linkinjeon@kernel.org, pc@manguebit.org,
	ronniesahlberg@gmail.com, sprasad@microsoft.com, tom@talpey.com,
	bharathsm@microsoft.com, metze@samba.org
Cc: linux-cifs@vger.kernel.org,
	ZhangGuoDong <zhangguodong@kylinos.cn>,
	ChenXiaoSong <chenxiaosong@kylinos.cn>
Subject: [PATCH 1/2] smb/client: fix little-endian values in diagnostic messages
Date: Tue, 24 Nov 2026 15:59:26 +0800	[thread overview]
Message-ID: <20261124075927.469470-2-zhang.guodong@linux.dev> (raw)
In-Reply-To: <20261124075927.469470-1-zhang.guodong@linux.dev>

From: ZhangGuoDong <zhangguodong@kylinos.cn>

Convert to CPU byte order to avoid incorrect debug log
on big-endian architectures.

Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 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(-)

diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
index d8f30c35cbe5..b23cb226c4d3 100644
--- a/fs/smb/client/cifsacl.c
+++ b/fs/smb/client/cifsacl.c
@@ -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;
diff --git a/fs/smb/client/sess.c b/fs/smb/client/sess.c
index fe006e9f2e10..468bdeae2de6 100644
--- a/fs/smb/client/sess.c
+++ b/fs/smb/client/sess.c
@@ -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;
 	}
 
diff --git a/fs/smb/client/smb1debug.c b/fs/smb/client/smb1debug.c
index e2d013e751e5..f4a08acd7242 100644
--- a/fs/smb/client/smb1debug.c
+++ b/fs/smb/client/smb1debug.c
@@ -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));
diff --git a/fs/smb/client/smb1misc.c b/fs/smb/client/smb1misc.c
index cdfbbff24b72..4005a97c0ac5 100644
--- a/fs/smb/client/smb1misc.c
+++ b/fs/smb/client/smb1misc.c
@@ -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;
diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c
index 298f549bd7ed..9c16839576e9 100644
--- a/fs/smb/client/smb2ops.c
+++ b/fs/smb/client/smb2ops.c
@@ -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));
diff --git a/fs/smb/client/smb2pdu.c b/fs/smb/client/smb2pdu.c
index b26bfb4bd91a..21e8a78f6104 100644
--- a/fs/smb/client/smb2pdu.c
+++ b/fs/smb/client/smb2pdu.c
@@ -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:
diff --git a/fs/smb/client/smb2transport.c b/fs/smb/client/smb2transport.c
index 080864b24a0c..51dca16463d8 100644
--- a/fs/smb/client/smb2transport.c
+++ b/fs/smb/client/smb2transport.c
@@ -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;
diff --git a/fs/smb/client/transport.c b/fs/smb/client/transport.c
index c51f99d7be4b..cbeead6e522b 100644
--- a/fs/smb/client/transport.c
+++ b/fs/smb/client/transport.c
@@ -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);
-- 
2.55.0


  reply	other threads:[~2026-11-24  7:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  7:59 [PATCH 0/2] smb/client: fix byte order issues on big-endian systems ZhangGuoDong
2026-11-24  7:59 ` ZhangGuoDong [this message]
2026-11-24  7:59 ` [PATCH 2/2] smb/client: fix file name conversion " ZhangGuoDong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124075927.469470-2-zhang.guodong@linux.dev \
    --to=zhang.guodong@linux.dev \
    --cc=bharathsm@microsoft.com \
    --cc=chenxiaosong@kylinos.cn \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=metze@samba.org \
    --cc=pc@manguebit.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=sprasad@microsoft.com \
    --cc=tom@talpey.com \
    --cc=zhangguodong@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox