From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796229288; b=iVue6n205zTHuMzzN4iqAIvRVbT8jjrJeoq9feSdbiPG9jUnUEwisXix56zImm9jVzeg W3YiUr3lB8QrxpmdcraJo2vDaVIysJ4vSm4DT9Cjb6l1ai4dtK/9PYAYc4vvvkGFLpl47 W91rWoFpXi0A2G++jLEAZkBzsETZei+KVxDpHWQB9No0BZaZOZuHmQnXWlgnmCNoZyh51 EkZaWynp528VnHQQmhBy0aM0EmiOfDfr5I2OUDf3Vm4YT8rMBWhzoAYgahqGoX0C2ZJuM gpo8a1kYzOqEpWBM+D/zALqTeV+uj1IOctafy25D/DvtHFoTLW7KW3vYZKn4qoLLo+Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796229288; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=Gh5fJX2E0Y13cklYptgCHUCPsOzDoofNNP+etaT+mSA=; b=ph4nhW0G8EdLn9R9FdbhoU3uiS8ZzK02imY/Qjlk2AhNdAYsJ6qy8ohtODgZHvPKWHXL 8wglvw0i27Tsr20N4LBDBn6Wjq7+BkmfaLsGugRXtjJrLdE1jn7bwqd0VOeZy0P79AC1S jIT3NoStWBe2LcFabLKfEqnk9msd06XM886SU9h212TkpKG+b6ubxR15vQS+xfhNVf/Gn a1rD+JpDorQD8sAMgcKyn+PTAQgk9cz8WkpwrWpJZ/rcoOA/gLNBvPs6v2EXEC3jnW9yC G1LaKkYRL3OTbEVFjeJSDwtP/C9Q+Di9sTYVi1EQ+619foSdGFIER8+f4aoPAyRp28g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="HS/Cgo/y"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42521606A323 for ; Wed, 2 Dec 2026 16:34:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=HS/Cgo/y Received: by smtp.kernel.org (Postfix) with ESMTPSA id 731AA1F00897; Wed, 2 Dec 2026 16:34:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796229288; bh=Gh5fJX2E0Y13cklYptgCHUCPsOzDoofNNP+etaT+mSA=; h=Subject:To:Cc:From:Date; b=HS/Cgo/yypkESGapVz0AAzrA8myA1t3nj4xyu+a+citqcoxoijaD6Cl6YQdEj5Gr5 NlZN9MJPjRIyCJUZwJATHsxBNisItm6g5hFRjCaPlEbXEzMhnerZrijWUg3MbFXEUz jPjYMtCQHKSh/ghCa6L1xM2N5SF3r2M7OyFSVINw= Subject: FAILED: patch "[PATCH] smb: client: convert path_consumed to mount charset units" failed to apply to 6.6-stable tree To: fredric.cover.lkernel@gmail.com,pc@manguebit.org Cc: From: Date: Wed, 02 Dec 2026 17:05:25 +0100 Message-ID: <2026120225-banister-race-ec5d@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.6-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y git checkout FETCH_HEAD git cherry-pick -x 3a191eec3627acd558640cf4092e9e337aa15291 # git commit -s git send-email --to '' --in-reply-to '2026120225-banister-race-ec5d@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 3a191eec3627acd558640cf4092e9e337aa15291 Mon Sep 17 00:00:00 2001 From: Fredric Cover Date: Thu, 12 Nov 2026 04:21:36 +0000 Subject: [PATCH] smb: client: convert path_consumed to mount charset units MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit path_consumed in a DFS referral counts bytes of the canonical path, which is in the DFS cache charset (utf8). dfs_parse_target_referral() applies it as an offset into full_path, which is in the mount charset. When the mount charset is not utf8, each non-ASCII character in the consumed part that encodes longer in utf8 than in the mount charset makes the offset too large, so leading characters of the prefix path are dropped. For example, with iocharset=iso8859-1, mounting //srv/dfs/café é/sub yields the prefix "ub" instead of "sub" and the mount fails with -ENOENT. (A single accented character only worked because the offset happened to land after the delimiter.) Translate the count in parse_dfs_target(), where both strings are available, by matching path components: count the delimiters in the consumed part of the canonical path and find the same position in the mount charset path. Delimiters are ASCII in both and are not affected by remapping. If the consumed bytes are identical in both strings, which is the case for utf8 mounts and ASCII-only prefixes using the default backslash delimiter, the value is used unchanged. This assumes the server reports PathConsumed on a component boundary; a translated value that ends mid-component is rounded up to the next boundary. Tested against Samba on a KASAN kernel: with iocharset=iso8859-1, links with 0 to 3 accented characters followed by a tail, a two-level tail, an accented tail, a link in a subdirectory, and mapposix with an accented name; iso8859-15 and cp932 mounts; and iocharset=utf8 controls. Not tested against Windows servers, with posixpaths, or with reserved characters under mapchars/mapposix. Signed-off-by: Fredric Cover Cc: stable@vger.kernel.org Signed-off-by: Paulo Alcantara diff --git a/fs/smb/client/dfs.c b/fs/smb/client/dfs.c index 57c90a2512a3..788cdda9a573 100644 --- a/fs/smb/client/dfs.c +++ b/fs/smb/client/dfs.c @@ -85,16 +85,87 @@ static void set_root_smb_session(struct cifs_mount_ctx *mnt_ctx) ctx->dfs_root_ses = ses; } +static bool dfs_is_delim(wchar_t c) +{ + return c == '/' || c == '\\'; +} + +/* + * @consumed counts bytes of the canonical (cache charset) path @cpath. + * Return the matching byte offset in @fpath, which holds the same path in + * the mount charset. Offsets are matched by path component, since the + * delimiters are ASCII in every charset and survive remapping. + */ +static int dfs_consumed_to_local(const struct nls_table *nls, + const char *cpath, const char *fpath, + int consumed) +{ + size_t clen = strlen(cpath), flen = strlen(fpath), off = 0; + int ndelims = 0, seen = 0, i; + bool ends_on_delim; + + if (consumed < 0) + return -EINVAL; + + /* Identical bytes in both strings: units already agree */ + if ((size_t)consumed <= min(clen, flen) && + !memcmp(cpath, fpath, consumed)) + return consumed; + + if ((size_t)consumed > clen) + consumed = clen; + + for (i = 0; i < consumed; i++) + if (dfs_is_delim(cpath[i])) + ndelims++; + ends_on_delim = consumed && dfs_is_delim(cpath[consumed - 1]); + + while (off < flen) { + wchar_t uni; + int len; + + len = nls->char2uni((const unsigned char *)fpath + off, + flen - off, &uni); + if (len <= 0) { + uni = (unsigned char)fpath[off]; + len = 1; + } + if (dfs_is_delim(uni)) { + /* check if start of next component */ + if (!ends_on_delim && seen == ndelims) + break; + seen++; + if (ends_on_delim && seen == ndelims) { + /* just past the last consumed delimiter */ + off += len; + break; + } + } + off += len; + } + return off; +} + static inline int parse_dfs_target(struct smb3_fs_context *ctx, struct dfs_ref_walk *rw, struct dfs_info3_param *tgt) { - int rc; const char *fpath = ref_walk_fpath(rw) + 1; + const char *cpath = ref_walk_path(rw) + 1; + int rc; rc = ref_walk_get_tgt(rw, tgt); - if (!rc) - rc = dfs_parse_target_referral(fpath, tgt, ctx); + if (!rc) { + struct dfs_info3_param local = *tgt; + int off; + + off = dfs_consumed_to_local(rw->mnt_ctx->cifs_sb->local_nls, + cpath, fpath, tgt->path_consumed); + if (off < 0) + return off; + local.path_consumed = off; + rc = dfs_parse_target_referral(fpath, &local, ctx); + } return rc; }