From nobody Thu Jul 30 14:32:54 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 4h9s9z1yP6z6mPTC for ; Thu, 30 Jul 2026 14:32:55 +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 4h9s9y6bRzz3hF9 for ; Thu, 30 Jul 2026 14:32:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1785421974; 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=MsDrOko8I4twe0zpCrQWENNrRo8pJna4CZjSPDdxJO3PhbBgUmjUJ7r27rBYGyZnm3MnFL kFFkcFf3QbbZOxayiBdMtNFTBgRsFaXDhJbr3Myu+0/tEnzvpO3kCOVZw/vcDXW/v6u3vO y/j23PTlzG9k9IUZaHOJ+KZ+16G84gQch9oJgVhb9CPVVy++5ikZM/MXSTvnqdFFbK+4r9 mNxT6wmDtphPnxorrQ3+G/spXh73CHOgEXnv4JG4en4JKmhHfYEVL0xgZpUmo0Si6FV7Y1 FjdAtTFz/C3lj8wuTnm2ejGfZU854SfFQC/CIW3taBTRmkyva3clJhLmVJ2ziQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1785421974; a=rsa-sha256; cv=none; b=YBSxi6v1HJPW2yJdoIEC1oQ/iRpg1fcdPsjduMTr5eUpN4iKCyhjDHDGbAXEA2GlPyWlak gTPXBFNwj6bgtqOW65m80fYBDCQP/Tmb9Sfc2xiO7hl/MXBSA6aHpBb2Mt/wdnIxSBJRa5 cFUf/aTf8V+ujnhyB7d2XA3/l+4Knq2pvd86KHmuqUUDR80RKcsvxiSMvoPGMLImRZcU3k /N4Yza6Qfpedg0PAqw5JgLPA9aoq4mx2TvOGCbgdCqiRV7xKYW7PAYm1wmY3qHSGek0mbb g0N5FF9at1Zh2OGTEuXamLcsbGTLHqsHXEiK1dvGeDfodWMDzBLH5vA7VD9DZQ== 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=1785421974; 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=XUG5wXxEg5QM7Fz9apmFPRxkvouAxu7ezz4lbkbMSr47UvcnPcQyD7gc+SMvGjlTcSjfjc UjIruXmzlfPVG+0QEkHVaKc1SMiWQ3HsE5ZeBX3FmpgxwJePSKz4MpPgEzfvm0mRtoroID nb/SK/00pj3UXDc47f/DXlw02WeiqfyFAIxga8MxEfXCuV2R8U418bI1duiCkttpjJD/lt DSFpB+neTs0HeL2c5Y3iGlsmhxr3U+NhvakbEWHf5pq/arl44ckn2/2kN5OZ7FvnmTAuAt zTWxEr3RC0TQoe4l0uvAi+vSLrXoqNdwki5nnzZq8+f8k3ZfcgCeHKmCzyKsiw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4h9s9y513Dz29g for ; Thu, 30 Jul 2026 14:32:54 +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 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: 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));