From nobody Thu Jul 30 02:56:39 2026 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 4h9Ykb3gbyz6mQbP for ; Thu, 30 Jul 2026 02:56:39 +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 "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4h9Ykb35zrz3Hwv for ; Thu, 30 Jul 2026 02:56:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785380199; 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=/MCkhcUfcnC3hyKI365mbnZY5bW84xHIXIY3Vrcxut8=; b=niIOKf7XX/NqPNR13Iecu2C7X1j9HH3ORgGmOZSDeWbfhnOGeGmlyZjb1J+HJRK3QJwiPP JLV9FzxewzBfceS0zaN441oqjLVzE+GjBiJ/6u08LOnLz1yjsC/9RtzQnU5qZ3AKYHzfdL 4IKYwvshPctaJ34lnYhHvf9Vdrc7477t82z0r+sYpKyGBAIJUYFXlGS+NepWctbt2n03GC 78z7WrHmkVOg/GphKmWTuBWH14ERqayTN2nTieqVF/smTTKNekk3LxQRAkL4lG0dutqSv3 PQAUrAv1AvcRsaTKm5jqbYSzbJ8D7sBgUbX5xxUzSsZYfJhxNClbAMwHtuXn3w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785380199; a=rsa-sha256; cv=none; b=K949cy8RCVBiBB37SPdb8jrddcu33jNFbge4OM9y0IoNIclcxTV3O009L6suaOdtYBLLYr 1/frY8Za+mhuNFGMAOOUBliCAgVDCUo/BtButwN9Vhj4SuGiuJ0HMChISgPWxDmC3zvDw/ h6izZXVP0EANWJjlAp+QPYtIH+T7/Ng+uWdW0PZSfzmiGtVCiLGUmgxIdt9QRmz86W0dD0 sSOX5Jn67qLSqJSAf+gje27AJKtI7b4jLqA7qyYlhlzyK3mxM59JPmjdNjtuSfAMUP/KVS nlEw9IOu4YHR5Bt7bC5HwBgw7owfIb9lvZryWzbW3otdK6Xc+Ewj0gEmZm0NVQ== 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=1785380199; 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=/MCkhcUfcnC3hyKI365mbnZY5bW84xHIXIY3Vrcxut8=; b=MNxPO/kdxmgQl1CeOTHWvWgxRehVy+APnCqska5RBG2o2c/CKP/b8ey705Nu0EPWbo6YC5 gdVjRb9j3BVks37lz7520KMp0LbZKpYRDez5fiw770Y20ztr8OzGe2yt5XJYIl2UvkShJw zui0xbPb6HMMkuFaP4hio567TGCLIooSB4Ci/OROiGX9nAz77LliZr+zBIPlYjm9/asunx zF+xKrg4VM5DcAOUA8/2LvfswFKJl9afyHm5W50cdFgKc9Lk72QJkDPFixc4duQex7lmPL k75aSdyZJpcnDrmAL5nIKedPo5pm1Lop0IlNqWRmLNGp3QgyVAgIChYwzl64fQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h9Ykb1JDFzvLj for ; Thu, 30 Jul 2026 02:56:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1a0ec by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 30 Jul 2026 02:56:39 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 930f2e4da964 - main - kern_execve(): avoid storing non-VDIR into p_textdvp 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.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 X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 930f2e4da96487f18a82f912275c6302c39b9bd2 Auto-Submitted: auto-generated Date: Thu, 30 Jul 2026 02:56:39 +0000 Message-Id: <6a6abd67.1a0ec.3ddbcc03@gitrepo.freebsd.org> The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=930f2e4da96487f18a82f912275c6302c39b9bd2 commit 930f2e4da96487f18a82f912275c6302c39b9bd2 Author: Konstantin Belousov AuthorDate: 2026-07-27 16:58:31 +0000 Commit: Konstantin Belousov CommitDate: 2026-07-30 02:56:30 +0000 kern_execve(): avoid storing non-VDIR into p_textdvp Reported by: Nick Price Tested by: pho Reviewed by: jah, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D58506 --- sys/kern/kern_exec.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 35eb22e03f48..352170d4f6f0 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -32,12 +32,12 @@ #include "opt_ktrace.h" #include "opt_vm.h" -#include #include #include #include #include #include +#include #include #include #include @@ -568,12 +568,46 @@ interpret: newbinname[nd.ni_cnd.cn_namelen] = '\0'; imgp->vp = newtextvp; + if (atomic_load_8(&newtextdvp->v_type) != VDIR) { + struct vnode *dvp1; + char *buf1; + size_t buf1len; + + /* + * The newtextdvp vnode might be not a + * directory when reclaimed or when the image + * is mounted over a regular file. In the + * latter case, try to resolve the containing + * directory. + * + * In any case, p_textdvp must be either a + * directory or reclaimed. + */ + VOP_UNLOCK(imgp->vp); + dvp1 = newtextdvp; + buf1len = MAXNAMLEN + 1; + buf1 = malloc(buf1len, M_TEMP, M_WAITOK); + error = vn_vptocnp(&dvp1, buf1, &buf1len); + if (error == 0) { + if (atomic_load_8(&dvp1->v_type) == VDIR) { + newtextdvp = dvp1; + } else { + vrele(dvp1); + newtextdvp = NULL; + } + } else { + newtextdvp = NULL; + } + free(buf1, M_TEMP); + vn_lock(imgp->vp, LK_SHARED | LK_RETRY); + } + /* * Do the best to calculate the full path to the image file. */ if (args->fname[0] == '/') { imgp->execpath = args->fname; - } else { + } else if (newtextdvp != NULL) { VOP_UNLOCK(imgp->vp); freepath_size = MAXPATHLEN; if (vn_fullpath_hardlink(newtextvp, newtextdvp,