From nobody Tue Nov 17 01:09:32 2026 X-Original-To: dev-commits-src-all@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 4jT68D4h28z71Pnv for ; Tue, 17 Nov 2026 01:09:32 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jT68D22Cfz3C2m for ; Tue, 17 Nov 2026 01:09:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794877772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=w3fQamUdpOS1a6nND6DbOKyLr/IgNzTEZheixYzvgV0=; b=gLO7FD5/zeW05c6nlUBNNBnG30uVwGcolYtVpVf1T0jD8rAqlgAxsZfk0rIVGMhYpRuJe4 VInG8xygrjNjRQyiVdxF8yHoBbA8p+VRI/wunw2lYLKKzaZEzIC59QS+qtaL/lLIUp87SP mU+gO49vIspFJ9O52e7WzU8UcNXCGjWo4ptipFaYQg1r6fIkh2KxA6vAbKhWQmF5paxK6h Xg/OBEVF0NtqEPISLI/8d4ONlt+GTlxUjSv9Py6T0Wy7RJyPkadlLTCRnQlkdxdiRpngt8 Se8FS6Ak4qb6er9u9IfWketOolmw9mNFK/roP052B+F89uH3IYKOnyNYJQf7Xw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794877772; b=xDBITJanDI5u+mQYmWQvc1rtJf3W/ihgarSa2QyDcTON8+Sa8DiqyfTvZq5uchaYvubh0Z uGJgBC5ImNHTgoe7k+1y+15OSgBQGe5Ahq4TRxDOl3rLHyXDpV+PzYvqmdpJcq8z8k0YsJ IAyHcOfROmtDqZfltUkDj5lSFzqIBmfxGYD8RF55YH2kQg0pf9OaAJu76FuCDzA5pvMKNO udqo3D8Jbxu+egrR9LmIHWQdY6h/lSFigFd9VeoFnnDQnqioFkUxTpdliGJ97B/ABB1S7X Sq1ScHuuKHIQf+XFOyDROP6fxAP9Q27zB9wIC0ZpJqxHSL+pYygw6/VR67z6xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794877772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=w3fQamUdpOS1a6nND6DbOKyLr/IgNzTEZheixYzvgV0=; b=KH9ZAiJ1/5KeBJe8hqW6nnMqlBsbGqzNtapNN0t/2WjQ/LRnSgvUwG1QB28kyttuI8TcnV g0WjiE1d/TM1NLsiPVvu8GT5hl9XS9D5ff2XlPOZBN/Pbz6JNEpDVFgw3Dy6Y9KZhdJ+7X OOEQuigNxTeVrSAGnXFu220YUvUl5RnhuxWap/QPAzQIID+v0D6zp0kfQy3/3bLWczicb/ K59snVKRNyUlPQRhqUg5I4zL0AGbDQIPLf7NFNXk+mnteIN+USkAjlEuUtjblgw6pIM90l NOPkqG+CeVTBR2qefyJekdKhEOmcQvqmGyJtFMeeHEOBM6HYeY+xdFmApi8sDQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jT68D1hjzzHHT for ; Tue, 17 Nov 2026 01:09:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 101d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 01:09:32 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Devin Teske From: Konstantin Belousov Subject: git: b04066641010 - stable/15 - namei: retry absolute symlink expansions from the native root List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository 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 X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: b040666410106d29ef618dc1b210839b19115ead Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 01:09:32 +0000 Message-Id: <6afba94c.101d.f0f8701@gitrepo.freebsd.org> The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b040666410106d29ef618dc1b210839b19115ead commit b040666410106d29ef618dc1b210839b19115ead Author: Devin Teske AuthorDate: 2026-10-18 15:44:12 +0000 Commit: Konstantin Belousov CommitDate: 2026-11-17 00:24:56 +0000 namei: retry absolute symlink expansions from the native root PR: 297426 (cherry picked from commit 23b326728778fd3a6c37b33686dea98d010eb1cf) --- sys/kern/vfs_lookup.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 105 insertions(+), 1 deletion(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 1ed8af81dde2..fadc65918657 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -613,11 +613,25 @@ namei(struct nameidata *ndp) struct componentname *cnp; struct thread *td; struct pwd *pwd; + char *abi_symlink; /* abs symlink expansion from the ABI pass */ + size_t abi_symlink_len; + size_t abi_suffix_len; /* leftover path past the saved target */ + bool target_resolved; /* walk has consumed that target */ + enum { + NAMEI_ABI_PASS_ABI = 0, + NAMEI_ABI_PASS_SYMLINK, + NAMEI_ABI_PASS_NATIVE, + } abi_pass; int error; enum cache_fpl_status status; cnp = &ndp->ni_cnd; td = curthread; + abi_symlink = NULL; + abi_symlink_len = 0; + abi_suffix_len = 0; + target_resolved = false; + abi_pass = NAMEI_ABI_PASS_ABI; #ifdef INVARIANTS KASSERT((ndp->ni_debugflags & NAMEI_DBG_CALLED) == 0, ("%s: repeated call to namei without NDREINIT", __func__)); @@ -655,7 +669,15 @@ restart: ndp->ni_loopcnt = 0; ndp->ni_vp = NULL; - error = namei_getpath(ndp); + if (__predict_false(abi_pass == NAMEI_ABI_PASS_SYMLINK)) { + /* + * The expansion was installed when abi_pass became + * SYMLINK. It is not reloaded from userspace. + */ + MPASS(cnp->cn_pnbuf != NULL); + error = 0; + } else + error = namei_getpath(ndp); if (__predict_false(error != 0)) { namei_cleanup_cnp(cnp); nameicap_cleanup(ndp, error); @@ -734,6 +756,8 @@ restart: * Locked lookup. */ for (;;) { + size_t prev_pathlen; + ndp->ni_startdir = dp; error = vfs_lookup(ndp); if (error != 0) { @@ -746,10 +770,56 @@ restart: error == ENOENT && was_restarted == 0; if (error != ERESTART && !abi_restart) goto out; + /* + * One restart from the native root is allowed. + * abi_pass only moves ABI -> SYMLINK or ABI -> + * NATIVE; never backwards. If the target of an + * absolute symlink had not yet resolved when the + * ABI pass failed, restart walking the saved + * expansion in place of the original path: the + * target may name a file that exists only in the + * native namespace (host-integration symlinks + * under the ABI root, linprocfs' /proc//exe). + * An ENOENT after the target resolved, or with + * nothing saved, restarts from the original path. + * + * The old path buffer is released before the + * expansion is installed, so namei_cleanup_cnp() + * does not free the saved symlink. + * + * vfs_lookup() subtracts a component from + * ni_pathlen before looking it up, so a miss on + * the target's own last component leaves exactly + * the suffix; only less than that means the walk + * had moved past the target. + */ + if (abi_symlink != NULL && + ndp->ni_pathlen < abi_suffix_len) + target_resolved = true; nameicap_cleanup(ndp, error); pwd_drop(pwd); namei_cleanup_cnp(cnp); NDRESET(ndp); + if (abi_restart && abi_symlink != NULL && + !target_resolved) { + KASSERT(abi_pass == NAMEI_ABI_PASS_ABI, + ("%s: symlink restart from pass %d", + __func__, abi_pass)); + abi_pass = NAMEI_ABI_PASS_SYMLINK; + cnp->cn_pnbuf = abi_symlink; + ndp->ni_pathlen = abi_symlink_len; + abi_symlink = NULL; + } else { + if (abi_restart) { + KASSERT(abi_pass == + NAMEI_ABI_PASS_ABI, + ("%s: native restart from pass %d", + __func__, abi_pass)); + abi_pass = NAMEI_ABI_PASS_NATIVE; + } + uma_zfree(namei_zone, abi_symlink); + abi_symlink = NULL; + } if (abi_restart) was_restarted = ISRESTARTED; ndp->ni_cnd.cn_flags |= was_restarted; @@ -764,14 +834,19 @@ restart: ndp->ni_vp, false, ndp); nameicap_cleanup(ndp, 0); pwd_drop(pwd); + uma_zfree(namei_zone, abi_symlink); NDVALIDATE(ndp); return (0); } + prev_pathlen = ndp->ni_pathlen; error = namei_follow_link(ndp); if (error != 0) break; vput(ndp->ni_vp); dp = ndp->ni_dvp; + if (abi_symlink != NULL && + prev_pathlen <= abi_suffix_len) + target_resolved = true; /* * Check if root directory should replace current directory. */ @@ -789,10 +864,38 @@ restart: */ if ((cnp->cn_flags & ISRESTARTED) != 0) ndp->ni_rootdir = pwd->pwd_rdir; + else if (pwd->pwd_adir != pwd->pwd_rdir) { + /* + * Save the expansion, and the length of + * the not-yet-walked suffix appended past + * the target, so that should the target + * fail to resolve under the ABI root the + * ENOENT handling above can restart from + * the expansion in place of the original + * path. + */ + if (abi_symlink == NULL) + abi_symlink = uma_zalloc(namei_zone, + M_WAITOK); + memcpy(abi_symlink, cnp->cn_pnbuf, + ndp->ni_pathlen); + abi_symlink_len = ndp->ni_pathlen; + abi_suffix_len = prev_pathlen; + target_resolved = false; + } vrele(dp); error = namei_handle_root(ndp, &dp); if (error != 0) goto out; + } else if (target_resolved) { + /* + * Target already consumed under the ABI root + * (relative symlink at or past the end of the + * saved expansion). A later ENOENT is no + * grounds to restart from that expansion. + */ + uma_zfree(namei_zone, abi_symlink); + abi_symlink = NULL; } } vput(ndp->ni_vp); @@ -804,6 +907,7 @@ out: namei_cleanup_cnp(cnp); nameicap_cleanup(ndp, error); pwd_drop(pwd); + uma_zfree(namei_zone, abi_symlink); return (error); }