From: Fredric Cover <fredric.cover.lkernel@gmail.com>
To: Paulo Alcantara <pc@manguebit.org>, Namjae Jeon <linkinjeon@kernel.org>
Cc: ChenXiaoSong <chenxiaosong@chenxiaosong.com>,
Tom Talpey <tom@talpey.com>,
Ronnie Sahlberg <ronniesahlberg@gmail.com>,
Shyam Prasad N <sprasad@microsoft.com>,
Bharath SM <bharathsm@microsoft.com>,
linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org,
Fredric Cover <fredric.cover.lkernel@gmail.com>
Subject: [PATCH 2/2] smb: client: fix double conversion of DFS path in setup_dfs_ref()
Date: Sat, 7 Nov 2026 02:02:57 +0000 [thread overview]
Message-ID: <20261107020257.363811-3-fredric.cover.lkernel@gmail.com> (raw)
In-Reply-To: <20261107020257.363811-1-fredric.cover.lkernel@gmail.com>
setup_dfs_ref() converts the path from the mount charset to the DFS
cache charset (utf8) via dfs_get_path(), and then passes that already
converted string to dfs_get_referral(). dfs_cache_find() converts its
input again, assuming it is still in the mount charset.
When the mount charset is not utf8 (iocharset=iso8859-1, or a kernel
built with a non-utf8 CONFIG_NLS_DEFAULT) and the DFS path contains
non-ASCII characters, the utf8 bytes are interpreted as mount-charset
characters and encoded a second time. For example, "é" is sent as
c3 83 c2 a9 instead of c3 a9. The server then fails the second-level
referral with STATUS_OBJECT_PATH_NOT_FOUND and the mount fails with
-ENOENT, even though the path exists.
Pass the unconverted path to dfs_get_referral() so that it is converted
exactly once.
Such mounts now get past the second-level referral and reach
dfs_parse_target_referral(), which is why this change depends on
"smb: client: fix out-of-bounds read in dfs_parse_target_referral()".
Tested with a Samba DFS root containing a link named "café", mounted
with iocharset=iso8859-1 and the single Latin-1 byte 0xe9 in the path:
before, the mount failed with -ENOENT; with both patches applied, it
succeeds.
Signed-off-by: Fredric Cover <fredric.cover.lkernel@gmail.com>
---
fs/smb/client/dfs.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/fs/smb/client/dfs.c b/fs/smb/client/dfs.c
index e6dcaf9b8682..0660c0a1eefb 100644
--- a/fs/smb/client/dfs.c
+++ b/fs/smb/client/dfs.c
@@ -103,6 +103,7 @@ static int setup_dfs_ref(struct dfs_info3_param *tgt, struct dfs_ref_walk *rw)
struct cifs_sb_info *cifs_sb = rw->mnt_ctx->cifs_sb;
struct smb3_fs_context *ctx = rw->mnt_ctx->fs_ctx;
char *ref_path, *full_path;
+ const char *raw_path;
int rc;
set_root_smb_session(rw->mnt_ctx);
@@ -114,9 +115,10 @@ static int setup_dfs_ref(struct dfs_info3_param *tgt, struct dfs_ref_walk *rw)
if (!tgt || (tgt->server_type == DFS_TYPE_LINK &&
DFS_INTERLINK(tgt->flags)))
- ref_path = dfs_get_path(cifs_sb, ctx->UNC);
+ raw_path = ctx->UNC;
else
- ref_path = dfs_get_path(cifs_sb, full_path);
+ raw_path = full_path;
+ ref_path = dfs_get_path(cifs_sb, raw_path);
if (IS_ERR(ref_path)) {
rc = PTR_ERR(ref_path);
kfree(full_path);
@@ -125,9 +127,13 @@ static int setup_dfs_ref(struct dfs_info3_param *tgt, struct dfs_ref_walk *rw)
ref_walk_path(rw) = ref_path;
ref_walk_fpath(rw) = full_path;
- return dfs_get_referral(rw->mnt_ctx,
- ref_walk_path(rw) + 1,
- ref_walk_tl(rw));
+ /*
+ * dfs_cache_find() canonicalizes its input from the mount's charset, so
+ * give it the raw path. Passing ref_walk_path() (already in the cache
+ * charset) would convert it a second time.
+ */
+
+ return dfs_get_referral(rw->mnt_ctx, raw_path + 1, ref_walk_tl(rw));
}
static int __dfs_referral_walk(struct dfs_ref_walk *rw)
--
2.53.0
prev parent reply other threads:[~2026-11-07 2:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 2:02 [PATCH 0/2] smb: client: fix DFS handling of non-ASCII paths with non-utf8 charset Fredric Cover
2026-11-07 2:02 ` [PATCH 1/2] smb: client: fix out-of-bounds read in dfs_parse_target_referral() Fredric Cover
2026-11-07 2:02 ` Fredric Cover [this message]
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=20261107020257.363811-3-fredric.cover.lkernel@gmail.com \
--to=fredric.cover.lkernel@gmail.com \
--cc=bharathsm@microsoft.com \
--cc=chenxiaosong@chenxiaosong.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pc@manguebit.org \
--cc=ronniesahlberg@gmail.com \
--cc=sprasad@microsoft.com \
--cc=tom@talpey.com \
/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
all inboxes | Powered by JetHome®