Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260923234714.GB23438@brightrain.aerifal.cx>
Date: Wed, 23 Sep 2026 19:47:14 -0400
From: Rich Felker <dalias@...c.org>
To: Trevor Gross <tg@...vorgross.com>
Cc: Alejandro Colomar <alx@...nel.org>, linux-man@...r.kernel.org,
	libc-alpha@...rceware.org, musl@...ts.openwall.com
Subject: Re: [PATCH 2/2] man/man2/fork.2: Document glibc and musl
 relaxed fork->exec AS requirements

On Wed, Sep 23, 2026 at 11:38:19PM +0000, Trevor Gross wrote:
> Link: https://lore.kernel.org/linux-man/20260923013428.GT23438@brightrain.aerifal.cx/ [1]
> Link: https://git.musl-libc.org/cgit/musl/commit/?id=167390f05564e0a4d3fcb4329377fd7743267560
> Signed-off-by: Trevor Gross <tg@...vorgross.com>
> ---
>  man/man2/fork.2 | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/man/man2/fork.2 b/man/man2/fork.2
> index fc78f786b..336c17448 100644
> --- a/man/man2/fork.2
> +++ b/man/man2/fork.2
> @@ -147,10 +147,17 @@ may be helpful for dealing with problems that this can cause.
>  After a
>  .BR fork ()
>  in a multithreaded program,
> -the child can safely call only async-signal-safe functions (see
> +POSIX specifies that the child can safely call only async-signal-safe
> +functions (see
>  .BR signal\-safety (7))
> -until such time as it calls
> +until it calls
>  .BR execve (2).
> +On glibc and musl libc, this is relaxed;
> +it is safe to call non-async-signal-safe functions in the time between
> +.BR fork ()
> +and
> +.BR exec ()
> +\&.
>  .IP \[bu]
>  The child inherits copies of the parent's set of open file descriptors.
>  Each file descriptor in the child refers to the same
> -- 
> 2.50.1 (Apple Git-155)

While glibc has taken measures to make this mostly work, especially
malloc-after-fork, I don't think glibc has an intentional model for
ensuring that arbitrary libc functions work right in the child of a
multithreaded fork. Before accepting such a man page patch, we should
at least get an official position from glibc on whether they claim
this property or at least aim for it.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.