aboutsummaryrefslogtreecommitdiff
path: root/src/syscall
AgeCommit message (Collapse)Author
2025-02-25all: surround -test.run arguments with ^$qmuntal
If the -test.run value is not surrounded by ^$ then any test that matches the -test.run value will be run. This is normally not the desired behavior, as it can lead to unexpected tests being run. Change-Id: I3447aaebad5156bbef7f263cdb9f6b8c32331324 Reviewed-on: https://go-review.googlesource.com/c/go/+/651956 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-24all: use testenv.Executable instead of os.Executable and os.Args[0]qmuntal
In test files, using testenv.Executable is more reliable than os.Executable or os.Args[0]. Change-Id: I88e577efeabc20d02ada27bf706ae4523129128e Reviewed-on: https://go-review.googlesource.com/c/go/+/651955 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-24syscall: allow \x00-prefixed unix abstract socket to use full path lengthAlbert Sundjaja
Fixes #70893 Change-Id: Ia0aaa497dad335fe962d52d3f115d26e8046e36f GitHub-Last-Rev: 7dd663678d8aecdfac94541a570dfbd1aa2577e7 GitHub-Pull-Request: golang/go#71851 Reviewed-on: https://go-review.googlesource.com/c/go/+/650875 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-02-23syscall: use sync.OnceFunc for copyenvTobias Klauser
Change-Id: I64f658c1962878685ba7736f19d58e10fbdcb94a Reviewed-on: https://go-review.googlesource.com/c/go/+/651835 Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-21runtime: use WCLONE when waiting on pidfd test childMichael Pratt
As of CL 650835, the pidfd test child no longer sends SIGCHLD on exit. Per clone(2), "If [the child termination] signal is specified as anything other than SIGCHLD, then the parent process must specify the __WALL or __WCLONE options when waiting for the child with wait(2)." Align with this requirement. For #71828. Change-Id: I6a6a636c739e4a59abe1533fe429a433e8588939 Reviewed-on: https://go-review.googlesource.com/c/go/+/651415 Reviewed-by: Ian Lance Taylor <iant@golang.org> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-20syscall: don't send child signal when testing pidfdIan Lance Taylor
Avoid a spurious SIGCHLD the first time we start a process. Fixes #71828 Change-Id: I744100d21bf6aaaaafc99bc5eec9f9f807a50682 Reviewed-on: https://go-review.googlesource.com/c/go/+/650835 Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-19syscall: don't truncate newly created files on Windowsqmuntal
There is no need for syscall.OpenFile to truncate newly created files. Some special Windows files, like the NUL device, can't be truncated, so we should avoid truncating unless it is really necessary. Fixes #71752. Change-Id: I8238048594f706f6a5281053d55cfe3dc898828d Reviewed-on: https://go-review.googlesource.com/c/go/+/650276 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-02-18syscall: disable O_DIRECTORY on Windows for js/wasmZxilly
O_DIRECTORY is not available on all platforms, as described at https://nodejs.org/docs/latest/api/fs.html#file-open-constants . On Windows, only O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY, and UV_FS_O_FILEMAP are available. Fixes #71758 Change-Id: Iacc890ba9a30dcd75eb746ec324fa0c3e368048e GitHub-Last-Rev: a0160e8fc82583c4f903ae165fe9f204896cf56d GitHub-Pull-Request: golang/go#71770 Reviewed-on: https://go-review.googlesource.com/c/go/+/650015 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
2025-02-14syscall: skip testAmbientCaps tests if there is no nobody userCarlos Ramos CarreƱo
When there is not a nobody user (for example inside Docker), the tests TestAmbientCaps and TestAmbientCapsUserns should be skipped instead of failing. Fixes #71644 Change-Id: I7f92db19e2b6f449d8d897650a0ecd89f5150f4a GitHub-Last-Rev: a4c4f5bb61929b4981dc0b92d773bd4ef13d7d3d GitHub-Pull-Request: golang/go#71729 Reviewed-on: https://go-review.googlesource.com/c/go/+/649396 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-02-10os: add Root.ChmodDamien Neil
For #67002 Change-Id: Id6c3a2096bd10f5f5f6921a0441dc6d9e6cdeb3b Reviewed-on: https://go-review.googlesource.com/c/go/+/645718 Commit-Queue: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com>
2025-02-03syscall: use consistent message for ESTALE on LinuxIan Lance Taylor
For some reason the ESTALE error message differed on Linux systems. On Linux strerror normally returns "Stale file handle" for ESTALE, except possibly in the en_GB locale. The mkerrors.sh script sets LC_ALL=C, so it should always produces "stale file handle". However, for some reason, several targets use "stale NFS file handle" instead. Clean this up so that we use the same string on all Linux systems. This is also consistent with golang.org/x/sys/unix. Fixes #71309 Change-Id: Ic2ffaf114c85112bc6d0831e43dd5fd2f4237bc2 Reviewed-on: https://go-review.googlesource.com/c/go/+/643335 Auto-Submit: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2025-02-03all: use slices.Contains to simplify codecuishuang
Change-Id: I9ef075bbb0e3c65f3c2a9d49e599ef50b18aa9be Reviewed-on: https://go-review.googlesource.com/c/go/+/639535 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-01-13syscall/js: adjust comments to that gofmt does not change themIan Lance Taylor
Change-Id: Ic410375987c0f376d0a975e5a6284de10f08b741 Reviewed-on: https://go-review.googlesource.com/c/go/+/642495 Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-17syscall, internal/syscall/unix: fix fstatat on linux/mips64Damien Neil
On linux/mips64, the syscall.Stat_t struct does not match the kernel version of the struct. Functions that operate on a Stat_t translate between it and the kernel struct. The fstatat function was not doing this translation. Make it do so. Export a syscall.Fstatat on mips64 for usage by internal/syscall/unix. Perhaps we should just do this on all architectures, but this is the smaller change for now. Fixes #70659 Change-Id: I38e36473689be25861953b418c9abc5b270a7bcf Reviewed-on: https://go-review.googlesource.com/c/go/+/633280 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-12-12syscall: on freebsd-386 only update written for certain errorsIan Lance Taylor
Testing on the freebsd-386 gomote seems to show that sendfile returns a non-zero number of bytes written even when it returns EINVAL. This confuses the caller. Change the Go code to only return non-zero on success or EINTR or EAGAIN, which are the only cases where the man page says that sendfile updates the number of bytes. For #70763 Change-Id: Icc04e6286b5b29a2029237711d50fe4973234f0a Reviewed-on: https://go-review.googlesource.com/c/go/+/635815 Reviewed-by: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-12-11syscall: remove a wrong comment in ClearenvKir Kolyshkin
The comment being removed was added by commit ff3173849e (which predates Gerrit and Rietveld, so no CL link), and at the time it made sense. Since CL 148370043 (and up to the current implementation of Clearenv) the env map, which is populated by copyenv, is actually used, so the comment is no longer valid. It is also misleading, so it's best to remove it. Change-Id: I8bd2e8bca6262759538e5bcbd396f0c71cca6a4c Reviewed-on: https://go-review.googlesource.com/c/go/+/635078 Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-11-22runtime, internal/synctest, syscall/js: keep bubble membership in syscallsDamien Neil
Propagate synctest bubble membership through syscall/js.Func functions. Avoids panics from cross-bubble channel operations in js syscalls. Fixes #70512 Change-Id: Idbd9f95da8bc4f055a635dfac041359f848dad1a Reviewed-on: https://go-review.googlesource.com/c/go/+/631055 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com>
2024-11-20os: add Root.Stat and Root.LstatDamien Neil
For #67002 Change-Id: I0903f45dbb4c44ea0280c340c96c5f3c3c0781be Reviewed-on: https://go-review.googlesource.com/c/go/+/627475 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2024-11-20internal/byteorder: use canonical Go casing in namesRuss Cox
If Be and Le stand for big-endian and little-endian, then they should be BE and LE. Change-Id: I723e3962b8918da84791783d3c547638f1c9e8a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/627376 Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-20syscall: do not run TestSyscallAllocations in parallel with other testsRuss Cox
Fixes #70327. Change-Id: I27ee0d1fbae73fb5c22aa699f4e3110c67bc9ea2 Reviewed-on: https://go-review.googlesource.com/c/go/+/630136 Auto-Submit: Russ Cox <rsc@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
2024-11-14syscall: define EBADFD for wasip1 targetFlavio Castelli
Fixes #60998 Change-Id: I7e899708c7e0406bd9927eb411b57fc3240b7f18 GitHub-Last-Rev: c1a20aee0e559e8a27a3c59acfd244fdbf885a80 GitHub-Pull-Request: golang/go#60999 Reviewed-on: https://go-review.googlesource.com/c/go/+/506175 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-13cmd/internal/obj/wasm: correct return PC for frameless wasmexport wrappersCherry Mui
For a wasmexport wrapper, we generate a call to the actual exported Go function, and use the wrapper function's PC 1 as the (fake) return address. This address is not used for returning, which is handled by the Wasm call stack. It is used for stack unwinding, and PC 1 makes it past the prologue and therefore has the right SP delta. But if the function has no arguments and results, the wrapper is frameless, with no prologue, and PC 1 doesn't exist. This causes the unwinder to fail. In this case, we put PC 0, which also has the correct SP delta (0). Fixes #69584. Change-Id: Ic047a6e62100db540b5099cc5a56a1d0f16d58b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/624000 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-11runtime, syscall: use pointer types on wasmimport functionsCherry Mui
Now that we support pointer types on wasmimport functions, use them, instead of unsafe.Pointer. This removes unsafe conversions. There is still one unsafe.Pointer argument left. It is actually a *Stat_t, which is an exported type with an int field, which is not allowed as a wasmimport field type. We probably cannot change it at this point. Updates #66984. Change-Id: I445c70b356c3877a5604bee67d19d99a538c682e Reviewed-on: https://go-review.googlesource.com/c/go/+/627059 Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2024-11-06syscall: mark SyscallN as noescapeqmuntal
syscall.SyscallN is implemented by runtime.syscall_syscalln, which makes sure that the variadic argument doesn't escape. There is no need to worry about the lifetime of the elements of the variadic argument, as the compiler will keep them live until the function returns. Fixes #70197. Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-windows-amd64-race Change-Id: I12991f0be12062eea68f2b103fa0a794c1b527eb Reviewed-on: https://go-review.googlesource.com/c/go/+/625297 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-23syscall: only remove write data access when O_APPEND is set on Windowsqmuntal
There is no need to remove all write accesses when O_APPEND is set, only the FILE_WRITE_DATA access. This will allow files opened with O_APPEND and O_WRONLY to be have their attributes and ACLs modified. Change-Id: I6fe3b25e87b141a9eb30805f395fec31242fd35d Reviewed-on: https://go-review.googlesource.com/c/go/+/620615 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-10-21syscall: skip TestSetuidEtc when root's gid is not 0Shuo Wang
When the root user belongs to a special user group (for example, in a mock environment), TestSetuidEtc will fail. For example: Setegid(1) want:"Gid: 0 1 0 1" got:"Gid: 1001 1 1001 1" Fixes #69921 Change-Id: I74d0a006b7529b1b569120a067eb4d7c4ed2e491 GitHub-Last-Rev: 5724383eb134c8a5c2a4a5ed67e2d3999073b98b GitHub-Pull-Request: golang/go#69922 Reviewed-on: https://go-review.googlesource.com/c/go/+/620775 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-18syscall: keep write access when O_TRUNC is used on Windowsqmuntal
CL 618836 introduces a regression where O_APPEND and O_TRUNC could not be used together on Windows. This CL fixes the issue by keeping the write access when O_TRUNC is used , which is required when overwriting data (as per the file access rights docs: https://learn.microsoft.com/en-us/windows/win32/fileio/file-access-rights-constants). Fixes #69902. Change-Id: I77ec60ca6929124dd4490bdad6c3280c4db3efcb Reviewed-on: https://go-review.googlesource.com/c/go/+/620575 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-10-11internal/syscall/windows: add Openat, MkdiratDamien Neil
Windows versions of openat and mkdirat, implemented using NtCreateFile. For #67002 Change-Id: If43b1c1069733e5c45f7d45a69699fec30187308 Reviewed-on: https://go-review.googlesource.com/c/go/+/619435 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-10syscall: support more flags when opening directories on Windowsqmuntal
syscall.Open was artificially limiting the flags that were eligible to open directories on Windows. This change extend the cases where we pass FILE_FLAG_BACKUP_SEMANTICS to all flag combinations allowed by Unix. Change-Id: Ia7c083bcba070f92ea61c6d67487bdefd0d99546 Reviewed-on: https://go-review.googlesource.com/c/go/+/619295 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-10-10syscall: fix Open param namesqmuntal
syscall.Open param names are confusing, mainly because what should be named flag is named mode and what should be named mode is named perm. The name perm is used as synonym for mode in other places, so keep it as is. Rename mode to flag to match the real meaning of the parameter. Also, rename path to name for consistency with other usage of the same parameter. Change-Id: Ideed09839d80c0383584c2268afbb6cc09ffda8c Reviewed-on: https://go-review.googlesource.com/c/go/+/619276 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-10syscall,os: move flags validation from os.OpenFile to syscall.Openqmuntal
syscall.Open is the functions that maps Unix/Go flags into Windows concepts. Part of the flag validation logic was still implemented in os.OpenFile, move it to syscall.Open for consistency. A nice side effect is that we don't have to translate the file name twice in case of an access denied error. Change-Id: I32c647a9a2a066277c78f53bacb45fb3036f6353 Reviewed-on: https://go-review.googlesource.com/c/go/+/619275 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-10-09syscall: simplify O_TRUNC handling on Windowsqmuntal
The current implementation of O_TRUNC in syscall.Open on Windows is prone to TOCTOU issues, as it opens the file twice if the first open detects that the file doesn't exist. The file could be created in between the two open calls, leading to the creation of a new file with the undesired readonly attribute. This CL implements O_TRUNC by just calling CreateFile once without taking O_TRUNCATE into account, and then using Ftruncate if O_TRUNC is set to truncate the file. Updates #38225. Change-Id: Ic3ad1bab75c9a1c16f99c8c5bed867c5dbc3a23b Reviewed-on: https://go-review.googlesource.com/c/go/+/618836 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-10-09syscall: implement Ftruncate using a single syscall on Windowsqmuntal
Ftruncate can be implemented on Windows using a single syscall. This makes the implementation more efficient and less prone to races when used in combination with other Seek calls. Change-Id: I5d9f780fba2710403fce89d3325e519f33ad9ae8 Reviewed-on: https://go-review.googlesource.com/c/go/+/618835 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-07syscall, internal/syscall/unix: add Openat support for wasip1Damien Neil
The syscall package is mostly frozen, but wasip1 file syscall support was added to syscall and the Open and Openat implementations overlap. Implement Openat in syscall for overall simplicity. We already have syscall.Openat for some platforms, so this doesn't add any new functions to syscall. For #67002 Change-Id: Ia34b12ef11fc7a3b7832e07b3546a760c23efe5b Reviewed-on: https://go-review.googlesource.com/c/go/+/617378 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-10-07crypto/rand: use arc4random_buf() on OpenBSDFilippo Valsorda
OpenBSD system calls are mediated by libc anyway, and arc4random_buf() is the preferred mechanism to obtain random bytes. Also, rename NetBSD's function to reflect it's not actually calling getentropy(3). Cq-Include-Trybots: luci.golang.try:gotip-openbsd-amd64 Change-Id: Id1f3f7af16750537e2420bcf44b086de5854198c Reviewed-on: https://go-review.googlesource.com/c/go/+/608395 Reviewed-by: Daniel McCarney <daniel@binaryparadox.net> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Bypass: Filippo Valsorda <filippo@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org>
2024-10-03syscall: use SYS_EXIT_GROUP in CLONE_PIDFD feature check childMichael Pratt
Inside Google we have seen issues with QEMU user mode failing to wake a parent waitid when this child exits with SYS_EXIT. This bug appears to not affect SYS_EXIT_GROUP. It is currently unclear if this is a general QEMU or specific to Google's configuration, but SYS_EXIT and SYS_EXIT_GROUP are semantically equivalent here, so we can use the latter here in case this is a general QEMU bug. For #68976. Change-Id: I34e51088c9a6b7493a060e2a719a3cc4a3d54aa0 Reviewed-on: https://go-review.googlesource.com/c/go/+/617417 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-10-02syscall: gofmt after CL 592078Tobias Klauser
Change-Id: I328760f7752f1f5ec100f151c7e13e3f804c0e10 Reviewed-on: https://go-review.googlesource.com/c/go/+/617355 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-12os: add clone(CLONE_PIDFD) check to pidfd feature checkMichael Pratt
clone(CLONE_PIDFD) was added in Linux 5.2 and pidfd_open was added in Linux 5.3. Thus our feature check for pidfd_open should be sufficient to ensure that clone(CLONE_PIDFD) works. Unfortuantely, some alternative Linux implementations may not follow this strict ordering. For example, QEMU 7.2 (Dec 2022) added pidfd_open, but clone(CLONE_PIDFD) was only added in QEMU 8.0 (Apr 2023). Debian bookworm provides QEMU 7.2 by default. Fixes #69259. Change-Id: Ie3f3dc51f0cd76944871bf98690abf59f68fd7bf Reviewed-on: https://go-review.googlesource.com/c/go/+/592078 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-09-10syscall: on exec failure, close pidfdIan Lance Taylor
Fixes #69284 Change-Id: I6350209302778ba5e44fa03d0b9e680d2b4ec192 Reviewed-on: https://go-review.googlesource.com/c/go/+/611495 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: roger peppe <rogpeppe@gmail.com> Reviewed-by: Tim King <taking@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-09-07syscall: follow convention for generated code commentTobias Klauser
Follow the convention (https://golang.org/s/generatedcode) for generated code as if we would regenerate them using mkall.sh. This also drops the superfluous //go:build tags which are already implied by the file names. Change-Id: Ic97c6ba9d707d347f06a7d6c1dd07b556d82c882 Reviewed-on: https://go-review.googlesource.com/c/go/+/611115 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-04all: use t.Chdir in testsKir Kolyshkin
Change-Id: I5bc514bedeb1155e6db52e37736fd6101774aea0 Reviewed-on: https://go-review.googlesource.com/c/go/+/529896 Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@golang.org>
2024-09-03syscall: use t.TempDir in testsKir Kolyshkin
Change-Id: Ibeb00306ee8f038c11f261abd99c05324bf2ab51 Reviewed-on: https://go-review.googlesource.com/c/go/+/609837 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-03syscall: use testenv.ExecutableKir Kolyshkin
Change-Id: I4390d4bfb7deb974df6546e30ebbb4b6fff74730 Reviewed-on: https://go-review.googlesource.com/c/go/+/609836 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-30syscall: honor prlimit set by a different processIan Lance Taylor
On Linux one process can call prlimit to change the resource limit of another process. With this change we treat that as though the current process called prlimit (or setrlimit) to set its own limit. The cost is one additional getrlimit system call per fork/exec, for cases in which the rlimit Cur and Max values differ at startup. This revealed a bug: the setrlimit (not Setrlimit) function should not change the cached rlimit. That means that it must call prlimit1, not prlimit. Fixes #66797 Change-Id: I46bfd06e09ab7273fe8dd9b5b744dffdf31d828b Reviewed-on: https://go-review.googlesource.com/c/go/+/607516 Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Aleksa Sarai <cyphar@cyphar.com> Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-08-30syscall: always use prlimit for getrlimit/setrlimit on LinuxIan Lance Taylor
Linux added the prlimit system call in version 2.6.36. As our minimum Linux kernel version is now 3.2, simplify the various getrlimit/setlrimit implementations to just always use prlimit. For #67001 Change-Id: I2512c21c947d0bc83f8f9077c143163fd8d83be3 Reviewed-on: https://go-review.googlesource.com/c/go/+/609178 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-08-30misc/wasm: move wasm runtime files to lib/wasmZxilly
Fixes #68024 Change-Id: I730c3ecfb14472f3eea3895c2a4d5e1d4ac146f5 GitHub-Last-Rev: 4242f360103ba1fd1f4085b8257ccce0f07a68e5 GitHub-Pull-Request: golang/go#68840 Reviewed-on: https://go-review.googlesource.com/c/go/+/604696 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2024-08-21syscall: optimize Getwd on aixKir Kolyshkin
When looking for \0, use clen which may be optimized. Also, return EINVAL when returned string is empty. This makes it similar to how it is implemented in *bsd and solaris. Change-Id: I3e37ed25f47110eafd12c80291f7746de9db7b23 Reviewed-on: https://go-review.googlesource.com/c/go/+/606902 TryBot-Bypass: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com>
2024-08-21syscall: add O_DIRECTORY for wasip1Kir Kolyshkin
Change-Id: Iadd69360fb09714a280c4dae26639834df28a7dc Reviewed-on: https://go-review.googlesource.com/c/go/+/606659 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-08-21syscall: add O_DIRECTORY for jsKir Kolyshkin
Change-Id: I2022fa27b072f9b34413a04a794aeb6d3c02166c Reviewed-on: https://go-review.googlesource.com/c/go/+/606658 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-08-21cmd/link: support wasmexport on js/wasmCherry Mui
Add export functions to the wasm module on GOOS=js. (Other parts work the same way as wasip1.) Add a test. Fixes #65199. Change-Id: Ia22580859fe40631d487f70ee293c12867e0c988 Reviewed-on: https://go-review.googlesource.com/c/go/+/606855 Reviewed-by: Zxilly Chou <zxilly@outlook.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>