From nobody Thu Jul 30 02:56:39 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 4h9Ykh5fj9z6mQVP for ; Thu, 30 Jul 2026 02:56:44 +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 4h9Ykh3rB8z3JDd for ; Thu, 30 Jul 2026 02:56:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785380204; 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=wWk6oBsTdEXyHG11t63Q+GPzTFHrguCFkdqcn4e+Ll+laoK2bbXw8Zst4IJpX+ZjKB8ZU9 oo086n8e8F0ZwwbwZgMLap5d1JlnyVcU03u6n9jsZ8wyPHWZzbrs1iq3JJq3OVjM9zC2sX y3ORYfktB/XskLT73V+aEAsXUmajI9rJ8P5lFTLKm3oetz4ZmBaIqumYRMcBwCZUXN2wPS nh6xdAI+unpuVEAzR8CBr6YCNQJMMZ2ga3Q1iMFFKVlbmw++LA/8Q3jU7HjAKrkdbNsf+x WkOKgsJQ0Zr7crRHYv4iWcX/NftkQOqUzErMDKoDDx6YJ0rwvCNmN5uzmxvioQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785380204; a=rsa-sha256; cv=none; b=xjYoKwEiYVRn8BbSZ7LIACyfMlQ2WdaRtZsn0UfagEKTzRc1w2fzRvCE79boyaEe+NEcy9 FU4xKUwJJ8U/uRjso+bTIwSBWxrcHRLs0xNvOsVIqU+BZk9ea1SyjkoECh2f4AMXN6ELrn YH3Xo3QZFb9rI0N26HHgwEEX02H7Br6T0d1GXjUwR+W2KMzCyX19letPppB29gS2so8hPj c3uZuSP6S8inEc53leDQQq3beKKG3yK+NBnjNvQ2V4rCxUY/HAKblFbyLIxNf/g17Fm0Rh wgWOepH2tgl43L4gpAcjcOycJDde81FuONcXn8ZMoCZpLPOcdT1l2aQubcP+mg== 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=1785380204; 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=BJppwa9nWXQRigQk4Hn/I/LLn9O8zlrGSeaZXp+PkziJ8vZQF9Pt5dI+cEgG1YgSUWwIyO zxQZzH0qjHv8QOmdZHK/Ws+URejK76if6cV/TWGwhAS5c+DNOHg+9ydERK+fF8kYP3MAoD oyvjxEYKmNJZNX/RgifpaT2uRYIAfpVLEzBuVjPEDUyfbRAQybvykwl1K/kPrNWKZzTslu OC35VXYreWA4xgFP2xOqK9bxB9u+raA3UeJZdnq4IEKaZAiKGImpPFybsQXbMFgkH5Jixl ADYrY8b9ztzSeTOJI77mEg1VApeH+g8e5YDdcjnh+xoCFg2K8NRgSbOzOvXCww== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h9Ykh2M7hzvW5 for ; Thu, 30 Jul 2026 02:56:44 +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 all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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,