From nobody Sun Feb 18 15:20:02 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Td8VV3KTGz59xJk; Sun, 18 Feb 2024 15:20:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Td8VV2dQpz46Nf; Sun, 18 Feb 2024 15:20:02 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708269602; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0Wyb4vQS2NKTYytZ6bZ3JoZ0QIFvCv5RjKIDSDj6rTg=; b=i5SYv1oFIZTCAUICkOz/zM2V6/dkB6Wi55C386zvD5LLGZ35Gy7lSQA/UmSvJhpKTZTXBT x2nGWUSVhg8ajTJAdWp9MKuJ7mECiJlt/s746sp0YBlmIbw9YM/fuKgt1gPVYnTsBeui7d mFbv/Oj1sufb48lg8hbeJzw7yXZq7mx8g9fMiM7y/Ps6RMVLsYznvoFB4vG8b8HZaa+Bme VMBg+iAGRUDHC+xyNVThrZCi29sE+zk+VSPa0LiQrx7yb27JZv1zYXKFd3PMR7N+3QcX52 ZRN+L3opjbjYW8Re1bz1xVrX6FqOB+6YjZO8HDC0M9x5QdSbCQyE3/WbPJwWww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708269602; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=0Wyb4vQS2NKTYytZ6bZ3JoZ0QIFvCv5RjKIDSDj6rTg=; b=qDn9zLGhXgboEs3fIRQAkQgrR6iPHwLAbWubx9Y2izcR7XK+3YUs3PB8Kfy3sz9iRO/VRo OZWiGZL1FiP37bis5BcYrWRcCnPkX6U9QBCLuUofDfzfBbvuOyNnhqzLmmDVv7bMVwQ+oa d8Alb6amNbp2GZKIIB+8Pt+LyZ+NpT4C3td7rMNMZOIQlzp2rxHGO7TeyHpXBsvxnGsL7x tpQQ46sOSl3TBYzuxln9IRnEJj80+aYHAvi/dbb6BSXx3qQje4K7Fuiml1619guH19gFmj X5cDNe81Y0GahAQeMKHbdmghk6s+/ZD+kNi0mBAfMbwjbjBSLbr7AteXCAwOcA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708269602; a=rsa-sha256; cv=none; b=UrJeT+q5vkstlZIjWv6kdRFmM9TR/sSPboW2Hu0A0M6VQ19vYDKr1pzhWY5HcTus39DpuP uG0537q+dqB0+POCNSfE970th/7S8ua0hx2GU88DFsU1zdkZBWzFnuGeSheKMB7lca+Ukc y9QY1m4HOm0FWGbk1HE9AkA1Nnkut236GKGZlt+XdeG9cgqo2AOSLQBKht8NkaPG6mc1ym sCiSw/+0jstoo8HbAYriSRRS/pxdhpQw+UaxZv7des80RcqohnQKVcGVSTUpMlJDd/Jpfm 8XbsbFLo0OsIkzZbEeoggcnyvTB8EYhL2k/oVZg4i4MIoB+dQIPBZzrIKoxHsQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Td8VV1jRFzwBp; Sun, 18 Feb 2024 15:20:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41IFK2lv011765; Sun, 18 Feb 2024 15:20:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41IFK2or011761; Sun, 18 Feb 2024 15:20:02 GMT (envelope-from git) Date: Sun, 18 Feb 2024 15:20:02 GMT Message-Id: <202402181520.41IFK2or011761@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "Jason A. Harmening" Subject: git: a2ddbe019d51 - main - unionfs: work around underlying FS failing to respect cn_namelen List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jah X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a2ddbe019d51b35f9da2cb5ddca8c69f0ee422da Auto-Submitted: auto-generated The branch main has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=a2ddbe019d51b35f9da2cb5ddca8c69f0ee422da commit a2ddbe019d51b35f9da2cb5ddca8c69f0ee422da Author: Jason A. Harmening AuthorDate: 2023-12-24 04:48:19 +0000 Commit: Jason A. Harmening CommitDate: 2024-02-18 15:19:23 +0000 unionfs: work around underlying FS failing to respect cn_namelen unionfs_mkshadowdir() may be invoked on a non-leaf pathname component during lookup, in which case the NUL terminator of the pathname buffer will be well beyond the end of the current component. cn_namelen in this case will still (correctly) indicate the length of only the current component, but ZFS in particular does not currently respect cn_namelen, leading to the creation on inacessible files with slashes in their names. Work around this behavior by temporarily NUL- terminating the current pathname component for the call to VOP_MKDIR(). https://github.com/openzfs/zfs/issues/15705 has been filed to track a proper upstream fix for the issue at hand. PR: 275871 Reported by: Karlo Miličević Tested by: Karlo Miličević Reviewed by: kib, olce MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D43818 --- sys/fs/unionfs/union_subr.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index b438131dc820..686043cc93de 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -916,7 +916,24 @@ unionfs_mkshadowdir(struct unionfs_mount *ump, struct vnode *udvp, goto unionfs_mkshadowdir_abort; unionfs_create_uppervattr_core(ump, &lva, &va, td); + /* + * Temporarily NUL-terminate the current pathname component. + * This function may be called during lookup operations in which + * the current pathname component is not the leaf, meaning that + * the NUL terminator is some distance beyond the end of the current + * component. This *should* be fine, as cn_namelen will still + * correctly indicate the length of only the current component, + * but ZFS in particular does not respect cn_namelen in its VOP_MKDIR + * implementation + * Note that this assumes nd.ni_cnd.cn_pnbuf was allocated by + * something like a local namei() operation and the temporary + * NUL-termination will not have an effect on other threads. + */ + char *pathend = &nd.ni_cnd.cn_nameptr[nd.ni_cnd.cn_namelen]; + char pathterm = *pathend; + *pathend = '\0'; error = VOP_MKDIR(udvp, &uvp, &nd.ni_cnd, &va); + *pathend = pathterm; if (!error) { unionfs_node_update(unp, uvp, td);