From nobody Sun Feb 1 21:41:16 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 4f438r443Pz6QjFY for ; Sun, 01 Feb 2026 21:41:16 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4f438r1jHBz3GTk for ; Sun, 01 Feb 2026 21:41:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1769982076; 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=fs+/9XvTXYYjLhSPHjVFbK7kDZGzUe08KzsTThZSrp0=; b=UxP+5Z9jqHuqYIvP7CHkApW1XUgK4HrFcHeSr3utA3qcm027T2hYmC8l9T0QK0/c9XQE2n 57/Mws+mXgYkutbOzCX7+MXmM+jJAEEK6IQv2GBYbej5J17QCV1D1YNZjMAKbO/ZGgh6JK qGiTijisa9kwDNgZ1Im0kpxOCFTbKBjuAotVj64YXRl7O2zNACNwUsTy7ghBZx7VWrcbhu tAFPn2EOOiEbkc/Meoc48Qn8J2EMtrROr8+gkC6wypVoAKz7donfX880E389vLFifakue6 TRMBZoM4h1VH10M8mvTUxPo5ncou1HSIxcQ92UwyoFK8kortVFsdHU0JE1g7Yg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1769982076; a=rsa-sha256; cv=none; b=w0ezegcOkbMT/jaqzprwnIgOBbGInQiszKaVpHQYpObk60XHhF6UDDbO2axjuK/n5fty8Q mm9KNX2wV9oTm+bBnrVVMzWzIXFtazMeRfdpuucZEZZkWN8D7cRrg/UgbAF92JRZWrD7cT nf1rs/ygK1QFi8eO6qAna4zYnnD2kiL4Tu0nvLPoOwC30S/3lF9wgoaHb5bxPYJVQMYQWh YJLtfG153rmjqGU27OGL2zZJ6TDufzG+JLw95ES3x4J9fgeF9z0GWEEU8f1nhv+3NDz+fg vND3WcTS0/bXuj4lL2670PLd6TFg+F8L/YQ+ZJ0hIn7ROaXpx3o4tNxq33G6uw== 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=1769982076; 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=fs+/9XvTXYYjLhSPHjVFbK7kDZGzUe08KzsTThZSrp0=; b=ugwsLqzGedrFRvA/NjWtg4omwMTZHDo/6T561Q5VEyoC4ldPk7nrqIaKzHooMiH7XLN8BM aTHxeOL2pyS+/fSGhUixWkhZfVE+ciUh5k2aMk3suzpwrKeJh3//nx2Z6Zl0M8btlUPSqy WTciKis5Om3F/Ltvr4jqtyFchiM85UCrgupIKhXZgMsiyXdkEr03JKSTkarwrWX7bsqyM1 ANw3tPvmO6fEGFxiHuBDP9AvZabTb6fMPwRvjDKKkjbfpRhCZBRzkSoCmZZUeNbMUo/9Kb m0X6WNTk4n6uZkqWz1C3/qfYbysWhS+QFfeAlFGxwmU+AHwuXUvuo6H8f2Jjjw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4f438r1Fhpzxd7 for ; Sun, 01 Feb 2026 21:41:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3dc84 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 01 Feb 2026 21:41:16 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 70c55537c134 - stable/15 - posix_spawn: use rfork_thread on all arches 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 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/stable/15 X-Git-Reftype: branch X-Git-Commit: 70c55537c13433d358c63b4dc1e2dcfcc6ea6f10 Auto-Submitted: auto-generated Date: Sun, 01 Feb 2026 21:41:16 +0000 Message-Id: <697fc87c.3dc84.19d97a44@gitrepo.freebsd.org> The branch stable/15 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=70c55537c13433d358c63b4dc1e2dcfcc6ea6f10 commit 70c55537c13433d358c63b4dc1e2dcfcc6ea6f10 Author: Konstantin Belousov AuthorDate: 2026-01-26 16:09:18 +0000 Commit: Konstantin Belousov CommitDate: 2026-02-01 21:38:50 +0000 posix_spawn: use rfork_thread on all arches (cherry picked from commit 4daf2d3e7db53a113108f9a02ceaf5051d416184) --- lib/libc/gen/posix_spawn.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c index c64915078317..656c0f20f798 100644 --- a/lib/libc/gen/posix_spawn.c +++ b/lib/libc/gen/posix_spawn.c @@ -236,7 +236,6 @@ struct posix_spawn_args { #define PSPAWN_STACK_ALIGN(sz) \ (((sz) + PSPAWN_STACK_ALIGNBYTES) & ~PSPAWN_STACK_ALIGNBYTES) -#if defined(__i386__) || defined(__amd64__) /* * Below we'll assume that _RFORK_THREAD_STACK_SIZE is appropriately aligned for * the posix_spawn() case where we do not end up calling execvpe and won't ever @@ -245,7 +244,6 @@ struct posix_spawn_args { #define _RFORK_THREAD_STACK_SIZE 4096 _Static_assert((_RFORK_THREAD_STACK_SIZE % PSPAWN_STACK_ALIGNMENT) == 0, "Inappropriate stack size alignment"); -#endif static int _posix_spawn_thr(void *data) @@ -287,12 +285,14 @@ do_posix_spawn(pid_t *pid, const char *path, pid_t p; int pfd; bool do_pfd; -#ifdef _RFORK_THREAD_STACK_SIZE char *stack; - size_t cnt, stacksz; + size_t stacksz; +#if defined(__i386__) || defined(__amd64__) stacksz = _RFORK_THREAD_STACK_SIZE; if (use_env_path) { + size_t cnt; + /* * We need to make sure we have enough room on the stack for the * potential alloca() in execvPe if it gets kicked back an @@ -319,6 +319,9 @@ do_posix_spawn(pid_t *pid, const char *path, return (ENOMEM); stacksz = (((uintptr_t)stack + stacksz) & ~PSPAWN_STACK_ALIGNBYTES) - (uintptr_t)stack; +#else + stack = NULL; + stacksz = 0; #endif psa.path = path; psa.fa = fa; @@ -341,13 +344,16 @@ do_posix_spawn(pid_t *pid, const char *path, * a special property of the libthr rtld locks ensure that * rtld is operational in the child. In particular, libthr * rtld locks do not store owner' tid into the lock word. - */ -#ifdef _RFORK_THREAD_STACK_SIZE - /* - * x86 stores the return address on the stack, so rfork(2) cannot work - * as-is because the child would clobber the return address of the - * parent. Because of this, we must use rfork_thread instead while - * almost every other arch stores the return address in a register. + * + * x86 stores the return address on the stack, so rfork(2) + * cannot work as-is because the child would clobber the + * return address of the parent. Because of this, we must use + * rfork_thread instead. + * + * Every other architecture stores the return address in a + * register, the trivial rfork_thread() wrapper is provided + * for them. The only minor drawback is that the stack is + * temporarily allocated. */ if (do_pfd) { p = pdrfork_thread(&pfd, PD_CLOEXEC | (*sa)->sa_pdflags, @@ -357,16 +363,7 @@ do_posix_spawn(pid_t *pid, const char *path, &psa); } free(stack); -#else - if (do_pfd) { - p = pdrfork(&pfd, PD_CLOEXEC | (*sa)->sa_pdflags, RFSPAWN); - } else { - p = rfork(RFSPAWN); - } - if (p == 0) - /* _posix_spawn_thr does not return */ - _posix_spawn_thr(&psa); -#endif + /* * The above block should leave us in a state where we've either * succeeded and we're ready to process the results, or we need to