From 07ede7a54379eef959cf29af5a87ea19c78a31fd Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Fri, 30 Jun 2023 11:50:47 -0400 Subject: 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 Reviewed-by: Ian Lance Taylor Run-TryBot: Bryan Mills Auto-Submit: Bryan Mills --- src/syscall/exec_linux.go | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/syscall/exec_linux.go') diff --git a/src/syscall/exec_linux.go b/src/syscall/exec_linux.go index feb1e26432..dfbb38ac16 100644 --- a/src/syscall/exec_linux.go +++ b/src/syscall/exec_linux.go @@ -641,11 +641,6 @@ childerror: } } -// Try to open a pipe with O_CLOEXEC set on both file descriptors. -func forkExecPipe(p []int) (err error) { - return Pipe2(p, O_CLOEXEC) -} - func formatIDMappings(idMap []SysProcIDMap) []byte { var data []byte for _, im := range idMap { -- cgit v1.3