All of lore.kernel.org
 help / color / mirror / Atom feed
From: ZhangGuoDong <zhang.guodong@linux.dev>
To: linkinjeon@kernel.org, tom@talpey.com, senozhatsky@chromium.org,
	chenxiaosong@chenxiaosong.com
Cc: linux-cifs@vger.kernel.org,
	ZhangGuoDong <zhangguodong@kylinos.cn>,
	ChenXiaoSong <chenxiaosong@kylinos.cn>
Subject: [PATCH 2/2] smb/server: fix file name conversion on big-endian systems
Date: Tue, 24 Nov 2026 15:56:12 +0800	[thread overview]
Message-ID: <20261124075613.469257-3-zhang.guodong@linux.dev> (raw)
In-Reply-To: <20261124075613.469257-1-zhang.guodong@linux.dev>

From: ZhangGuoDong <zhangguodong@kylinos.cn>

Use CPU byte order for temporary UTF-16 buffers to avoid incorrect
file name conversion on big-endian architectures.

Fixes: 0c180317c654 ("ksmbd: add support for surrogate pair conversion")
Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn>
Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/server/unicode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/smb/server/unicode.c b/fs/smb/server/unicode.c
index 85e6791745ec..8841f8a83026 100644
--- a/fs/smb/server/unicode.c
+++ b/fs/smb/server/unicode.c
@@ -80,7 +80,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;
@@ -404,7 +404,7 @@ int smbConvertToUTF16(__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;
-- 
2.55.0


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

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  7:56 [PATCH 0/2] smb/server: fix byte order issues on big-endian systems ZhangGuoDong
2026-11-24  7:56 ` [PATCH 1/2] smb/server: fix little-endian values in diagnostic messages ZhangGuoDong
2026-11-24 23:32   ` Namjae Jeon
2026-11-24  7:56 ` ZhangGuoDong [this message]
2026-11-24 23:32   ` [PATCH 2/2] smb/server: fix file name conversion on big-endian systems Namjae Jeon

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=20261124075613.469257-3-zhang.guodong@linux.dev \
    --to=zhang.guodong@linux.dev \
    --cc=chenxiaosong@chenxiaosong.com \
    --cc=chenxiaosong@kylinos.cn \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=senozhatsky@chromium.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.