From nobody Thu Jul 30 14:32:54 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 4h9sB42lYqz6mPCJ for ; Thu, 30 Jul 2026 14:33:00 +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 4h9sB40ZfCz3hSW for ; Thu, 30 Jul 2026 14:33:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785421980; 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=m+oPOQzsF6e7TnHjZ+feGDufHZIaLtuhzrUp7l10aMc=; b=pjkehFizjDRnUbp1mqdZLhueTYRuIycdT6xtBEoHgDEbIeSN6jnDI7xpUF4vldXiZg4onP gkmMCjxByMKMTFC7zaWJqqEIQbHitZ5sMRCNORVKDXngW3x7i3SRNRdDanAubiD8dn084s iRxIEDUa598lTIes224ax099dFpaKfNwnGwnY6cSRjPfzV/DNVQMu1KXG5vTLz6sZSUCj/ 1ZrzfqgKI2q2cG7Cals28PXY0Ngnv9DCRSLGNyIzR2U0bj7U4J5NcHHzqw/Z2TXy/38lOx 8VE9+w6bH7q0v1J9zqAYh9H/gxTDwuiocT+ydYpGV0KEVCqSkljMFoCZsxjk/g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785421980; a=rsa-sha256; cv=none; b=SsvN56M8A1OweojeAJh8tIgZ9rC3/XZip9WyEsGWrkgbMlYEIrOM7dv2aMv8P0XopICM1L eEIYnE/G0I28LJmCa1UlBqghntY11rWyXNxEUGZc/3gH7cP02z8I6mSXIjLZ7AxBkedy8H IPWi6VuV2gV8ByUpY1vXzl2ToxXA5A0WezOc/lhKUnMCJlOrld27+CqRVynyGRqQz4L/mw oPMDSaEVy8f58quls9hb9dCHwZl9pqR6g9ivwf/WsTq+Ly1+frW9uzJqUJDCOwZexfCHOd 2eelO8KVhX1Kw9EmivrENJwyNlQxslCYMvv36cBp60gfzdKlmiKgEfcS802kAA== 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=1785421980; 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=m+oPOQzsF6e7TnHjZ+feGDufHZIaLtuhzrUp7l10aMc=; b=UufbAgWuCdeS1k5cTkmKH8tAIkkk1vNpYodT0+lfBo3cGXIAX2XdEp1Xe+/XCAfkLbwghb dz+U1AUBEirr97UlO14QwIUC4JwNNsRTWgl5PIU4CsFlF5WA0AMGPXEUDO8/F4t7fBeW7Z lYSknutxS+Ujh+TRdzhOy4U2zWvUWCj86pvrZ+z3CpSYfIKrY9D0Kwxf/UTS2QTY642+mz G3TR5iFFtH0C7j6994J2cgOo8PAJOM7j9w936Y0anaujUwgJFjH4rAXXtF8NtfHB31Hak2 8RZiGe/C6paaQUlybs2m4KdKkQhOyHmnTQbpKwlKJFzcvhWoOEeGSnteJsfuaQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h9sB36gDGz27Z for ; Thu, 30 Jul 2026 14:32:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2067f by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 30 Jul 2026 14:32:54 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Cochard Subject: git: 727a83e90098 - main - tests/procdesc: Fix race in pdopenpid_pdwait_only_one 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: olivier X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 727a83e90098e1c0fc4acdcf9b8099a70e6ea2b2 Auto-Submitted: auto-generated Date: Thu, 30 Jul 2026 14:32:54 +0000 Message-Id: <6a6b6096.2067f.30c4222c@gitrepo.freebsd.org> The branch main has been updated by olivier: URL: https://cgit.FreeBSD.org/src/commit/?id=727a83e90098e1c0fc4acdcf9b8099a70e6ea2b2 commit 727a83e90098e1c0fc4acdcf9b8099a70e6ea2b2 Author: Olivier Cochard AuthorDate: 2026-07-30 14:28:42 +0000 Commit: Olivier Cochard CommitDate: 2026-07-30 14:28:42 +0000 tests/procdesc: Fix race in pdopenpid_pdwait_only_one The child exited immediately after pdfork(), so the parent's pdopenpid() could catch it mid-exit (P_WEXIT) and fail with EBUSY. Block the child on a pipe until the parent has opened the second descriptor, then release it Approved by: markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D58546 --- tests/sys/kern/procdesc.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/sys/kern/procdesc.c b/tests/sys/kern/procdesc.c index 541f15b49338..1feaef34e2cb 100644 --- a/tests/sys/kern/procdesc.c +++ b/tests/sys/kern/procdesc.c @@ -519,16 +519,29 @@ ATF_TC_WITHOUT_HEAD(pdopenpid_pdwait_only_one); ATF_TC_BODY(pdopenpid_pdwait_only_one, tc) { pid_t child; - int fd1, fd2, status; + int fd1, fd2, pip[2], status; + + ATF_REQUIRE_EQ(pipe(pip), 0); child = pdfork(&fd1, PD_DAEMON); ATF_REQUIRE_MSG(child >= 0, "pdfork: %s", strerror(errno)); - if (child == 0) + if (child == 0) { + char c; + + close(pip[1]); + /* Block until the parent has opened the second fd. */ + (void)read(pip[0], &c, 1); _exit(42); + } + ATF_REQUIRE(close(pip[0]) == 0); + /* Open the second fd while the child is still alive. */ fd2 = pdopenpid(child, 0); ATF_REQUIRE_MSG(fd2 >= 0, "pdopenpid: %s", strerror(errno)); + /* Release the child so that it exits. */ + ATF_REQUIRE(close(pip[1]) == 0); + /* Collect via the first fd. */ ATF_REQUIRE_MSG(pdwait(fd1, &status, WEXITED, NULL, NULL) == 0, "pdwait(fd1): %s", strerror(errno));