summaryrefslogtreecommitdiff
path: root/src/syscall
Commit message (Collapse)AuthorAgeFilesLines
* os, syscall: permit setting mtime to Unix 0 on WindowsIan Lance Taylor2023-05-161-2/+5
| | | | | | | | | | | | | This edge case was accidentally broken by CL 219638. Change-Id: I673b3b580fbe379a04f8650cf5969fe9bce83691 Reviewed-on: https://go-review.googlesource.com/c/go/+/495036 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
* os, syscall: support ill-formed UTF-16 strings on Windowsqmuntal2023-05-155-21/+327
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Windows UTF-16 strings can contain unpaired surrogates, which can't be decoded into a valid UTF-8 string. This file defines a set of functions that can be used to encode and decode potentially ill-formed UTF-16 strings by using the [the WTF-8 encoding](https://simonsapin.github.io/wtf-8/). WTF-8 is a strict superset of UTF-8, i.e. any string that is well-formed in UTF-8 is also well-formed in WTF-8 and the content is unchanged. Also, the conversion never fails and is lossless. The benefit of using WTF-8 instead of UTF-8 when decoding a UTF-16 string is that the conversion is lossless even for ill-formed UTF-16 strings. This property allows to read an ill-formed UTF-16 string, convert it to a Go string, and convert it back to the same original UTF-16 string. Fixes #59971 Change-Id: Id6007f6e537844913402b233e73d698688cd5ba6 Reviewed-on: https://go-review.googlesource.com/c/go/+/493036 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Paul Hampson <Paul.Hampson@Pobox.com>
* syscall: implement wasip1 SetNonblock and IsNonblockChris O'Hara2023-05-113-4/+38
| | | | | | | | | | | | | | | | | | | | | Allows for the NONBLOCK file descriptor flag to be set and queried on wasip1. syscall.SetNonblock uses the fd_fdstat_set_flags WASI system call and unix.IsNonblock uses the fd_fdstat_get system call. This is a prerequisite for non-blocking I/O support. Change-Id: I2bf79fd57142b2ec53eed3977d9aac8c6337eb80 Reviewed-on: https://go-review.googlesource.com/c/go/+/493356 Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Julien Fabre <ju.pryz@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Achille Roussel <achille.roussel@gmail.com>
* os: make Chtimes accept empty time values to skip file time modificationConstantin Konstantinidis2023-05-113-6/+48
| | | | | | | | | | | | | | | | Empty time value time.Time{} leaves the corresponding time of the file unchanged. Fixes #32558 Change-Id: I1aff42f30668ff505ecec2e9509d8f2b8e4b1b6a Reviewed-on: https://go-review.googlesource.com/c/go/+/219638 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
* all: fix a lot of commentscui fliter2023-05-101-1/+1
| | | | | | | | | | | | | Fix comments, including duplicate is, wrong phrases and articles, misspellings, etc. Change-Id: I8bfea53b9b275e649757cc4bee6a8a026ed9c7a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/493035 Reviewed-by: Benny Siegert <bsiegert@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
* syscall,internal/poll: move pipe check from syscall.Seek to callersqmuntal2023-05-091-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On Windows, syscall.Seek is a thin wrapper over SetFilePointerEx [1], which does not work on pipes, although it doesn't return an error on that case. To avoid this undefined behavior, Seek defensively calls GetFileType and errors if the type is FILE_TYPE_PIPE. The problem with this approach is that Seek is a low level foundational function that can be called many times for the same file, and the additional cgo call (GetFileType) will artificially slow down seek operations. I've seen GetFileType to account for 10% of cpu time in seek-intensive workloads. A better approach, implemented in this CL, would be to move the check one level up, where many times the file type is already known so the GetFileType is unnecessary. The drawback is that syscall.Seek has had this behavior since pipes where first introduced to Windows in https://codereview.appspot.com/1715046 and someone could be relying on it. On the other hand, this behavior is not documented, so we couldn't be breaking any contract. [1] https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-setfilepointerex Change-Id: I7602182f9d08632e22a8a1635bc8ad9ad35a5056 Reviewed-on: https://go-review.googlesource.com/c/go/+/493626 Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* syscall: reduce memory allocated by UTF16FromStringFrediano Ziglio2023-05-042-3/+35
| | | | | | | | | | | | | | | The function allocated a buffer larger than needed. Fixes #59967. Signed-off-by: Frediano Ziglio <frediano.ziglio@nextdlp.com> Change-Id: I5f30a135acf5f27d6c2ef4bc4abef5144da4dc94 Reviewed-on: https://go-review.googlesource.com/c/go/+/492575 Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* syscall: fix opening of directories on wasip1Achille Roussel2023-04-301-4/+83
| | | | | | | | | | | | | | | | | | | Go programs targeting GOOS=wasip1 were failing to open directories when executed with runtimes like wasmtime or wasmedge due to requesting rights for operations that are not supported on directories such as fd_read, fd_write, etc... This change addresses the issue by performing a second path_open when observing EISDIR, and masking the requested rights to only ask for permissions to perform operations supported by a directory. Change-Id: Ibf65acf4a38bc848a649f41dbd026507d8b63c82 Reviewed-on: https://go-review.googlesource.com/c/go/+/490755 Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: remove wasip1 O_DIRECTORY workaroundAchille Roussel2023-04-281-23/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | Wasmtime used to error when opening a directory without passing the O_DIRECTORY flag, which required doing a stat to determine whether to inject the flag prior to opening any file. The workaround was subject to races since the stat and open calls were not atomic. Wasmtime fixed the issue in v8.0.1. For details see: - https://github.com/bytecodealliance/wasmtime/pull/4967 - https://github.com/bytecodealliance/wasmtime/pull/6163 - https://github.com/bytecodealliance/wasmtime/releases/tag/v8.0.1 Change-Id: I0f9fe6a696024b70fffe63b83e8f61e48acd0c4a Reviewed-on: https://go-review.googlesource.com/c/go/+/489955 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
* syscall: add a sync.Pool for a NetlinkRIB scratch bufferBrad Fitzpatrick2023-04-181-3/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The syscall.NetlinkRIB signature means it necessarily allocates but this changes makes it allocate a bit less. For example, in the net package: name old time/op new time/op delta Interfaces-8 59.1µs ± 3% 57.3µs ± 2% -3.02% (p=0.000 n=10+10) InterfaceByIndex-8 53.1µs ± 5% 50.6µs ± 2% -4.81% (p=0.000 n=10+10) InterfaceByName-8 59.3µs ± 2% 57.4µs ± 1% -3.29% (p=0.000 n=10+10) InterfaceAddrs-8 105µs ± 1% 101µs ± 1% -4.22% (p=0.000 n=10+9) InterfacesAndAddrs-8 38.2µs ± 3% 36.3µs ± 2% -4.98% (p=0.000 n=10+10) InterfacesAndMulticastAddrs-8 152µs ± 2% 154µs ± 6% ~ (p=0.105 n=10+10) name old alloc/op new alloc/op delta Interfaces-8 22.8kB ± 0% 18.7kB ± 0% -17.90% (p=0.000 n=10+9) InterfaceByIndex-8 16.2kB ± 0% 12.1kB ± 0% -25.22% (p=0.000 n=10+10) InterfaceByName-8 22.8kB ± 0% 18.8kB ± 0% -17.85% (p=0.000 n=10+10) InterfaceAddrs-8 36.6kB ± 0% 28.5kB ± 0% -22.28% (p=0.000 n=10+10) InterfacesAndAddrs-8 9.60kB ± 0% 5.51kB ± 0% -42.59% (p=0.000 n=10+7) InterfacesAndMulticastAddrs-8 141kB ± 0% 141kB ± 0% ~ (all equal) name old allocs/op new allocs/op delta Interfaces-8 53.0 ± 0% 52.0 ± 0% -1.89% (p=0.000 n=10+10) InterfaceByIndex-8 28.0 ± 0% 27.0 ± 0% -3.57% (p=0.000 n=10+10) InterfaceByName-8 54.0 ± 0% 53.0 ± 0% -1.85% (p=0.000 n=10+10) InterfaceAddrs-8 155 ± 0% 153 ± 0% -1.29% (p=0.000 n=10+10) InterfacesAndAddrs-8 38.0 ± 0% 37.0 ± 0% -2.63% (p=0.000 n=10+10) InterfacesAndMulticastAddrs-8 77.0 ± 0% 77.0 ± 0% ~ (all equal) Signed-off-by: Brad Fitzpatrick <bradfitz@golang.org> Change-Id: Ic3278b2c000af78d7ed816645463c3b7ff0c90ca Reviewed-on: https://go-review.googlesource.com/c/go/+/485455 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* wasm: restrict supported types in go:wasmimport function signaturesAchille Roussel2023-04-132-46/+54
| | | | | | | | | | | | | | | | | | | | | | | | | Changes the set of types supported in functions declared with the go:wasmimport directive to only allow 32 bits and 64 bits integers and floats, as well as unsafe.Pointer in parameters only. Both the compiler code and the standard library are updated because the new restrictions require modifying the use of go:wasmimport in the syscall and runtime packages. In preparation of enabling packages outside of the standard library to use the go:wasmimport directive, the error messages are modified to carry more context and use ErrorfAt instead of Fatalf to avoid printing the compiler stack trace when a function with an invalid signature is encountered. Fixes #59156 Change-Id: Ied8317f8ead9c28f0297060ac35a5b5255ab49db Reviewed-on: https://go-review.googlesource.com/c/go/+/483415 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
* syscall: implement Fchdir on Windowsqmuntal2023-04-122-1/+52
| | | | | | | | | | | | | | | | | This CL adds support for os.File.Chdir() on Windows by implementing syscall.Fchdir, which is internally used by Chdir. Windows does not provide a function that sets the working directory using a file handle, so we have to fallback to retrieving the file handle path and then use it in SetCurrentDirectory. Change-Id: I2ae93575e50411e5a9426ea531541958d7c9e812 Reviewed-on: https://go-review.googlesource.com/c/go/+/480135 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
* syscall: add a Go directive "go:nocheckptr" to forkAndExecInChild1root2023-04-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | forkAndExecInChild1 func must not acquire any locks in child, because they might have been locked at the time of the fork. This implies to no rescheduling, no malloc calls, and no new stack segments. So, doing a "checkptrAlignment" is bad here, because checkptr functions added by the instrumentation could grow the stack, which should not be done between fork and exec calls. Hence using a Go directive "go:nocheckptr" to forkAndExecInChild1 func,so that the compiler should not do "checkptrAlignment" when functions marked with "go:norace". This race detection bug was caught in go 1.21 on s390x. Running a "./race.bash" script from "go/src" directory failed and the bug details are provided in issue link mentioned below. Fixes #58785 Change-Id: I254091368b0789d886acdf26f8aa8d8f5a986b24 Reviewed-on: https://go-review.googlesource.com/c/go/+/481415 Auto-Submit: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* internal: add wasip1 supportJohan Brandhorst-Satzkorn2023-04-071-0/+3
| | | | | | | | | | | | | | | | | | For #58141 Co-authored-by: Richard Musiol <neelance@gmail.com> Co-authored-by: Achille Roussel <achille.roussel@gmail.com> Co-authored-by: Julien Fabre <ju.pryz@gmail.com> Co-authored-by: Evan Phoenix <evan@phx.io> Change-Id: I1488726e5b43cd21c5f83900476afd2fb63d70c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/479622 Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
* syscall: add remaining wasip1 filesJohan Brandhorst-Satzkorn2023-04-0610-3/+1702
| | | | | | | | | | | | | | | | | | Implements filesystem, networking and os interactions. For #58141 Co-authored-by: Richard Musiol <neelance@gmail.com> Co-authored-by: Achille Roussel <achille.roussel@gmail.com> Co-authored-by: Julien Fabre <ju.pryz@gmail.com> Co-authored-by: Evan Phoenix <evan@phx.io> Change-Id: If5c43ad5bd2955e6d2d4e2822fd68bce89ca786c Reviewed-on: https://go-review.googlesource.com/c/go/+/479619 Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com>
* all: fix misuses of "a" vs "an"cui fliter2023-04-041-2/+2
| | | | | | | | | | | | | | Fixes the misuse of "a" vs "an", according to English grammatical expectations and using https://www.a-or-an.com/ Change-Id: I53ac724070e3ff3d33c304483fe72c023c7cda47 Reviewed-on: https://go-review.googlesource.com/c/go/+/480536 Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
* syscall: let errors.ErrUnsupported match ERROR_NOT_SUPPORTED and ↵Tobias Klauser2023-03-161-2/+8
| | | | | | | | | | | | | | | | | ERROR_CALL_NOT_IMPLEMENTED These error codes are returned on windows in case a particular functions is not supported. Updates #41198 Change-Id: Ic31755a131d4e7c96961ba54f5bb51026fc7a563 Reviewed-on: https://go-review.googlesource.com/c/go/+/476916 Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: let ENOSYS, ENOTSUP and EOPNOTSUPP implement errors.ErrUnsupportedTobias Klauser2023-03-164-12/+26
| | | | | | | | | | | | | | | | | | | As suggested by Bryan, also update (Errno).Is on windows to include the missing oserror cases that are covered on other platforms. Quoting Bryan: > Windows syscalls don't actually return those errors, but the dummy Errno > constants defined on Windows should still have the same meaning as on > Unix. Updates #41198 Change-Id: I15441abde4a7ebaa3c6518262c052530cd2add4b Reviewed-on: https://go-review.googlesource.com/c/go/+/476875 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* syscall: let EPLAN9 and EWINDOWS implement errors.ErrUnsupportedTobias Klauser2023-03-152-0/+5
| | | | | | | | | | | | | | | As suggested by Bryan. This should fix the failing TestIPConnSpecificMethods on plan9 after CL 476217 was submitted. For #41198 Change-Id: I18e87b3aa7c9f7d48a1bd9c2819340acd1d2ca4e Reviewed-on: https://go-review.googlesource.com/c/go/+/476578 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: restore original NOFILE rlimit in child processIan Lance Taylor2023-03-1560-73/+343
| | | | | | | | | | | | | If we increased the NOFILE rlimit when starting the program, restore the original rlimit when forking a child process. For #46279 Change-Id: Ia5d2af9ef435e5932965c15eec2e428d2130d230 Reviewed-on: https://go-review.googlesource.com/c/go/+/476097 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Bypass: Ian Lance Taylor <iant@google.com>
* os, syscall: move rlimit code to syscallIan Lance Taylor2023-03-154-0/+100
| | | | | | | | | | | | | | | | | | | | | In CL 393354 the os package was changed to raise the open file rlimit at program start. That code is not inherently tied to the os package. This CL moves it into the syscall package. This is in preparation for future changes to restore the original soft rlimit when exec'ing a new program. For #46279 Change-Id: I981401b0345d017fd39fdd3dfbb58069be36c272 Reviewed-on: https://go-review.googlesource.com/c/go/+/476096 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* internal/testenv, syscall: move isNotSupported to internal/testenvTobias Klauser2023-03-151-48/+13
| | | | | | | | | | | | | | | This allows to use this helper function in packages other than syscall, namely package net. For #58114 Change-Id: I72c59ab013e9195801ff1315019ae1aef4396287 Reviewed-on: https://go-review.googlesource.com/c/go/+/476216 Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* syscall: handle errors.ErrUnsupported in isNotSupportedTobias Klauser2023-03-151-3/+3
| | | | | | | | | | | | Updates #41198 Change-Id: Ifed913f6088b77abc7a21d2a79168a20799f9d0e Reviewed-on: https://go-review.googlesource.com/c/go/+/475857 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
* syscall: use clone3 syscall with CLONE_NEWTIMETobias Klauser2023-03-132-0/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | | CLONE_NEWTIME can only be used with the clone3 and unshare system calls, see https://github.com/torvalds/linux/commit/769071ac9f20b6a447410c7eaa55d1a5233ef40c: > All available clone flags have been used, so CLONE_NEWTIME uses the highest > bit of CSIGNAL. It means that it can be used only with the unshare() and > the clone3() system calls. The clone3 syscall was added in Linux kernel version 5.3 and CLONE_NEWTIME was added in version 5.6. However, it was non-functional until version 6.3 (and stable versions with the corresponding fix [1]). [1] https://lore.kernel.org/lkml/20230308105126.10107-1-tklauser@distanz.ch/ In case CLONE_NEWTIME is set in SysProcAttr.Cloneflags on an unsupported kernel version, the fork/exec call will fail. Fixes #49779 Change-Id: Ic3ecfc2b601bafaab12b1805d7f9512955a8c7e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/474356 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
* syscall: avoid race in plan9 while syncing Chdir across goroutinesmiller2023-03-092-12/+47
| | | | | | | | | | | | | | | | | | | | | | Because each M in Plan 9 runs in a separate OS process with its own current working directory, a Chdir call in one goroutine needs to be propagated to other goroutines before a subsequent syscall with a local pathname (see #9428). This is done by function syscall.Fixwd, but there is still a race if a goroutine is preempted and rescheduled on a different M between calling Fixwd and executing the syscall which it protects. By locking the goroutine to its OS thread from the start of Fixwd to the end of the protected syscall, this race can be prevented. Fixes #58802. Change-Id: I89c0e43ef4544b5bfb5db7d2158f13f24b42e1f6 Reviewed-on: https://go-review.googlesource.com/c/go/+/474055 Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* all: move //go: function directives directly above functionsMichael Pratt2023-03-021-4/+4
| | | | | | | | | | | | | | | | These directives affect the next declaration, so the existing form is valid, but can be confusing because it is easy to miss. Move then directly above the declaration for improved readability. CL 69120 previously moved the Gosched nosplit away to hide it from documentation. Since CL 224737, directives are automatically excluded from documentation. Change-Id: I8ebf2d47fbb5e77c6f40ed8afdf79eaa4f4e335e Reviewed-on: https://go-review.googlesource.com/c/go/+/472957 Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
* all: implement wasmimport directiveEvan Phoenix2023-03-023-65/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | Go programs can now use the //go:wasmimport module_name function_name directive to import functions from the WebAssembly runtime. For now, the directive is restricted to the runtime and syscall/js packages. * Derived from CL 350737 * Original work modified to work with changes to the IR conversion code. * Modification of CL 350737 changes to fully exist in Unified IR path (emp) * Original work modified to work with changes to the ABI configuration code. * Fixes #38248 Co-authored-by: Vedant Roy <vroy101@gmail.com> Co-authored-by: Richard Musiol <mail@richard-musiol.de> Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Change-Id: I740719735d91c306ac718a435a78e1ee9686bc16 Reviewed-on: https://go-review.googlesource.com/c/go/+/463018 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
* syscall: use unsafe.Slice in (*RawSockaddrAny).Sockaddr on windowsTobias Klauser2023-02-281-2/+1
| | | | | | | | | | | | | Follow CL 471436. Change-Id: I415b126f58dbd381b8d45457e7bd79f025a2a03c Reviewed-on: https://go-review.googlesource.com/c/go/+/472035 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
* syscall: fix invalid unsafe.Pointer conversion on WindowsCuong Manh Le2023-02-271-10/+13
| | | | | | | | | | | | Fixes #58714 Change-Id: Ifa5c059ed5e358ed98aee7e83b95dd1806b535f7 Reviewed-on: https://go-review.googlesource.com/c/go/+/471335 Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* syscall: use unsafe.Slice in anyToSockaddrCuong Manh Le2023-02-274-8/+4
| | | | | | | | | | | | The function was added since go1.17, which is the minimum version for bootstraping now. Change-Id: I08b55c3639bb9ff042aabfcdcfbdf2993032ba6b Reviewed-on: https://go-review.googlesource.com/c/go/+/471436 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* runtime: use explicit NOFRAME on netbsd/amd64qmuntal2023-02-242-45/+2
| | | | | | | | | | | | | | | | | | | This CL marks some netbsd assembly functions as NOFRAME to avoid relying on the implicit amd64 NOFRAME heuristic, where NOSPLIT functions without stack were also marked as NOFRAME. While here, and thanks to CL 466355, `asm_netbsd_amd64.s` can be deleted in favor of `asm9_unix2_amd64.s`, which makes better use of the frame pointer. Updates #58378 Change-Id: Iff554b664ec25f2bb6ec198c0f684590b359c383 Reviewed-on: https://go-review.googlesource.com/c/go/+/466396 Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
* runtime: use explicit NOFRAME on dragonfly/amd64qmuntal2023-02-231-11/+10
| | | | | | | | | | | | | | | This CL marks some dragonfly assembly functions as NOFRAME to avoid relying on the implicit amd64 NOFRAME heuristic, where NOSPLIT functions without stack were also marked as NOFRAME. Updates #58378 Change-Id: I832a1a78d68a49f11df3b03fa9d50d4796bcac03 Reviewed-on: https://go-review.googlesource.com/c/go/+/466355 Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
* syscall: add ptracePtr that accepts pointer arg as unsafe.PointerDmitri Goutnik2023-02-2329-15/+242
| | | | | | | | | | | | | | | | The existing ptrace wrapper accepts pointer argument as an uintptr which often points to the memory allocated in Go. This violates unsafe.Pointer safety rules. Fixes #58387 Change-Id: Iab12122c495953f94ea00c2a61654a818a464205 Reviewed-on: https://go-review.googlesource.com/c/go/+/470299 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Dmitri Goutnik <dgoutnik@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Dmitri Goutnik <dgoutnik@gmail.com>
* syscall: add jail support to ForkExec on FreeBSDHarald Böhm2023-02-222-0/+108
| | | | | | | | | | | | | | | | | | Introduce a new SysProcAttr member called Jail on FreeBSD. This allows supplying an existing jail's ID to which the child process is attached before calling the exec system call. Fixes #46259 Change-Id: Ie282e5b83429131f9a9e1e27cfcb3bcc995d1d4d Reviewed-on: https://go-review.googlesource.com/c/go/+/458335 Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Goutnik <dgoutnik@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Samuel Karp <samuelkarp@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
* syscall: introduce IoctlPtr for exec_unix testsDmitri Goutnik2023-02-216-10/+18
| | | | | | | | | | | | | | | | | Avoid passing Go pointers as uintptr in exec_unix_test.go by introducing syscall.IoctlPtr() which accepts arg as unsafe.Pointer. For #44834 Fixes #58609 Change-Id: I6d0ded023e5f3c9989783aee7075bb88100d9ec2 Reviewed-on: https://go-review.googlesource.com/c/go/+/469675 Run-TryBot: Dmitri Goutnik <dgoutnik@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: Faccessat: check for CAP_DAC_OVERRIDE on LinuxKir Kolyshkin2023-02-171-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CL 416115 added using faccessat2(2) from syscall.Faccessat on Linux (which is the only true way to implement AT_EACCESS flag handing), if available. If not available, it uses some heuristics to mimic the kernel behavior, mostly taken from glibc (see CL 126415). Next, CL 414824 added using the above call (via unix.Eaccess) to exec.LookPath in order to check if the binary can really be executed. As a result, in a very specific scenario, described below, syscall.Faccessat (and thus exec.LookPath) mistakenly tells that the binary can not be executed, while in reality it can be. This makes this bug a regression in Go 1.20. This scenario involves all these conditions: - no faccessat2 support available (i.e. either Linux kernel < 5.8, or a seccomp set up to disable faccessat2); - the current user is not root (i.e. geteuid() != 0); - CAP_DAC_OVERRIDE capability is set for the current process; - the file to be executed does not have executable permission bit set for either the current EUID or EGID; - the file to be executed have at least one executable bit set. Unfortunately, this set of conditions was observed in the wild -- a container run as a non-root user with the binary file owned by root with executable permission set for a user only [1]. Essentially it means it is not as rare as it may seem. Now, CAP_DAC_OVERRIDE essentially makes the kernel bypass most of the checks, so execve(2) and friends work the same was as for root user, i.e. if at least one executable bit it set, the permission to execute is granted (see generic_permission() function in the Linux kernel). Modify the code to check for CAP_DAC_OVERRIDE and mimic the kernel behavior for permission checks. [1] https://github.com/opencontainers/runc/issues/3715 Fixes #58552. Change-Id: I82a7e757ab3fd3d0193690a65c3b48fee46ff067 Reviewed-on: https://go-review.googlesource.com/c/go/+/468735 Reviewed-by: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* syscall: regenerate zsyscall_windows.goqmuntal2023-02-011-1/+0
| | | | | | | | | | | | | | This CL regenerates zsyscall_windows.go, which was incorrectly hand-edited in CL 463842. Change-Id: Id556e69a282b2291a0b293b276ed4b9e0aeec105 Reviewed-on: https://go-review.googlesource.com/c/go/+/463848 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
* runtime: always use LoadLibraryEx to load system librariesqmuntal2023-01-313-36/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | This CL removes a fallback that used LoadLibraryA when the runtime was loading system DLLs on Windows 7, Windows Server 2008 R2, or earlier. We can safely remove that fallback now, as go1.21 will require at least Windows 8 or Server 2012. This CL also saves some syscall initialization time and bytes: new: init syscall @2.3 ms, 0 ms clock, 1000 bytes, 18 allocs old: init syscall @3.6 ms, 0.52 ms clock, 1744 bytes, 24 allocs Updates #57003 Change-Id: I7dcc1173537785b6b580e9f78632c0c74da658d4 Reviewed-on: https://go-review.googlesource.com/c/go/+/463842 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Damien Neil <dneil@google.com>
* syscall: avoid making assumptions about syscall permissionsBryan C. Mills2023-01-271-301/+207
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently check for at least three different permission bits before running tests that require root permissions: we look for UID 0, lack of an LXC container, and lack of a Docker container, and probe a number of distro-specific files in /proc and /sys. The sheer number of these checks suggests that we have probably missed at least one. Per Alan J. Perlis, “If you have a procedure with ten parameters, you probably missed some.” (And, indeed, we definitely have: a Debian patch¹ adds one more environment check!) CL 58170 added some of these container checks, but “decided to go this way instead of just skipping os.IsPermission errors because many of those tests were specifically written to check false positive permission errors.” However, we can't in general distinguish between a false-positive error and a real one caused by a container: if one is making a change to the syscall package, they should run the tests with -v and check for unexpected skips. Notably: - TestUnshare already skips itself if the command fails with an error ending in the string "operation not permitted", which could be caused by a variety of possible bugs. - The Unshare tests added in CL 38471 will fail with a permission error if CLONE_NEWNS is not supported, but it seems to me that if CLONE_NEWNS is supported — sufficient to start the process! — then Unmount must also be supported, and the test can at least check that the two are consistent. - The AmbientCaps tests should fail to start the subprocess with EINVAL or similar (not produce bogus output) if the kernel does not support ambient caps for any reason, which we can then detect. (If the subprocess fails in the way the test is concerned about, it will exit with status 2, not fail to start in the first place.) By executing the system calls and checking for permission errors, this change exposed an existing bug for AmbientCaps (filed as #57208), which was detected by the linux-arm-aws builder. For #57208. Updates #21379. Updates #14693. ¹https://sources.debian.org/patches/golang-1.19/1.19.3-1/0006-skip-userns-test-in-schroot-as-well.patch/ Change-Id: I9b167661fa1bb823168c8b50d8bbbf9643e49f76 Reviewed-on: https://go-review.googlesource.com/c/go/+/456375 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Alexander Morozov <lk4d4math@gmail.com> Run-TryBot: Bryan Mills <bcmills@google.com>
* syscall: clean up variable declarations in forkAndExecInChildBryan C. Mills2023-01-256-71/+98
| | | | | | | | | | | | | | | | | | | The various forkAndExecInChild implementations have comments explaining that they pre-declare variables to force allocations to occur before forking, but then later use ":=" declarations for additional variables. To make it clearer that those ":=" declarations do not allocate, we move their declarations up to the predeclared blocks. For #57208. Change-Id: Ie8cb577fa7180b51b64d6dc398169053fdf8ea97 Reviewed-on: https://go-review.googlesource.com/c/go/+/456516 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: export X__ifi_pad and X_f on s390x and riscv64Bryan C. Mills2023-01-253-10/+16
| | | | | | | | | | | | | | | This brings the exported field names on these GOARCHes in line with the other supported linux platforms. Fixes #57313. Change-Id: I2107a7116ba60dc0c0a27f776318e3eb69e51682 Reviewed-on: https://go-review.googlesource.com/c/go/+/457557 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Bryan Mills <bcmills@google.com>
* all: fix some commentscui fliter2023-01-241-1/+1
| | | | | | | | | | Change-Id: I3e9f05d221990b1ae464545d6d8b2e22c35bca21 Reviewed-on: https://go-review.googlesource.com/c/go/+/463077 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* runtime: revert use of __fork to work around Apple atfork bugsRuss Cox2023-01-107-81/+17
| | | | | | | | | | | | | | | | | | | | | An Apple engineer suggests that since __fork is not public API, it would be better to use a different fix. With the benefit of source code, they suggest using xpc_date_create_from_current instead of xpc_atfork_child. The latter sets some flags that disable certain functionality for the remainder of the process lifetime (expecting exec), while the former should do the necessary setup. Reverting the __fork fix in order to prepare a clean fix based on CL 451735 using xpc_date_create_from_current. This reverts commit c61d322d5f9e3fcffa4c523892af432dca030c12. Change-Id: I2da293ff537237ffd2d40ad756d827c95c84635b Reviewed-on: https://go-review.googlesource.com/c/go/+/460475 Auto-Submit: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
* syscall: skip TestUseCgroupFD if cgroupfs not mountedShengjing Zhu2023-01-061-2/+3
| | | | | | | | | | | | | When building in schroot (for building Debian package), the cgroupfs is not mounted in schroot (only sysfs is mounted). Change-Id: Ieddac7b2f334d58d832f5d84d81af812badf3720 Reviewed-on: https://go-review.googlesource.com/c/go/+/460539 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
* runtime: call __fork instead of fork on darwinRuss Cox2022-12-227-17/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issues #33565 and #56784 were caused by hangs in the child process after fork, while it ran atfork handlers that ran into slow paths that didn't work in the child. CL 451735 worked around those two issues by calling a couple functions at startup to try to warm up those child paths. That mostly worked, but it broke programs using cgo with certain macOS frameworks (#57263). CL 459175 reverted CL 451735. This CL introduces a different fix: bypass the atfork child handlers entirely. For a general fork call where the child and parent are both meant to keep executing the original program, atfork handlers can be necessary to fix any state that would otherwise be tied to the parent process. But Go only uses fork as preparation for exec, and it takes care to limit what it attempts to do in the child between the fork and exec. In particular it doesn't use any of the things that the macOS atfork handlers are trying to fix up (malloc, xpc, others). So we can use the low-level fork system call (__fork) instead of the atfork-wrapped one. The full list of functions that can be called in a child after fork in exec_libc2.go is: - ptrace - setsid - setpgid - getpid - ioctl - chroot - setgroups - setgid - setuid - chdir - dup2 - fcntl - close - execve - write - exit I disassembled all of these while attached to a hung exec.test binary and confirmed that nearly all of them are making direct kernel calls, not using anything that the atfork handler needs to fix up. The exceptions are ioctl, fcntl, and exit. The ioctl and fcntl implementations do some extra work around the kernel call but don't call any other functions, so they should still be OK. (If not, we could use __ioctl and __fcntl instead, but without a good reason, we should keep using the standard entry points.) The exit implementation calls atexit handlers. That is almost certainly inappropriate in a failed fork child, so this CL changes that call to __exit on darwin. To avoid making unnecessary changes at this point in the release cycle, this CL leaves OpenBSD calling plain exit, even though that is probably a bug in the OpenBSD port (filed #57446). Fixes #33565. Fixes #56784. Fixes #57263. Change-Id: I26812c26a72bdd7fcf72ec41899ba11cf6b9c4ab Reviewed-on: https://go-review.googlesource.com/c/go/+/459176 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
* syscall: don't use faccessat2 on androidMichael Pratt2022-12-211-2/+12
| | | | | | | | | | | | | | The Android seccomp policy does not allow faccessat2, so attempting to use it results in a SIGSYS. Avoid it and go straight to the fallback. Fixes #57393. Change-Id: I8d4e12a6f46cea5642d3b5b5a02c682529882f29 Reviewed-on: https://go-review.googlesource.com/c/go/+/458495 Reviewed-by: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Changkun Ou <mail@changkun.de> Run-TryBot: Michael Pratt <mpratt@google.com>
* syscall, internal/poll: fall back to accept on linux-armIan Lance Taylor2022-12-164-16/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Our minimum Linux version is 2.6.32, and the accept4 system call was introduced in 2.6.28, so we use accept4 everywhere. Unfortunately, it turns out that the accept4 system call was only added to linux-arm in 2.6.36, so for linux-arm only we need to try the accept4 system call and then fall back to accept if it doesn't work. The code we use on linux-arm is the code we used in Go 1.17. On non-arm platforms we continue using the simpler code introduced in Go 1.18. Adding accept4 to the ARM Linux kernel was: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=21d93e2e29722d7832f61cc56d73fb953ee6578e Fixes #57333 Change-Id: I6680cb54dd4d3514a6887dda8906e6708c64459d Reviewed-on: https://go-review.googlesource.com/c/go/+/457995 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* syscall: fix closing of reordered FDs in plan9 ForkExecmiller2022-12-131-1/+1
| | | | | | | | | | | | | | | | | After dup'ing file descriptors in syscall.ProcAttr.Files to pass to the exec'ed process, the logic for closing the old descriptors was incorrect and could close the new descriptor instead. Fixes #57180 Change-Id: I7725f21a465ffba57050fe4e36f3d36ba181cfb2 Reviewed-on: https://go-review.googlesource.com/c/go/+/457115 Run-TryBot: David du Colombier <0intro@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: David du Colombier <0intro@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com>
* syscall: skip TestUseCgroupFD if cgroupfs mounted ROPaul E. Murphy2022-12-121-1/+3
| | | | | | | | | | | | | | | | The skipping logic should also trigger if /sys/fs/cgroup is mounted read-only too. This is how it is mounted on the ppc64le/p10 containers today. Fixes #57262 Change-Id: Idc0ab050052ebf5777ac09f9519215b437b0ee7c Reviewed-on: https://go-review.googlesource.com/c/go/+/456835 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Paul Murphy <murp@ibm.com>
* syscall: fix shadowing bugs in forkAndExecInChildBryan C. Mills2022-12-122-4/+4
| | | | | | | | | | | Fixes #57208. Updates #23152. Change-Id: Icc9a74aeb26f1b6f151162c5d6bf1b4d7cd54d0a Reviewed-on: https://go-review.googlesource.com/c/go/+/456515 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>