aboutsummaryrefslogtreecommitdiff
path: root/src/internal/syscall
AgeCommit message (Collapse)Author
2025-06-10os: disallow Root.Remove(".") on Plan 9, js, and WindowsDamien Neil
Windows already forbids this, since removing the root causes a sharing violation (can't delete the directory while the os.Root has a handle open to it), but add a more explicit check for attempts to delete "." and return EINVAL. Note that this change to Windows doesn't affect operations like Root.Remove("dir/."), since the path is cleaned into just "dir" before attempting the deletion. Fixes #73863 Change-Id: I0f45ccb6c9f171d3a52831632c134150388d77b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/679377 Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-21os: add Root.MkdirAllDamien Neil
For #67002 Change-Id: Idd74b5b59e787e89bdfad82171b6a7719465f501 Reviewed-on: https://go-review.googlesource.com/c/go/+/674116 Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-05-20net: avoid using Windows' TransmitFile on non-server machinesShibi J M
Windows API's TransmitFile function is limited to two concurrent operations on workstation and client versions of Windows. This change modifies the net.sendFile function to perform no work in such cases so that TransmitFile is avoided. Fixes #73746 Change-Id: Iba70d5d2758bf986e80c78254c8e9e10b39bb368 GitHub-Last-Rev: 315ddc0cd8034f52632dc31baf35057a8bad9bcd GitHub-Pull-Request: golang/go#73758 Reviewed-on: https://go-review.googlesource.com/c/go/+/673855 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-05-14os: don't follow symlinks on Windows when O_CREATE|O_EXCLDamien Neil
Match standard Unix behavior: Symlinks are not followed when O_CREATE|O_EXCL is passed to open. Thanks to Junyoung Park and Dong-uk Kim of KAIST Hacking Lab for discovering this issue. Fixes #73702 Fixes CVE-2025-0913 Change-Id: Ieb46a6780c5e9a6090b09cd34290f04a8e3b0ca5 Reviewed-on: https://go-review.googlesource.com/c/go/+/672396 Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
2025-05-05net,os: support converting between *os.File and net.Conn on Windowsqmuntal
The runtime poller and os.NewFile recently gained support for disassociating the handle from the runtime poller IOCP (see CL 664455). This was the main blocker for allowing the conversion between *os.File and net.Conn. Implementing the conversion is now trivial. The only remaining work, implemented in this CL, is improving os.NewFile to also support socket handles and updating some build tags so that Windows can share almost the same net's File implementation as Unix. There is one important limitation, though: the duplicated socket handle returned by the various File methods in the net package is not usable on other process. If someone needs to pass a socket handle to another process, they should manually call the WSADuplicateSocket Windows API passing the process ID of the target process. Fixes #9503. Fixes #10350. Updates #19098. Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-race,gotip-windows-amd64-longtest,gotip-windows-arm64 Change-Id: Ic43cadaac2662b925d57a9d362ddc7ae21d1b56e Reviewed-on: https://go-review.googlesource.com/c/go/+/668195 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-05-01os: fix Root.Mkdir permission bits on OpenBSDJosh Rickmar
Pass missing mode bits in the mkdirat() syscall wrapper. Fixes #73559 Change-Id: I54b1985bd77b1fe5d1a48acab9f2597f8c931854 GitHub-Last-Rev: 669c17361d86bc9065bb6b47a2d60aa86bcfa12d GitHub-Pull-Request: golang/go#73565 Reviewed-on: https://go-review.googlesource.com/c/go/+/669375 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2025-04-24os,internal/poll: disassociate handle from IOCP in File.Fdqmuntal
Go 1.25 will gain support for overlapped IO on handles passed to os.NewFile thanks to CL 662236. It was previously not possible to add an overlapped handle to the Go runtime's IO completion port (IOCP), and now happens on the first call the an IO method. This means that there is code that relies on the fact that File.Fd returns a handle that can always be associated with a custom IOCP. That wouldn't be the case anymore, as a handle can only be associated with one IOCP at a time and it must be explicitly disassociated. To fix this breaking change, File.Fd will disassociate the handle from the Go runtime IOCP before returning it. It is then not necessary to defer the association until the first IO method is called, which was recently added in CL 661955 to support this same use case, but in a more complex and unreliable way. Updates #19098. Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-race,gotip-windows-amd64-longtest,gotip-windows-arm64 Change-Id: Id8a7e04d35057047c61d1733bad5bf45494b2c28 Reviewed-on: https://go-review.googlesource.com/c/go/+/664455 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-14internal/poll: disable SIO_UDP_NETRESET on WindowsJames Tucker
Disable the reception of NET_UNREACHABLE (TTL expired) message reporting on UDP sockets to match the default behavior of sockets on other plaforms. See https://learn.microsoft.com/en-us/windows/win32/winsock/winsock-ioctls#sio_udp_netreset This is similar to, but a different case from the prior change 3114bd6 / https://golang.org/issue/5834 that disabled one of the two flags influencing behavior in response to the reception of related ICMP. Updates #5834 Updates #68614 Change-Id: I39bc77ab68f5edfc14514d78870ff4a24c0f645e GitHub-Last-Rev: 78f073bac226aeca438b64acc2c66f76c25f29f8 GitHub-Pull-Request: golang/go#68615 Reviewed-on: https://go-review.googlesource.com/c/go/+/601397 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2025-04-06all: use slices.Equal to simplify codecuishuang
Change-Id: Ib3be7cee6ca6dce899805aac176ca789eb2fd0f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/661738 Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-04-04internal/syscall/windows: use unsafe.Pointer instead of uintptrqmuntal
Some functions accept a uintptr when they should accept an unsafe.Pointer, else the compiler won't know that the pointer should be kept alive across the call, potentially causing undefined behavior. Fixes #73156 (potentially) Change-Id: I29c847eb8ffbb785fabf217e9f3718d10cfb5047 Reviewed-on: https://go-review.googlesource.com/c/go/+/662855 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-04-04internal/poll: simplify execIOqmuntal
execIO has multiple return paths and multiple places where error is mangled. This CL simplifies the function by just having one return path. Some more tests have been added to ensure that the error handling is done correctly. Updates #19098. Change-Id: Ida0b1e85d4d123914054306e5bef8da94408b91c Reviewed-on: https://go-review.googlesource.com/c/go/+/662215 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Carlos Amedee <carlos@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-04-03internal/syscall/windows: define NtQueryInformationFile buffer as unsafe.Pointerqmuntal
The unsafe.Pointer -> uintptr conversion must happen when calling syscall.Syscall, not when calling the auto-generated wrapper function, else the Go compiler doesn't know that it has to keep the pointer alive. This can cause undefined behavior and stack corruption. Fixes #73135. Fixes #73112 (potentially). Fixes #73128 (potentially). Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-race Change-Id: Ib3ad8b99618d8997bfd0742c0e44aeda696856c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/662575 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Carlos Amedee <carlos@golang.org>
2025-04-01internal/poll: defer IOCP association until first IO operationqmuntal
Defer the association of the IOCP to the handle until the first I/O operation is performed. A handle can only be associated with one IOCP at a time, so this allows external code to associate the handle with their own IOCP and still be able to use a FD (through os.NewFile) to pass the handle around (e.g. to a child process standard input, output, and error) without having to worry about the IOCP association. This CL doesn't change any user-visible behavior, as os.NewFile still initializes the FD as non-pollable. For #19098. Change-Id: Id22a49846d4fda3a66ffcc0bc1b48eb39b395dc5 Reviewed-on: https://go-review.googlesource.com/c/go/+/661955 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-31os: avoid symlink races in RemoveAll on WindowsDamien Neil
Make the openat-using version of RemoveAll use the appropriate Windows equivalent, via new portable (but internal) functions added for os.Root. We could reimplement everything in terms of os.Root, but this is a bit simpler and keeps the existing code structure. Fixes #52745 Change-Id: I0eba0286398b351f2ee9abaa60e1675173988787 Reviewed-on: https://go-review.googlesource.com/c/go/+/661575 Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-31os,internal/poll: support I/O on overlapped handles not added to the pollerqmuntal
Calling syscall.ReadFile and syscall.WriteFile on overlapped handles always need to be passed a valid *syscall.Overlapped structure, even if the handle is not added to a IOCP (like the Go runtime poller). Else, the syscall will fail with ERROR_INVALID_PARAMETER. We also need to handle ERROR_IO_PENDING errors when the overlapped handle is not added to the poller, in which case we need to block until the operation completes. Previous CLs already added support for overlapped handles to the poller, mostly to keep track of the file offset independently of the file pointer (which is not supported for overlapped handles). Fixed #15388. Updates #19098. Change-Id: I2103ab892a37d0e326752ae8c2771a43c13ba42e Reviewed-on: https://go-review.googlesource.com/c/go/+/661795 Auto-Submit: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
2025-03-28os: add Root.SymlinkDamien Neil
For #67002 Change-Id: Ia1637b61eae49e97e1d07f058ad2390e74cd3403 Reviewed-on: https://go-review.googlesource.com/c/go/+/660635 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> Auto-Submit: Damien Neil <dneil@google.com>
2025-03-28internal/poll: don't skip empty writes on Windowsqmuntal
Empty writes might be important for some protocols. Let Windows decide what do with them rather than skipping them on our side. This is inline with the behavior of other platforms. While here, refactor the Read/Write/Pwrite methods to reduce one indentation level and make the code easier to read. Fixes #73084. Change-Id: Ic5393358e237d53b8be6097cd7359ac0ff205309 Reviewed-on: https://go-review.googlesource.com/c/go/+/661435 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-27internal/syscall/windows: run go generateqmuntal
CL 660595 manually edited zsyscall_windows.go, making it be out of sync with its associated //sys directive. Longtest builders are failing due to that. Fixes #73069. Change-Id: If7256ef4b831423e4925fb6e5656fe3f7ef77fea Reviewed-on: https://go-review.googlesource.com/c/go/+/661275 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-26internal/poll: support async file operations on Windowsqmuntal
This CL adds support for async file operations on Windows. The affected functions are Read, Write, Pread, and Pwrite. The code has been slightly refactored to avoid duplication. Both the async and sync variants follow the same code path, with the exception of the async variant passes an overlapped structure to the syscalls and supports the use of a completion port. This doesn't change any user-facing behavior, as the os package still sets the pollable parameter to false when calling FD.Init. For #19098. Change-Id: Iead6e51fa8f57e83456eb5ccdce28c2ea3846cc2 Reviewed-on: https://go-review.googlesource.com/c/go/+/660595 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-03-24os: add Root.LinkDamien Neil
For #67002 Change-Id: I223f3f2dbc8b02726f4ce5a017c628c4a20f109a Reviewed-on: https://go-review.googlesource.com/c/go/+/659757 Reviewed-by: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-21internal/syscall/unix: add missing cgo_import_dynamics for AIXDamien Neil
Change-Id: Ief4c6dd8340e07556692d2bde2284a3b7afb2444 Reviewed-on: https://go-review.googlesource.com/c/go/+/659756 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-21internal/syscall/windows: set SYNCHRONIZE flag in DeleteatDamien Neil
Change-Id: Ice23659cf089b4f837d73b2db5b6eccd7562164e Reviewed-on: https://go-review.googlesource.com/c/go/+/659616 Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2025-03-20os: add Root.RenameDamien Neil
For #67002 Change-Id: Ifb1042bc5ceaeea64296763319b24634bbcb0bf0 Reviewed-on: https://go-review.googlesource.com/c/go/+/659416 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-03-19internal/syscall/unix: fix number of params for unlinkatKir Kolyshkin
This reverts the change to Unlinkat done in CL 659415, as it appears to be wrong. While at it, let's unify argument formatting for better readability (and also so those parameters are easier to count). Change-Id: I092105f85de107e0495afed3cd66c039343250f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/659357 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-19internal/syscall/unix: use correct number of params in unlinkat, fchownatDamien Neil
We were calling syscall6 with an incorrect parameter count, omitting the flags parameter. Change-Id: Ife606bd57c1e4b899c0340767e9197bbe0aa81a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/659415 Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-18os: add Root.ChtimesDamien Neil
For #67002 Change-Id: I9b10ac30f852052c85d6d21eb1752a9de5474346 Reviewed-on: https://go-review.googlesource.com/c/go/+/649515 Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.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-19path/filepath: use RtlIsDosDeviceName_U to detect Windows devicesqmuntal
RtlIsDosDeviceName_U is specifically designed to detect Windows devices. We were using GetFullPathName to do this, but it's not the right API for the job, as it is slower and allocates more memory. goos: windows goarch: amd64 pkg: path/filepath cpu: Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ IsLocal-12 5.685µ ± 59% 1.853µ ± 12% -67.41% (p=0.000 n=10) │ old.txt │ new.txt │ │ B/op │ B/op vs base │ IsLocal-12 496.00 ± 0% 48.00 ± 0% -90.32% (p=0.000 n=10) │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ IsLocal-12 10.000 ± 0% 6.000 ± 0% -40.00% (p=0.000 n=10) Change-Id: Ib40ad7a90ab93cf7051c8d6becbce4d287f10f4e Reviewed-on: https://go-review.googlesource.com/c/go/+/650578 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-02-18all: use a more straightforward return valuecuishuang
Change-Id: I27e86c221da7f541c4823f501801e02942c9a829 Reviewed-on: https://go-review.googlesource.com/c/go/+/649935 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@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-14internal/syscall/unix: correct fchmodat on openbsdJoel Sing
This is incorrectly calling the fchownat trampoline - call fchmodat as intended. Change-Id: I7b1e758d456006303ca95b70df9e6b52d3020158 Reviewed-on: https://go-review.googlesource.com/c/go/+/649655 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Bypass: Damien Neil <dneil@google.com> Reviewed-by: Damien Neil <dneil@google.com> Commit-Queue: Damien Neil <dneil@google.com> Auto-Submit: Damien Neil <dneil@google.com>
2025-02-14internal/syscall/unix: fix fchownat linkname for AIX & SolarisDamien Neil
Typo fix: libc_chownat => libc_fchownat Change-Id: I6721a988c19e3438b967a73559159c948ed51a0e Reviewed-on: https://go-review.googlesource.com/c/go/+/649636 Auto-Submit: Damien Neil <dneil@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-13os: add Root.ChownDamien Neil
For #67002 Change-Id: I546537618cbe32217fa72264d49db2b1a1d3b6db Reviewed-on: https://go-review.googlesource.com/c/go/+/648295 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-12internal/syscall: add cgo_import_dynamic for Fchmodat on AIX and SolarisDamien Neil
For #67002 Change-Id: I1709fd51ba52c074501420943d311c785a49d851 Reviewed-on: https://go-review.googlesource.com/c/go/+/649015 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
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>
2024-12-21internal/syscall/unix: apply fstatat fix to linux/mips64leCherry Mui
Apply CL 633280 to linux/mips64le, as it has the same struct as mips64. Updates #70659. Change-Id: Ibab635e69e44682eb214bf6a00f4cd75816b2d34 Reviewed-on: https://go-review.googlesource.com/c/go/+/637739 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Cherry Mui <cherryyz@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-11-21all: fix some function names and typos in commentcuishuang
Change-Id: I07e7c8eaa5bd4bac0d576b2f2f4cd3f81b0b77a4 Reviewed-on: https://go-review.googlesource.com/c/go/+/630055 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Russ Cox <rsc@golang.org> Auto-Submit: Ian Lance Taylor <iant@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-20os: add Root.RemoveDamien Neil
For #67002 Change-Id: Ibbf44c0bf62f53695a7399ba0dae5b84d5efd374 Reviewed-on: https://go-review.googlesource.com/c/go/+/627076 Reviewed-by: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-20os: add RootDamien Neil
Add os.Root, a type which represents a directory and permits performing file operations within that directory. For #67002 Change-Id: I863f4f1bc320a89b1125ae4237761f3e9320a901 Reviewed-on: https://go-review.googlesource.com/c/go/+/612136 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-19internal/syscall/unix, os: add and use Waitid syscall wrapper on linuxTobias Klauser
Instead of open-coding the waitid syscall wrapper add it to internal/syscall/unix. As the syscall is currently only used on Linux, switch the implementation in os.(*Process).blockUntilWaitable to use the 128-byte unix.SiginfoChild type instead of a plain 128-byte buffer. Also use ignoringEINTR for the waitid calls instead of open-coding it. Change-Id: I8dc47e361faa1f5e912d5de021f119c91c9f12f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/629655 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> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2024-11-19os/user: fix race detector failureqmuntal
The race detector doesn't like that windows.GetSid* functions return pointers to the SID structure. This change makes these functions return values instead and mark them with nocheckptr. Fixes #70378 Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-race Change-Id: Iba39d75bb31679d25a5ee43b51e4abb0c435dbac Reviewed-on: https://go-review.googlesource.com/c/go/+/628995 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-15os/user: support built-in service user accounts on Windowsqmuntal
Built-in service user accounts should be treated as special cases of well-known groups and allowed in user.Lookup and user.LookupId. Namely, these accounts are: - NT AUTHORITY\SYSTEM (S-1-5-18) - NT AUTHORITY\LOCAL SERVICE (S-1-5-19) - NT AUTHORITY\NETWORK SERVICE (S-1-5-20) See https://learn.microsoft.com/en-us/windows/win32/services/service-user-accounts. Note that #49509 also mentions S-1-5-17 (NT AUTHORITY\IUSR) as another well-known group that should be treated as a user. I haven't found any documentation supporting this claim, and it is not an account that is used usually, so I'm not adding it for now. This CL is heavily based on CL 452497. Fixes #49509 Change-Id: I6e204ddfb4ed0c01b4503001cf284602531e4a88 Reviewed-on: https://go-review.googlesource.com/c/go/+/626255 Reviewed-by: Cherry Mui <cherryyz@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: David Chase <drchase@google.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-10-28cmd: use internal/syscall/windows to get Windows versionqmuntal
internal/syscall/windows already provides a function to get the Windows version. There is no need to use golang.org/x/sys/windows for this. Change-Id: If31e9c662b10716ed6c3e9054604366e494345cf Reviewed-on: https://go-review.googlesource.com/c/go/+/622815 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-10-21internal/syscall/windows: set write access when O_TRUNC is usedqmuntal
Whenn O_TRUNC is set, Opentat ends up calling syscall.Ftruncate, which needs write access. Make sure write access is not removed when O_TRUNC and O_APPEND are both set. Updates #67002. Change-Id: Iccc470b7be3c62144318d6a707057504f3b74c97 Reviewed-on: https://go-review.googlesource.com/c/go/+/620576 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-10-14internal/syscall/windows: fix handle leak in Mkdiratqmuntal
Mkdirat does not close the handle returned by CreateFile, but it should. Mkdirat has been introduced in this developer cycle, so it is not necessary to backport this fix to any release branch. Change-Id: Icddac5ccdc6a142a5be5392a39aba2ae7cc9c69a Reviewed-on: https://go-review.googlesource.com/c/go/+/620195 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Quim Muntal <quimmuntal@gmail.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-07net: detect EAI_ADDRFAMILY for cgo host lookup on FreeBSDMichael Anthony Knyszek
For #61095. Change-Id: Iff9f19f6f2eada739967774b50d949f9c5893ee0 Cq-Include-Trybots: luci.golang.try:gotip-darwin-amd64_14,gotip-freebsd-amd64 Reviewed-on: https://go-review.googlesource.com/c/go/+/618015 TryBot-Bypass: Michael Knyszek <mknyszek@google.com> Reviewed-by: Damien Neil <dneil@google.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>