From nobody Mon Mar 04 18:51:46 2024 X-Original-To: dev-commits-src-branches@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 4TpSTt6p89z5D6Nr; Mon, 4 Mar 2024 18:51:46 +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 4TpSTt5llkz4bnK; Mon, 4 Mar 2024 18:51:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709578306; 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=ky7Mux0irIVr5Zh2CSNT2SAs6Gedn/gMBdkEZXKmf18=; b=VnG4GkvOTqQx1lW6ISTwXGXgVSnkx/4v2PVFGtjWP/xXYGLrbbxI5wox3AOv+IiHrrt+QE E3I1nMGyj3Em0jS/0lPU2r+bsN3zrKoC0JdMkSu+bzc1+M0pkkligMRUYLYEEsXlOqWbjV njJaPPTHTioBnAcayoy+K3GvUYUW2LuSArBn6SWmTM8DuqLxYxwsb4lUg9Jal0qW5km9vl Vs4M0ahG6zEYrHSS3fvJh+UzLQUeRjO2e275n93Lb3zStwsnoofM2ZURHvhVNvqkiktqz4 2X+2i6JH/gXfUkNxCNNpZJH9Rb0+Ns8JCnyRQ+LPAkR9z6JUJxRMMW9N3bsAWQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709578306; a=rsa-sha256; cv=none; b=yp6sr1XfrjOukZ9SVc3mV/MFclWjYKi2VQAg+4WVCMoGnBPru9FM8ME70BGQOXq7stPiUx FfPoqO6JQ5Jqg9suQMqKwKBg7a7PWkRY14biYvndxoD4p7hJnyv7cEaQ3l7sP3CCVLm3VA nle9PqoJPTBa/8fc36KicBNpOvqKhOvPrDG4IJtZmJXAdi6M0PY0ZAJz7M2xgrxZ2HOeiq DKj0EM3DnlHog0VtGue0vJQXAMc9oh1nUMs8R9dHNCgTi+BEUusPsoKk8PWuTdzYS7LlVI cvQNqeJywE74LdoSBaN5L00c7LxCodAcCrLa3jB3nlbG/kQ8NfAcS7a4tsAyEw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709578306; 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=ky7Mux0irIVr5Zh2CSNT2SAs6Gedn/gMBdkEZXKmf18=; b=yW7wFGVMrbsFXBzsZ3Zqm0pbuPEkJziKUIzv6f9qpWK1+O0YrlUVDv+kf5rwzbedVeG+eS g9U1owtM519+qU9IAyQDe22CRo4Hw55LrWqLPY5eKHxyXqACMFYpJvfLjTlPWDEHaKDNf0 YFxe/PTGj/xdI4+xUNIP9VQvRi3ykieMUj2/9I1aO/kPJ7jf45PjMipUFiak1ZG8Xk+p1I k/S9+Y9f0Y4GvEXNj9SUIRyCvtmMwBxMxfHApZuO+lNdkUPd/PmnqIiRMl3U87i1OakW08 6AudCmxUT5hF7WFoD5Z9xE35PplW7sPLT8a4xnnCGPd+TTSYWg4zZk5byq+yQA== 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 4TpSTt5N4kzYk1; Mon, 4 Mar 2024 18:51:46 +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 424IpkCf009634; Mon, 4 Mar 2024 18:51:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 424IpkxK009631; Mon, 4 Mar 2024 18:51:46 GMT (envelope-from git) Date: Mon, 4 Mar 2024 18:51:46 GMT Message-Id: <202403041851.424IpkxK009631@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "Jason A. Harmening" Subject: git: c18e6a5a5c63 - stable/14 - unionfs: work around underlying FS failing to respect cn_namelen List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/14 X-Git-Reftype: branch X-Git-Commit: c18e6a5a5c63d85d664d60dc3bf0232ea21bf8d2 Auto-Submitted: auto-generated The branch stable/14 has been updated by jah: URL: https://cgit.FreeBSD.org/src/commit/?id=c18e6a5a5c63d85d664d60dc3bf0232ea21bf8d2 commit c18e6a5a5c63d85d664d60dc3bf0232ea21bf8d2 Author: Jason A. Harmening AuthorDate: 2023-12-24 04:48:19 +0000 Commit: Jason A. Harmening CommitDate: 2024-03-04 18:31:25 +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 Differential Revision: https://reviews.freebsd.org/D43818 (cherry picked from commit a2ddbe019d51b35f9da2cb5ddca8c69f0ee422da) --- 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 c841136e42d5..469ba0775e7c 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -918,7 +918,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);