From nobody Tue Jul 7 20:57:47 2026 X-Original-To: dev-commits-src-branches@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 4gvtph0w92z6kShT for ; Tue, 07 Jul 2026 20:57:48 +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 4gvtph0SHfz3lts for ; Tue, 07 Jul 2026 20:57:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1783457868; 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=1YBtaFHC6gAihc9misiTB23cteNiWJMJ7E1l25blyOk=; b=Rw6z8E7NwdESsLyT+3E2UoCRWsYY6BRPbl9/rVyaXnieJ4y7RkyLDcz5AgQHZHztNoZRVy 64vw0+Cgovu11zQx/xsQg4SND0tspW7Xw636ZgCi5n+2Ox/xJwGv9QXyrWuzCIQLEYiRKl DkN6FYEGUam7OyL7l9Arsz6nJTqZt6yurZGmm2JoAlU6I7l+TMyWyfe/SSgq8wKernflmY 0kim9TqFtm9jqhlTddeUvo2nAbtCGaxSwVHsCKfG+pF4NOTEbzUlY3zTrKR1DFLPUoKHO/ 153Z1k3ipwowtcnjSDnfb3wg12PjXlstqEIMLY+juSe+IZ4L6DKC/IXdTQFtjg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1783457868; a=rsa-sha256; cv=none; b=av9PA6M+SX8zd0OMlDW5aSIi1z4gcDmfjzGy1c11BPdTl8XPTlerHsJ4ZNLHfIUZY/XIrx qgLbzLuoQxd1ZfQNWVPIFsUpIiAv7zKQl0Zyh3AlxAveWZLDrhVlnIX1PmJN7Mc8wdtmit ZxAFJTqSitGaXglGyZWxQFPCGdwPR3CLrDhS2H6MoWGy0qfnuNZIb8/88BVjJK7h/oNcgS Ten2OV2/OonztfC6HLo6BEtHKsqNb5oHjmucR8X+U3ce+Nq6Xr7ilzRDpfSf9iBiCAeVSQ xcfKcqUgPrccfrIVegpXSpEbCX5HyLeehFGHk0FtLN670A1pQvRsHKzIkt8YTQ== 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=1783457868; 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=1YBtaFHC6gAihc9misiTB23cteNiWJMJ7E1l25blyOk=; b=Rtz3o8mF1w+NPDl6QDZmRElcmsAbSSwx6TuEOQyJErEhN+LZ+6WmL3Lh9J1KZSEe+isCag K16QXcHao3lhz+N6eR+Im8ePw8h9svYAqgbjJVsMKIcGVSJJaeUY2oa1h+/euNgkM1ZuzQ CfuqUUg5f0RazIL9USKWP3LWreSqy8N7OyxIZeooOqAJxJd7Ru+H4ExlvUorEqf0UUFaWL FH94cEEe9GPkTA8d7jj4iHOkseNwXggJEdt4x1BnrxN+hay9z1+x5e/MBYHncWVzagwxRa fuFr02bhbrOr+GbQF723DHoJAJhRGHEOxhNEhcOeksQsM5jMpvXf0Oy9AKZcmw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gvtpg6JP6zrsJ for ; Tue, 07 Jul 2026 20:57:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 472f4 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 07 Jul 2026 20:57:47 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 8adf49dac1a9 - stable/15 - tests: Fix race condition in aslr_setuid List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 8adf49dac1a937c9a8dc6937d6d23af14df7597a Auto-Submitted: auto-generated Date: Tue, 07 Jul 2026 20:57:47 +0000 Message-Id: <6a4d684b.472f4.78c6cda6@gitrepo.freebsd.org> The branch stable/15 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=8adf49dac1a937c9a8dc6937d6d23af14df7597a commit 8adf49dac1a937c9a8dc6937d6d23af14df7597a Author: Dag-Erling Smørgrav AuthorDate: 2026-06-22 13:23:31 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-07-07 07:06:55 +0000 tests: Fix race condition in aslr_setuid Use a cloexec pipe to block the parent until the child is ready. While here, redirect the output from ping to /dev/null, and mark the test as requiring the inet feature since we ping the IPv4 loopback. PR: 296116 MFC after: 1 week Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D57734 (cherry picked from commit 080a4087014e1d19136cc77028019d98b5c69e1e) tests: Fix race condition in aslr_setuid, take 2 Instead of a cloexec pipe, ingest ping's stdout and block until it has printed its initial summary, then close the pipe and return to the main test loop. Run ping in quiet mode so it won't mind that stdout is gone. PR: 296116 MFC after: 1 week Fixes: 080a4087014e ("tests: Fix race condition in aslr_setuid") Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D57763 (cherry picked from commit 86950cf9ffe89b7978fca019019692b3ea492044) --- tests/sys/kern/Makefile | 1 + tests/sys/kern/aslr.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile index 03aca4f19a56..ab68fbf11a6e 100644 --- a/tests/sys/kern/Makefile +++ b/tests/sys/kern/Makefile @@ -94,6 +94,7 @@ PROGS+= coredump_phnum_helper PROGS+= pdeathsig_helper PROGS+= sendfile_helper +CFLAGS.aslr+= -I${SRCTOP}/tests LIBADD.aslr+= util LIBADD.copy_file_range+= md LIBADD.jail_lookup_root+= jail util diff --git a/tests/sys/kern/aslr.c b/tests/sys/kern/aslr.c index 13038054603c..966ea5c3b83a 100644 --- a/tests/sys/kern/aslr.c +++ b/tests/sys/kern/aslr.c @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -19,6 +20,7 @@ #include #include +#include "freebsd_test_suite/macros.h" /* * Spawn an unprivileged child with ASLR force-disabled, which then execs @@ -27,19 +29,22 @@ static pid_t spawn_ping(const atf_tc_t *tc) { + char line[64]; const char *user; struct passwd *passwd; pid_t child; - int arg, error; + int arg, error, io[2]; user = atf_tc_get_config_var(tc, "unprivileged_user"); passwd = getpwnam(user); ATF_REQUIRE(passwd != NULL); + ATF_REQUIRE(pipe2(io, O_CLOEXEC) == 0); child = fork(); ATF_REQUIRE(child >= 0); if (child == 0) { - if (seteuid(passwd->pw_uid) != 0) + if (dup2(io[1], STDOUT_FILENO) != STDOUT_FILENO || + seteuid(passwd->pw_uid) != 0) _exit(1); arg = PROC_ASLR_FORCE_DISABLE; @@ -47,10 +52,12 @@ spawn_ping(const atf_tc_t *tc) if (error != 0) _exit(2); - execl("/sbin/ping", "ping", "127.0.0.1", NULL); + execl("/sbin/ping", "ping", "-q", "127.0.0.1", NULL); _exit(127); } - usleep(500000); /* XXX-MJ */ + ATF_REQUIRE(close(io[1]) == 0); + ATF_REQUIRE(read(io[0], line, sizeof(line)) > 0); + ATF_REQUIRE(close(io[0]) == 0); return (child); } @@ -98,6 +105,7 @@ ATF_TC_BODY(aslr_setuid, tc) pid_t child, pid; int arg, error, st; + ATF_REQUIRE_FEATURE("inet"); if (!atf_tc_has_config_var(tc, "unprivileged_user")) atf_tc_skip("unprivileged_user not set");