]> Cypherpunks.ru repositories - gostls13.git/commit
syscall: serialize locks on ForkLock on platforms where forkExecPipe is not atomic
authorBryan C. Mills <bcmills@google.com>
Fri, 30 Jun 2023 15:50:47 +0000 (11:50 -0400)
committerGopher Robot <gobot@golang.org>
Mon, 10 Jul 2023 19:19:59 +0000 (19:19 +0000)
commit07ede7a54379eef959cf29af5a87ea19c78a31fd
treec5492e88cd6f4532628853acc2c764f855a2a0bb
parent7dc62f3bda96359cc1904f4ea387f9a1c82c9f9d
syscall: serialize locks on ForkLock on platforms where forkExecPipe is not atomic

In CL 421441, we changed syscall to allow concurrent calls to
forkExec.

On platforms that support the pipe2 syscall that is the right
behavior, because pipe2 atomically opens the pipe with CLOEXEC already
set.

However, on platforms that do not support pipe2 (currently aix and
darwin), syscall.forkExecPipe is not atomic, and the pipes do not
initially have CLOEXEC set. If two calls to forkExec proceed
concurrently, a pipe intended for one child process can be
accidentally inherited by the other. If the process is long-lived, the
pipe can be held open unexpectedly and prevent the parent process from
reaching EOF reading the child's status from the pipe.

Fixes #61080.
Updates #23558.
Updates #54162.

Change-Id: I83edcc80674ff267a39d06260c5697c654ff5a4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/507355
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
src/os/exec/exec_test.go
src/syscall/exec_linux.go
src/syscall/exec_unix.go
src/syscall/forkpipe.go
src/syscall/forkpipe2.go