aboutsummaryrefslogtreecommitdiff
path: root/src/syscall
AgeCommit message (Collapse)Author
2023-11-02syscall: call getfsstat via libc on openbsdJoel Sing
On openbsd, call getfsstat directly via libc, instead of calling it via syscall.Syscall. Updates #63900 Change-Id: Ib4c581160b170e6cc6017c42e959e647d97ac993 Reviewed-on: https://go-review.googlesource.com/c/go/+/538736 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Josh Rickmar <jrick@zettaport.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Joel Sing <joel@sing.id.au>
2023-11-01syscall: regen zsyscall for openbsd/riscv64Joel Sing
This removes the unused writelen function, which was cleaned up for other platforms in CL#529035. Change-Id: I1999dc81276763bdc73d8590c16729447c4e8538 Reviewed-on: https://go-review.googlesource.com/c/go/+/538119 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Joel Sing <joel@sing.id.au>
2023-11-01syscall: regenerate zsyscall for dragonfly/freebsd/netbsdJoel Sing
The sysctl declaration was moved in CL 141639, however the files were presumably not regenerated. There is no functional change, however regenerating avoids unrelated noise in future diffs. Change-Id: Ifb840b5853f3f1c3c88a3f94df21b6f6d3c635d4 Reviewed-on: https://go-review.googlesource.com/c/go/+/538118 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-10-20syscall: stop counting trailing NUL for abstract addresses starting with NULF Y
Changes trailing-NUL-counting behavior for abstract addresses starting with the NUL character to be the same as abstract addresses starting with the @ character. For #63579. Change-Id: I206e4d0d808396998cb7d92a9e26dda854cb1248 GitHub-Last-Rev: 0ff0a9c938a4b57cdc30b1c4f0c058108a241df8 GitHub-Pull-Request: golang/go#63580 Reviewed-on: https://go-review.googlesource.com/c/go/+/535776 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-10-04syscall: add syscall support for openbsd/riscv64 portJoel Sing
Updates #55999 Change-Id: I5b8452207e951e543b9be42ebcb7d62c0c023f08 Reviewed-on: https://go-review.googlesource.com/c/go/+/518627 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Aaron Bieber <deftly@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-10-03syscall: return pointer from test function OrigRlimitNofileIan Lance Taylor
Change-Id: I8740a2a7ebb3045d8daa97bcb0da7f31f6f7b881 Reviewed-on: https://go-review.googlesource.com/c/go/+/531996 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-10-02syscall: copy original rlimit before modifyingMichael Pratt
CL 531516 converted origRlimitNofile from an atomic.Value to atomic.Pointer[Rlimit]. i.e., it changed from storing a value to storing a pointer. After storing a pointer to lim, the remainder of this function immediately modifies it, thus mutating the value pointer to by origRlimitNofile (and thus defeating the point of origRlimitNofile). This broke the android-amd64-emu builder because it is (apparently) the only builder where the original RLIMIT_NOFILE Cur != Max. TestRlimitRestored is skipped on every other builder. Change-Id: I12076350eeddfd221823ad651e7e7eca59d2bdcd Reviewed-on: https://go-review.googlesource.com/c/go/+/532100 Run-TryBot: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-29syscall: make origRlimitNofile atomic.Pointer[Rlimit]Jes Cok
Currently we are bootstrapping with Go 1.20, origRlimitNofile can be changed to atomic.Pointer[Rlimit]. Change-Id: I00ce9d1a9030bd5dbd34e3dc6c4e38683a87be86 GitHub-Last-Rev: f2ccdb38412019d10661ed6be42086b445e411bf GitHub-Pull-Request: golang/go#63274 Reviewed-on: https://go-review.googlesource.com/c/go/+/531516 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2023-09-28syscall: simplify and optimize environment block creation on Windowsqmuntal
createEnvBlock currently allocates multiple times: at least one to convert the slice of strings into a NULL separated slice of bytes, and then again to encode it as UTF-16. The logic to do so is also quite complex. This CL simplifies the logic by allocating only once by encoding the slice of strings into UTF-16 directly using utf16.AppendRune. goos: windows goarch: amd64 pkg: syscall cpu: Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ CreateEnvBlock-12 37.92µ ± 24% 21.36µ ± 8% -43.66% (p=0.000 n=10) │ old.txt │ new.txt │ │ B/op │ B/op vs base │ CreateEnvBlock-12 109.12Ki ± 0% 26.62Ki ± 0% -75.60% (p=0.000 n=10) │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ CreateEnvBlock-12 4.000 ± 0% 1.000 ± 0% -75.00% (p=0.000 n=10) Change-Id: If35f62c3926b486d5253a9ae23a33b979b2f02c2 Reviewed-on: https://go-review.googlesource.com/c/go/+/531355 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com>
2023-09-27syscall: remove Windows 7 console handle workaroundqmuntal
Windows 7 is no longer supported, there is no need to complicate the code to support inheriting console handles. Change-Id: Ie9f5cde77a63ea4fa6032bbb7ba5bd48a0989c5b Reviewed-on: https://go-review.googlesource.com/c/go/+/531235 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
2023-09-27all: fix misuses of "a" vs "an"cui fliter
Fixes the misuse of "a" vs "an", according to English grammatical expectations and using https://www.a-or-an.com/ Change-Id: Ic9600dcbb3d843880349729478266c4b9bcf7316 Reviewed-on: https://go-review.googlesource.com/c/go/+/531335 Run-TryBot: shuang cui <imcusg@gmail.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-22all: clean unnecessary casts for test filesJes Cok
This is a follow up of CL 528696. Change-Id: I5b71eabedb12567c4b1b36f7182a3d2b0ed662a5 GitHub-Last-Rev: acaf3ac11c38042ad27b99e1c70a3c9f1a554a15 GitHub-Pull-Request: golang/go#62713 Reviewed-on: https://go-review.googlesource.com/c/go/+/529197 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-20syscall: skip TestDeathSignalSetuid if exec fails with a permission errorBryan C. Mills
Also explicitly look up user "nobody" (or "gopher" on the Go builders) if running as root, instead of hard-coding UID/GID 99. Fixes #62719. Change-Id: I9fa8955f2c239804fa775f2478a5274af9330822 Reviewed-on: https://go-review.googlesource.com/c/go/+/529795 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> 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>
2023-09-20syscall: remove unused writelenTobias Klauser
Change-Id: I3c0e9e405120ef595712741a2f8e963cbb0733dc Reviewed-on: https://go-review.googlesource.com/c/go/+/529035 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-19syscall: correctly generate accept on linux/armTobias Klauser
CL 457995 introduced syscall_linux_accept.go which is used on linux/arm to generate accept and use it in Accept. However, that CL forgot to include the file in the list of files used with mksyscall.pl to generate the syscall wrappers. This lead to accept no longer being generated when re-running mkall.sh on linux/arm. Change-Id: I7747399afae47a883a7fb079c82e835b90f366cf Reviewed-on: https://go-review.googlesource.com/c/go/+/529055 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Commit-Queue: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2023-09-18all: clean unnecessary castsJes Cok
Run 'unconvert -safe -apply' (https://github.com/mdempsky/unconvert) Change-Id: I24b7cd7d286cddce86431d8470d15c5f3f0d1106 GitHub-Last-Rev: 022e75384c08bb899a8951ba0daffa0f2e14d5a7 GitHub-Pull-Request: golang/go#62662 Reviewed-on: https://go-review.googlesource.com/c/go/+/528696 Auto-Submit: Ian Lance Taylor <iant@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: Michael Pratt <mpratt@google.com>
2023-09-18net: enable most tests on wasip1 and jsBryan C. Mills
To get them to pass, implement more fake syscalls. To make those syscalls easier to reason about, replace the use of sync.Cond with selectable channels. Fixes #59718. Fixes #50216. Change-Id: I135a6656f5c48f0e5c43dc4d4bcbdb48ee5535d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/526117 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Achille Roussel <achille.roussel@gmail.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-14syscall: remove unused ptracePtr on openbsdTobias Klauser
ptracePtr was introduced in CL 470299 for openbsd but it's not used on this platform. For #58387 Change-Id: I27901c3f4497e18dc407a9248b66e2691c9a6abb Reviewed-on: https://go-review.googlesource.com/c/go/+/527535 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-13syscall: use SYS_SETRLIMIT in //sysnb setrlimit1 on linux/arm64Tobias Klauser
Otherwise the setrlimit1 wrapper would be generated using the inexistent SYS_GETRLIMIT1 syscall number. This was likely missed in CL 476097. For #476097 Change-Id: I5cfa2ebacb58aeeaddd3db3639a45cf368fbe0ab Reviewed-on: https://go-review.googlesource.com/c/go/+/527555 Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-09-12all: calculate the median uniformlyJes Cok
This is a follow up of CL 526496. Change-Id: I9f351951bf975e31befd36b9c951d195d2f8f9f7 GitHub-Last-Rev: 4307adafbffef7494d6f807b69df3e56328d6bf4 GitHub-Pull-Request: golang/go#62590 Reviewed-on: https://go-review.googlesource.com/c/go/+/527576 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-09-12all: fix Microsoft linksqmuntal
This CL fixes the links to Microsoft documentation in the Go source code. Some links were broken and some others were outdated. Change-Id: I4c3bcd3aa3c07a31be1b7f94c25339dcc2e771e8 Reviewed-on: https://go-review.googlesource.com/c/go/+/527556 Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
2023-09-08syscall: skip unshare tests if mount syscall is not availableDmitri Shuralyov
CL 513779 added crude skips for tests that couldn't work when run under 'unshare --net --map-root-user' as used by the current iteration of the no-network check in LUCI. Bryan suggested a more targeted way to detect when the environment is insufficient, which makes it possible to remove the builder-specific skip and its slightly incorrect explaining comment. Updates #30612. Change-Id: I0de79f44ab94d7f1018384c2e959ca7df3a1b0ae Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-amd64-longtest-race Reviewed-on: https://go-review.googlesource.com/c/go/+/526835 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-09-07syscall: remove unused ptracePtr on darwinTobias Klauser
ptracePtr was introduced in CL 470299 for darwin but it's not used on this platform. Also, the argument types for addr and data were swapped in the generated ptrace1Ptr (probably because the change was not generated but done manually). For #58387 Change-Id: I429ab0c741e19020d98729c34efabce1d9003f56 Reviewed-on: https://go-review.googlesource.com/c/go/+/526475 Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-07syscall: improve linux SysProcAttr documentationKir Kolyshkin
The SysProcAttr is OS-specific anyway, so it makes little sense to say that some fields are Linux-specific (they all are anyway). While at it, make sure to use complete sentences (add missing periods). Change-Id: Ic0afe3920c2561fd9a657f4edab21939a8f56d57 Reviewed-on: https://go-review.googlesource.com/c/go/+/525395 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-07syscall: add support to get pidfd from ForkExec on LinuxKir Kolyshkin
Add PidFD support, so that if the PidFD pointer in SysProcAttr is not nil, ForkExec (and thus all its users) obtains a pidfd from the kernel during clone(), and writes the result (or -1, if the functionality is not supported by the kernel) into *PidFD. The functionality to get pidfd is implemented for both clone3 and clone. For the latter, an extra argument to rawVforkSyscall is needed, thus the change in asm files. Add a trivial test case checking the obtained pidfd can be used to send a signal to a process, using pidfd_send_signal. To test clone3 code path, add a flag available to tests only. Updates #51246. Change-Id: I2212b69e1a657163c31b4a6245b076bc495777a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/520266 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com>
2023-09-05all: use ^TestName$ regular pattern for invoking a single testDmitri Shuralyov
Use ^ and $ in the -run flag regular expression value when the intention is to invoke a single named test. This removes the reliance on there not being another similarly named test to achieve the intended result. In particular, package syscall has tests named TestUnshareMountNameSpace and TestUnshareMountNameSpaceChroot that both trigger themselves setting GO_WANT_HELPER_PROCESS=1 to run alternate code in a helper process. As a consequence of overlap in their test names, the former was inadvertently triggering one too many helpers. Spotted while reviewing CL 525196. Apply the same change in other places to make it easier for code readers to see that said tests aren't running extraneous tests. The unlikely cases of -run=TestSomething intentionally being used to run all tests that have the TestSomething substring in the name can be better written as -run=^.*TestSomething.*$ or with a comment so it is clear it wasn't an oversight. Change-Id: Iba208aba3998acdbf8c6708e5d23ab88938bfc1e Reviewed-on: https://go-review.googlesource.com/c/go/+/524948 Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-05syscall: fixup TestUseCgroupFD error checkingKir Kolyshkin
Fixup for CL 520265; of course errors returned from os/exec are wrapped. While at it, change the order -- it seems more readable this way. Change-Id: Ifb5d0c113f4fb2b3cc4be922021dbd2a8a886b7b Reviewed-on: https://go-review.googlesource.com/c/go/+/524959 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-09-03syscall: inline TestUseCgroupFDHelperKir Kolyshkin
This way, the test case is self-contained, and the test output no longer has useless lines related to TestUseCgroupFDHelper. Change-Id: I575a03b678c8c08a87353f6dc00c35a90ec561ca Reviewed-on: https://go-review.googlesource.com/c/go/+/525196 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: 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: Tobias Klauser <tobias.klauser@gmail.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-09-01syscall: fix skipping TestUseCgroupFDKir Kolyshkin
The check in prepareCgroupFD tried to find out if clone3 with CLONE_INTO_CGROUP flag is supported, by supplying arguments in SysProcAttr that will make ForkExec use clone3 with CLONE_INTO_CGROUP and fail. CL 456375 inadvertently broke the above check by adding more errno values to ignore. As a result, TestUseCgroupFD is always skipped, even when the test could in fact be run. Fix by removing the check entirely, instead let's use the functionality and figure out from the errno if this has failed because of unsupported syscall, lack of permissions, or other reason. Change-Id: I108b27b6cfeec390ebd3f161ac39e8597569b666 Reviewed-on: https://go-review.googlesource.com/c/go/+/520265 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com> 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: Bryan Mills <bcmills@google.com>
2023-08-24syscall: skip TestUnshareMountNameSpaceChroot on platforms that require ↵Bryan C. Mills
external linking TestUnshareMountNameSpaceChroot attempts to build a statically-linked binary to run in a chroot, and sets CGO_ENABLED=0 in order to do so. Rather than trying to figure out some other way to coax the linker into building a static binary, let's just skip the test on Linux platforms that require external linking (namely android/arm). This should fix the build failure reported in https://build.golang.org/log/1ea245a9c2e916c81043db177be76778bab00058. While we're here, let's also fix the failure logging to make the text readable! Updates #46330. Change-Id: I4fa07640ce012ac141bf4698bc3215a7f146062c Reviewed-on: https://go-review.googlesource.com/c/go/+/522182 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-22syscall: add support for openbsd/ppc64Joel Sing
Add syscall support for the openbsd/ppc64 port. Updates #56001 Change-Id: I695c5c296e90645515de0c8f89f1bc57e976679d Reviewed-on: https://go-review.googlesource.com/c/go/+/475636 Reviewed-by: Eric Grosse <grosse@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Joel Sing <joel@sing.id.au> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-17syscall: don't check non-existent return code in GetStartupInfoTobias Klauser
Fixes #31316 Change-Id: I1ca5968836e7bcad91496e4ed3cf1a0caf1375f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/520275 Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-08-16syscall: remove deprecation noticeIan Lance Taylor
The syscall package isn't getting new system call support, but it is not deprecated. Fixes #60797 Change-Id: I33b60269f9ce70ac2108fa0f3d42fd87a3076bf1 Reviewed-on: https://go-review.googlesource.com/c/go/+/520018 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-10syscall: avoid setting O_NONBLOCK needlessly by checking flags beforehandAndy Pan
Change-Id: I097a2941f1d1a7fd98ccf1534940d03f47ac3229 Reviewed-on: https://go-review.googlesource.com/c/go/+/517675 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Andy Pan <panjf2000@gmail.com>
2023-08-05runtime,syscall: invert openbsd architecture testsJoel Sing
Rather than testing for architectures that use libc-based system calls, test that it is not the single architecture that Go is still using direct system calls. This reduces the number of changes needed for new openbsd ports. Updates #36435 Updates #61546 Change-Id: I79c4597c629b8b372e9efcda79e8f6ff778b9e8e Reviewed-on: https://go-review.googlesource.com/c/go/+/516016 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Joel Sing <joel@sing.id.au> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-07-28syscall, cmd/cgo: skip tests that shouldn't run under 'unshare -n -r'Dmitri Shuralyov
A small number of tests in the main tree are currently skipped in LUCI because our builders there run tests without root. Unfortunately, these tests begin to run when run under 'unshare -n -r' as implemented in the current iteration of a no-network check. Add targeted builder-only skips so that they don't begin to run and fail with a false positive. Updates #10719. For #30612. Change-Id: I6dd320714a279c395882c1b2ebfbb2fce58f913b Reviewed-on: https://go-review.googlesource.com/c/go/+/513779 Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-07-28syscall: skip TestUnshare if there's nothing more to unshareDmitri Shuralyov
Tests that need to use the internet are expected not to run when -short test flag is set, and the Go build system automatically catches when a test forgets that. It does this by unsharing all real network interfaces and leaving only a loopback interface in a new network namespace. TestUnshare tests that a process started with CLONE_NEWNET unshare flag has fewer network interfaces than before. Of course, if /proc/net/dev starts out with a single loopback interface, the test would fail with a false positive: === RUN TestUnshare exec_linux_test.go:139: Got 3 lines of output, want <3 --- FAIL: TestUnshare (0.00s) Give the test what it wants: a skip when the environment doesn't meet the minimum requirements for the test, and more useful log output if it fails. Change-Id: I6b9c29d88ce725e640a7ee86c7e1be9761f21b02 Reviewed-on: https://go-review.googlesource.com/c/go/+/513762 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2023-07-20net: remove sysSocket fallback for Windows 7qmuntal
`syscall.ForkLock` is not used in `syscall.StartProcess` since CL 288297, so using it in `sysSocket` makes no sense. This CL goes a little bit further and removes the `sysSocket` fallback for Windows 7, since it is not supported since go 1.21 (#57003). Updates #60942 Change-Id: If14a0d94742f1b80af994f9f69938701ee41b402 Reviewed-on: https://go-review.googlesource.com/c/go/+/506136 Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2023-07-10syscall: serialize locks on ForkLock on platforms where forkExecPipe is not ↵Bryan C. Mills
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>
2023-07-06os: do not skip directory entries with zero inodes on wasip1Achille Roussel
When building programs to GOOS=wasip1, the program does not have the guarantees that the underlying directories will come from a file system where a zero inode value indicates that the entry was deleted but not yet removed from the directory. The host runtime may be running on windows or may be exposing virtual user-space file systems that do not have the concept of inodes. In those setup, we assume that the host runtime is in charge of dealing with edge cases such as skipping directory entries with zero inodes when needed, and the guest application should trust the list of entries that it sees; therefore, we disable skipping over zero inodes on wasip1. Change-Id: I99aa562441cdb4182965f270af054cf3cf7f8f20 Reviewed-on: https://go-review.googlesource.com/c/go/+/507915 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> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
2023-07-04os, syscall: update unreachable link about =C: envsOleksandr Redko
Change-Id: I185dec133599f9c69fda7563697bbc33e433fb78 Reviewed-on: https://go-review.googlesource.com/c/go/+/507135 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-06-29syscall: stub Getrlimit on wasip1Chris O'Hara
This is a prerequisite to enabling the pure Go resolver for wasip1. Change-Id: Iecd8a18ce4c9eb69a697d29930bedb7175b4f0ce Reviewed-on: https://go-review.googlesource.com/c/go/+/500577 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-06-27syscall: clarify which handles are affected by SysProcAttr.NoInheritHandlesqmuntal
SysProcAttr.NoInheritHandles doc comment is not clear about which handles are affected by it. This CL clarifies that it not only affects the ones passed in AdditionalInheritedHandles, but also the ones passed in ProcAttr.Files, which are required to be stderr, stdin and stdout when calling syscall.StartProcess. Updates #60942 Change-Id: I5bc5b3604b6db04b83f6764d5c5ffbdafeeb22fb Reviewed-on: https://go-review.googlesource.com/c/go/+/505515 Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-06-27syscall: try non-blocking stdio on wasip1Chris O'Hara
Try to set stdio to non-blocking mode before the os package calls NewFile for each fd. NewFile queries the non-blocking flag but doesn't change it, even if the runtime supports non-blocking stdio. Since WebAssembly modules are single-threaded, blocking system calls temporarily halt execution of the module. If the runtime supports non-blocking stdio, the Go runtime is able to use the WASI net poller to poll for read/write readiness and is able to schedule goroutines while waiting. Change-Id: I1e3ce68a414e3c5960ce6a27fbfd38556e59c3dc Reviewed-on: https://go-review.googlesource.com/c/go/+/498196 Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Achille Roussel <achille.roussel@gmail.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-06-14syscall: Fix Getwd on Windows to correctly handle long paths.Qi Xiao
Fixes #60051. Change-Id: Ia68ca0493912cb09d8c1d36a144bf0725842af1d Reviewed-on: https://go-review.googlesource.com/c/go/+/502415 Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-06-14all: fix spelling errorsAlexander Yastrebov
Fix spelling errors discovered using https://github.com/codespell-project/codespell. Errors in data files and vendored packages are ignored. Change-Id: I83c7818222f2eea69afbd270c15b7897678131dc GitHub-Last-Rev: 3491615b1b82832cc0064f535786546e89aa6184 GitHub-Pull-Request: golang/go#60758 Reviewed-on: https://go-review.googlesource.com/c/go/+/502576 Auto-Submit: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
2023-06-10syscall: implement Ptrace{Set,Get}Regs using PTRACE_{GET,SET}REGSET on all ↵chenguoqi
linux platforms In the ptrace system call, most of the newer architectures (e.g. arm64,riscv64,loong64) do not provide support for the command PTRACE_{GET, SET}REGS. The Linux kernel 2.6.33-rc7[1] introduces support for the command PTRACE_{GET,SET}REGSET, which exports different types of register sets depending on the NT_* types, completely overriding the functionality provided by PTRACE_{GET,SET}REGS. [1] https://lore.kernel.org/all/20100211195614.886724710@sbs-t61.sc.intel.com/ Fixes #60679. Change-Id: I8c2671d64a7ecd654834740f4f1e1e50c00edcae Reviewed-on: https://go-review.googlesource.com/c/go/+/501756 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-06-05syscall: don't panic when argv is nil on freebsdRoland Shoemaker
The workaround in CL 69970044 introduced a panic when StartProcess is called with empty argv. Check the length before trying to access it. Change-Id: Ic948d86c7067a21c484ba24e100d1f1f80179730 Reviewed-on: https://go-review.googlesource.com/c/go/+/500415 Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-05-30syscall: fix ComputerName on Windowsqmuntal
GetComputerName expects n to be the size of the buffer, and on output contains the number of characters copied to the buffer. CL 493036 broke ComputerName by always setting n to 0. Change-Id: I3f4b30d2f9825d321a6d28ec82bdc7b6294e04e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/499035 Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-05-25net: implement wasip1 FileListener and FileConnChris O'Hara
Implements net.FileListener and net.FileConn for wasip1. net.FileListener can be used with a pre-opened socket. If the WASM module knows the file descriptor, a listener can be constructed with: l, err := net.FileListener(os.NewFile(fd, "")) If the WASM module does not know the file descriptor, but knows that at least one of the preopens is a socket, it can find the file descriptor and construct a listener like so: func findListener() (net.Listener, error) { // We start looking for pre-opened sockets at fd=3 because 0, 1, // and 2 are reserved for stdio. Pre-opened directories also // start at fd=3, so we skip fds that aren't sockets. Once we // reach EBADF we know there are no more pre-opens. for preopenFd := uintptr(3); ; preopenFd++ { l, err := net.FileListener(os.NewFile(preopenFd, "")) var se syscall.Errno switch errors.As(err, &se); se { case syscall.ENOTSOCK: continue case syscall.EBADF: err = nil } return l, err } } A similar strategy can be used with net.FileConn and pre-opened connection sockets. The wasmtime runtime supports pre-opening listener sockets: $ wasmtime --tcplisten 127.0.0.1:8080 module.wasm Change-Id: Iec6ae4ffa84b3753cce4f56a2817e150445db643 Reviewed-on: https://go-review.googlesource.com/c/go/+/493358 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Bypass: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>