parse_dfs_target() converts @path_consumed to the mount charset using dfs_consumed_to_local(), but @ref->node_name from the DFS referral cache is still encoded in UTF-8 (cache_cp). In dfs_parse_target_referral(), passing @ref->node_name directly to cifs_build_devname() and smb3_parse_devname() copies UTF-8 bytes into ctx->UNC and ctx->prepath (and mixes encodings when @prepath from @full_path is also non-empty). On mounts using a non-UTF-8 iocharset such as iso8859-1, subsequent path checks re-encode these strings to UTF-16LE using local_nls, corrupting non-ASCII characters on the wire and causing initial mount to fail with -ENOENT. Convert @ref->node_name from cache_cp to ctx->local_nls with dfs_cache_local_path() before building the device name so ctx->UNC and ctx->prepath stay in the mount charset. Tested against Samba with iocharset=iso8859-1 and iocharset=utf8 for both DFS link referrals with a non-ASCII target subpath and mounts with an additional non-ASCII prepath, including reconnects. Fixes: c870a8e70e68 ("cifs: handle different charsets in dfs cache") Cc: stable@vger.kernel.org # depends on: smb: client: convert DFS prefix from cache charset on reconnect Signed-off-by: Fredric Cover --- Note: Applies on top of "smb: client: convert DFS prefix from cache charset on reconnect". --- fs/smb/client/dfs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/smb/client/dfs.c b/fs/smb/client/dfs.c index efef00c33321..6b212e49cf92 100644 --- a/fs/smb/client/dfs.c +++ b/fs/smb/client/dfs.c @@ -25,6 +25,7 @@ int dfs_parse_target_referral(const char *full_path, const struct dfs_info3_para { int rc; const char *prepath = NULL; + char *node_name = NULL; char *path; if (!full_path || !*full_path || !ref || !ctx) @@ -40,7 +41,12 @@ int dfs_parse_target_referral(const char *full_path, const struct dfs_info3_para prepath++; } - path = cifs_build_devname(ref->node_name, prepath); + node_name = dfs_cache_local_path(ref->node_name, ctx->local_nls); + if (IS_ERR(node_name)) + return PTR_ERR(node_name); + + path = cifs_build_devname(node_name, prepath); + kfree(node_name); if (IS_ERR(path)) return PTR_ERR(path); -- 2.53.0