Commit Graph

1303 Commits

Author SHA1 Message Date
Bryan C. Mills
da31bd327a unix: lock the thread for TestPrctlRetInt
The prctl system calls used in this test modify and examine the
properties of the current thread. For the test to work correctly (and
to avoid interfering with other tests), the thread must be locked for
those calls and should not be reused when the test completes.

Fixes golang/go#50607

Change-Id: I2b14e6c0440155f4287d97f0bb72099af291ba0d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/378555
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-01-14 19:58:35 +00:00
Tobias Klauser
5a964db013 windows: add Get{Active,Maximum}ProcesorCount
Reference:
https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getactiveprocessorcount
https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getmaximumprocessorcount

Change-Id: Ifca711b82f112b395eac3b96266f63b5623881fc
Reviewed-on: https://go-review.googlesource.com/c/sys/+/374435
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Patrik Nyblom <pnyb@google.com>
Trust: Patrik Nyblom <pnyb@google.com>
Run-TryBot: Patrik Nyblom <pnyb@google.com>
2022-01-11 09:28:08 +00:00
Tobias Klauser
a018aaa089 unix/linux: update to Linux Kernel 5.16
Change-Id: I83f84e8aa6f75fc2a6fd1744546e8dc3d5bc3a55
Reviewed-on: https://go-review.googlesource.com/c/sys/+/377134
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2022-01-10 18:14:12 +00:00
Jason A. Donenfeld
1d35b9e2eb windows/svc: use NtQuerySystemInformation in IsWindowsService
This brings the algorithm more exactly in line with what .NET does for
the identically named function. Specifically, instead of using
OpenProcess, which requires rights that restricted services might not
have, we use NtQuerySystemInformation(SYSTEM_PROCESS_INFORMATION) to
find the parent process image name and session ID.

Fixes golang/go#44921.

Change-Id: Ie2ad7521cf4c530037d086e61dbc2413e4e7777c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/372554
Trust: Jason Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Patrik Nyblom <pnyb@google.com>
Trust: Patrik Nyblom <pnyb@google.com>
Run-TryBot: Patrik Nyblom <pnyb@google.com>
2021-12-16 02:10:12 +00:00
Matt Layher
4abf325e02 unix: add netlink attribute type and policy type constants
Change-Id: I343785b938461c94c32d52fb632514293564311a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/372295
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-12-15 21:12:19 +00:00
Matt Layher
4825e8c387 unix: add WireGuard generic netlink interface constants on Linux
Change-Id: I619c49f745da8cfd17bc2aae28d97aff73daf4d5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/371674
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-12-14 23:44:02 +00:00
Jason A. Donenfeld
3b038e5940 windows: set pipe explicitly inheritable in test for go 1.16
Go 1.16 didn't create inheritable pipes yet, because we didn't have safe
process inheritance semantics worked out then. So, for this test,
explicitly mark the pipe as inheritable, in case this is running on Go
1.16.

Fixes golang/go#50160.

Change-Id: I2e59cf430ff35e7f59315b11b73e79b9aaf3e6ce
Reviewed-on: https://go-review.googlesource.com/c/sys/+/371694
Trust: Jason Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2021-12-14 17:07:44 +00:00
Matt Layher
024a26f5d6 unix: regenerate generic netlink controller constants
This adds support for generic netlink policy commands, and also regenerates the
constants using a shell one-liner for reproducibility in the future.

Change-Id: I868965c2a5abe2ff384e81223e03373465462f52
Reviewed-on: https://go-review.googlesource.com/c/sys/+/371654
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-12-14 15:06:14 +00:00
Jason A. Donenfeld
03aa0b5f68 windows: allocate attribute list with LocalAlloc, not individual items
We didn't want to wind up with Go pointers mangled by win32, so we were
previously copying the contents into a LocalAlloc'd blob, and then
adding that to the attribute list. The problem is that recent changes to
the API broke this design convention, to the point where it expects 0x18
byte objects to be added using size 0x8. This seems like an unfortunate
oversight from Microsoft, but there's nothing we can do about it. So we
can work around it by instead LocalAlloc'ing the actual container, and
then using the exact pointer value that's passed into Update.

This commit also adds a test that both makes sure that these functions
actually work, and provokes a UaF that's successfully caught, were you
to comment out the line of this commit that reads `al.pointers =
append(al.pointers, value)`.

Fixes golang/go#50134.

Change-Id: Ib73346d2d6ca3db601cd236596cefb564d9dc8f1
Reviewed-on: https://go-review.googlesource.com/c/sys/+/371276
Trust: Jason Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason Donenfeld <Jason@zx2c4.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Patrik Nyblom <pnyb@google.com>
Trust: Patrik Nyblom <pnyb@google.com>
Run-TryBot: Patrik Nyblom <pnyb@google.com>
2021-12-13 22:30:07 +00:00
Tobias Klauser
af8b642124 unix: use pipe2 syscall in Pipe on NetBSD
The pipe2 syscall is part of NetBSD since version 6.0 and thus exists in
all officially supported versions (6.0 through 6.1 and 7.0+).

Follows CL 94035 which did the same for package syscall.

Change-Id: Icfa7dfb13788c9a7425c641d0233b109e8c79e7f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/370794
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Trust: Benny Siegert <bsiegert@gmail.com>
2021-12-10 11:16:14 +00:00
Russ Cox
798191bca9 unix, plan9: avoid writing to p when Pipe(p) fails
Generally speaking Go functions make no guarantees
about what has happened to result parameters on error,
and Pipe is no exception: callers should avoid looking at
p if Pipe returns an error.

However, we had a bug in which ForkExec was using the
content of p after a failed Pipe, and others may too.
As a robustness fix, make Pipe avoid writing to p on failure.

windows.Pipe already avoided writing to p on failure.

For golang/go#50057.

Change-Id: I93ed06b06a9981793c119c1d7df689fbe79b4116
Reviewed-on: https://go-review.googlesource.com/c/sys/+/370614
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2021-12-09 17:19:07 +00:00
zhouguangyuan
97ca703d54 cpu: remove the declaration of function darwinSupportsAVX512
The implement of darwinSupportsAVX512 has been removed in CL 361255.
But the command "go install -buildmode=shared std" failed because the
declaration of it is remained in cpu/cpu_gc_x86.go. It should be removed.

Update golang/go#49233
For golang/go#49942

Change-Id: I8fa7c61c20457e49414930029b9f026c335aa421
Reviewed-on: https://go-review.googlesource.com/c/sys/+/368994
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
2021-12-05 18:29:25 +00:00
Tobias Klauser
94396e4217 windows: add ModuleEntry32 type and Module32{First,Next} wrappers
Reference:
https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/ns-tlhelp32-moduleentry32w
https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-module32firstw
https://docs.microsoft.com/en-us/windows/win32/api/tlhelp32/nf-tlhelp32-module32nextw

Change-Id: I5455cabdbaa8e7e25490f869ca349e3c6f67a0cf
Reviewed-on: https://go-review.googlesource.com/c/sys/+/369174
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Patrik Nyblom <pnyb@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Patrik Nyblom <pnyb@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Patrik Nyblom <pnyb@google.com>
2021-12-04 12:00:58 +00:00
Jason A. Donenfeld
fe61309f88 windows: add SetupAPI and CfgMgr32 functions
Simon and I have worked on these on and off for a number of projects
over the last 3 years and by now it's quite stable and mature. Rather
than carrying this around privately, these have now been updated to be
in the style of x/sys/windows, in this case matching how the
security_windows.go file does things. Specifically, because these APIs
are kind of hard to work with, and quite lengthy, we split them off into
a setupapi_windows.go file, just like security_windows.go.  We already
had the setupapierrors_windows.go file, so that's been folded into the
new one that contains the additional definitions nad functions.

These APIs are among the most obtuse to work with in all of Win32, so
considerable attention has been spent trying to make these wrappers both
quite "raw" so that they match the win32, but also accessible from Go.
The fact that they're so old in Windows history makes for a few tricky
things, like struct padding that doesn't quite match Go's rules, but
we've been able to accommodate basically everything after quite a bit of
work.

Change-Id: I0c2dd85e4bb40eee10186ffc92558a858bdf8c6a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/366654
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Patrik Nyblom <pnyb@google.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Simon Rozman <simon@rozman.si>
Reviewed-by: Patrik Nyblom <pnyb@google.com>
2021-11-24 21:15:45 +00:00
Jason A. Donenfeld
ef496fb156 windows: re-enable TestWinVerifyTrust with newly signed file
Rather than disabling this test, let's just not make it rely on
Microsoft files, whose signing validity period we can't depend on.
Instead, we include our own EV-signed artifact, with a Digicert
timestamp using a certificate valid for a decade.

Fixes golang/go#49651.
Fixes golang/go#49266.
For golang/go#46906.

Change-Id: Idadba346810017b8f769d6fac1ddd357d4dee93c
Reviewed-on: https://go-review.googlesource.com/c/sys/+/366655
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-23 17:31:58 +00:00
Bryan C. Mills
dee7805ff2 windows: skip TestWinVerifyTrust
This test is failing (with different failure modes) on two different
builders. Adding a skip until it can be made more robust.

For golang/go#49651
For golang/go#49266
Updates golang/go#46906

Change-Id: I0fdd0e6f729c37e234b62b65abc53003eb8834f0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/364794
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Patrik Nyblom <pnyb@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Patrik Nyblom <pnyb@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-11-17 18:06:35 +00:00
Kir Kolyshkin
0a5406a544 unix: add mount_setattr support for linux
This brings in mount_setattr(2) support, added to Linux 5.12 kernel and
documented at https://man7.org/linux/man-pages/man2/mount_setattr.2.html

Change-Id: I5609980c18aef80f9429a8c8cec8c1e129f74ab7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/363444
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
2021-11-16 06:13:58 +00:00
Ian Lance Taylor
0c823b97ae unix: avoid depending on consistent Revents type in TestPoll
For golang/go#49380

Change-Id: Ie1d370681962d9f69ef54b33ddf38e4c74a2e298
Reviewed-on: https://go-review.googlesource.com/c/sys/+/363660
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-11-13 00:15:01 +00:00
Michael Anthony Knyszek
faf0a1b62c unix: identify unexpected events that fired in TestPoll
Currently if TestPoll fails because an unexpected event fired, we just
print that it happened, not which one fired. #49380 has been difficult
to reproduce, so printing more information for this case would be
helpful.

Updates #49380.

Change-Id: I820c4b634536565487ee1474f8afe092a8a4443b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/363714
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-11-12 19:34:37 +00:00
Johan Jansson
7580c6e521 unix: factor out mkmerge into a proper package
Factor mkmerge.go and mkmerge_test.go into package internal/mkmerge.

Due to ignore constraints, mkmerge_test.go wasn't run by the Go
builders and failing tests were unnoticed.

Factoring mkmerge into its own package and removing ignore constraints
makes the tests run automatically by the Go builders.

Fixes golang/go#49484

Change-Id: I56a0b7220e40d1d7e5193490cb547cad4202f9ac
Reviewed-on: https://go-review.googlesource.com/c/sys/+/363334
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-12 16:43:55 +00:00
Johan Jansson
7c45f0c2c7 unix: mount Docker-based builder at x/sys
Mount the data volume for the Docker-based builder at x/sys instead of
x/sys/unix.

The x/sys/go.mod file was not included in the data volume when mounting
x/sys/unix. This breaks module-aware go commands that run within the
Docker container.

Fix this problem by mounting the volume at x/sys and updating the
working directory of the builder accordingly.

Updates golang/go#49484

Change-Id: I2346b5320413b48de4984c9d9e31203941336357
Reviewed-on: https://go-review.googlesource.com/c/sys/+/363594
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Bryan C. Mills <bcmills@google.com>
2021-11-12 16:43:26 +00:00
Bryan C. Mills
c6105e7cf7 unix: in TestClockNanosleep, compare wall times when sleeping until wall times
Previously, we were sleeping until a wall time but then comparing the
duration slept using monotonic time. If the wall time happens to jump
during the sleep, the monotonic time can legitimately be shorter than
the wall time.

Fixes golang/go#42513

Change-Id: Iaef8d9ba46082e821f5cb18c96b9869238d7af05
Reviewed-on: https://go-review.googlesource.com/c/sys/+/363456
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-11-12 14:30:42 +00:00
Bryan C. Mills
f221eed1c0 unix: in TestSelect, only error for an early wakeup on Linux
On Linux, 'man 2 select' explicitly lists the conditions under which
select may return before the timeout interval. Most other platforms
make no such guarantee, so do not test for it on those platforms.

Fixes golang/go#36409

Change-Id: I194a34af3132a7db7fc186dec9de67fa6dd0bfae
Reviewed-on: https://go-review.googlesource.com/c/sys/+/363455
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-11 21:35:25 +00:00
Bryan C. Mills
99a53858aa all: add missing //go:build comments
These were apparently overlooked in CL 357329, CL 294490, CL 296889,
and other various updates to this module. (I noticed them via gopls
while investigating golang/go#49466.)

Updates golang/go#41184

Change-Id: Id042bb6fe5282e6d528e9315acf2ad29d0df58ba
Reviewed-on: https://go-review.googlesource.com/c/sys/+/362577
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-10 15:43:04 +00:00
Bryan C. Mills
51b60fd695 windows/registry: lock OS thread while enumerating keys
CL 361154 updated the standard syscall package to document that
successive calls to syscall.RegEnumKeyEx must occur on the same OS
thread (after that requirement was empirically discovered in
golang/go#49320).

This use in x/sys needs to be updated to comply with the
newly-discovered requirement.

Fixes golang/go#49466.

Change-Id: Idc45d91f175e1db25c215213fcaa45982c2f5e6e
Reviewed-on: https://go-review.googlesource.com/c/sys/+/362576
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-09 18:48:56 +00:00
Tobias Klauser
02f5c0300f unix: fix fsync for read-only files on aix
On aix, the fsync syscall doesn't work on read-only files. Use
fsync_range instead to allow Fsync to work on any file.

Follow CL 254657 which did the same in package syscall.

For golang/go#41372

Change-Id: Ibc55ecf5c43e27a04281af1a204f847eeafeea63
Reviewed-on: https://go-review.googlesource.com/c/sys/+/362274
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-09 06:54:45 +00:00
Koichi Shiraishi
cbcd623f20 unix: generate darwinTests per GOARCH and enabled darwin/arm64 test
Change-Id: I1c5bb166f6971f83890a08413aa8b35fe23a0c04
Reviewed-on: https://go-review.googlesource.com/c/sys/+/357069
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-11-08 22:43:32 +00:00
Tobias Klauser
e0b2ad06fe unix: fix finalizer fd close bug in TestOpenByHandleAt
The raw fd is successively wrapped using os.NewFile, so dont defer close
the raw fd, but instead use (*os.File).Close.

Fixes golang/go#49403

Change-Id: I1f4b12536ff0abea6b1680a4ff932b7eefa57162
Reviewed-on: https://go-review.googlesource.com/c/sys/+/361995
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-07 10:43:06 +00:00
Tobias Klauser
ebca88c72f unix/linux: update Dockerfile to Go 1.17.3
Change-Id: I14bced7165e0d3307950e922048cd38b1197f5fe
Reviewed-on: https://go-review.googlesource.com/c/sys/+/361994
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2021-11-06 13:20:15 +00:00
Tobias Klauser
c75c47738b unix, windows: copy arrays by assignment instead of looping
Follow CL 360602 which did the same in package syscall.

Change-Id: Ibf6d86dea1cb118e869618c66da72da281adb2d7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/361574
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-11-05 18:34:46 +00:00
Keith Randall
7861aae155 cpu: pretend AVX-512 is disabled on Darwin
Darwin doesn't save/restore the AVX-512 mask registers when
processing a signal. Go generates lots of signals, which cause
the mask registers to randomly get clobbered. Better to pretend
that AVX-512 isn't supported.

Update golang/go#49233

Change-Id: I0dda77a6f205e10eefccd82e6f4f0f184dae42d9
Reviewed-on: https://go-review.googlesource.com/c/sys/+/361255
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Martin Möhrmann <martin@golang.org>
2021-11-03 23:57:46 +00:00
Tobias Klauser
ae416a5f93 unix: regenerate type Clockinfo on OpenBSD 6.9
OpenBSD 6.9 changed the definition of Clockinfo, leading
TestSysctlClockinfo to fail on OpenBSD 6.9 onwards. Since OpenBSD 6.8 is
no longer supported upstream, regenerate Clockinfo on that release and
test that SysctlClockInfo fails gracefully on OpenBSD 6.8 and earlier.

Fixes golang/go#47629
For golang/go#48977

Change-Id: Ia511b8601af11f70ffcce0f96764c69a67d626b8
Reviewed-on: https://go-review.googlesource.com/c/sys/+/360694
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
2021-11-03 18:47:34 +00:00
Koichi Shiraishi
4dd72447c2 unix: add stdint.h for mkall.sh on darwin/arm64
currently occured below error:
  In file included from /Users/zchee/go/src/golang.org/x/sys/unix/types_darwin.go:24:
  In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:63:
  In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/signal.h:146:
  In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/machine/_mcontext.h:34:
  In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/arm/_mcontext.h:36:
  In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/machine/_structs.h:35:
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/arm/_structs.h:482:2: error: unknown type name 'uint32_t'
  	uint32_t    fpsr;
  	^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/arm/_structs.h:483:2: error: unknown type name 'uint32_t'
  	uint32_t    fpcr;
  	^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/arm/_structs.h:489:2: error: unknown type name 'uint32_t'
  	uint32_t    fpsr;
  	^
  /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/arm/_structs.h:490:2: error: unknown type name 'uint32_t'
  	uint32_t    fpcr;
  	^
  4 errors generated.

Change-Id: Iba2520fbf600914d3e8ed54b073039a6470846f7
Reviewed-on: https://go-review.googlesource.com/c/sys/+/357070
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-02 19:28:58 +00:00
Tobias Klauser
a2f17f7b99 unix: allow passing optional args to SysctlKinfoProcSlice
This allows using SysctlKinfoProcSlice to e.g. query processes by user
id using the kern.proc.uid sysctl and is still backwards compatible to
original implementation, i.e. still allows the kern.proc.all sysctl
without any additional arguments.

Change-Id: Ia2d76ce5b91a077221891e1f2dfd79a38d2be52b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/359677
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-02 06:14:01 +00:00
Tobias Klauser
95da234e12 unix: add SysctlKinfoProc on darwin
This allows to get KinfoProc for a given process using
SysctlKinfoProcSlice("kern.proc.pid", pid) rather than having to query
all processes using SysctlKinfoProcSlice() and the extracting the
relevant KinfoProc.

Change-Id: I965ea5c77d6f3441592b4540c54ab56f6ac9e27d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/359676
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-02 06:13:51 +00:00
Tobias Klauser
39c9dd3799 unix/linux: update Dockerfile to Kernel 5.15
Change-Id: I032465fbaecd49ffb6048577cd2f3fcb3d8e11d0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/359678
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-11-01 20:44:03 +00:00
Hao Mou
611d5d6438 windows: fix test causing checkptr failure
TestNtCreateFileAndNtSetInformationFile is failing checkptr. Fix by
using replacing [:] with [:n:n].

Fixes golang/go#49217

Change-Id: I08e7ed41b33452c096cf40cdbf9d73989b769bdb
Reviewed-on: https://go-review.googlesource.com/c/sys/+/359496
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-10-31 06:41:16 +00:00
Koichi Shiraishi
b3129d9d10 unix: fix difference Stat_t type and Statfs_t type per GOARCH on darwin
In darwin/arm64, has the libc_fstat{fs} trampoline, not libc_fstat{fs}64.
But types_darwin.go defined same C types.

Change-Id: Ia33c60029eb59360e421f42ef79efe890eba3e3e
Reviewed-on: https://go-review.googlesource.com/c/sys/+/357071
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-10-30 16:08:13 +00:00
Tobias Klauser
565ff80d9b unix: change darwin Eproc/ExternProc members from int8 array to byte array
CL 328169 added Eproc and ExternProc types on darwin which have some
int8 array members containing human-readable strings. In order to make
it easier to convert these to Go strings, change them to byte arrays.

Change-Id: I200494fd90d8506bce0f52a039ea59703981c8d3
Reviewed-on: https://go-review.googlesource.com/c/sys/+/359674
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-10-30 16:03:51 +00:00
Jason A. Donenfeld
6e7872819d windows/svc: allow querying service start reason
The QueryServiceDynamicInformation API makes it possible to determine
why a service started. This is declared as an optional function because
the API is Win8+.

Reference:
https://docs.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-queryservicedynamicinformation

Change-Id: I18e9a95b35f8c37d94c9900626c1785f425701dc
Reviewed-on: https://go-review.googlesource.com/c/sys/+/358394
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-29 16:52:21 +00:00
Takuto Ikuta
c1bf0bb051 windows: regen zsyscall_windows.go
It seems mksyscall sorts Windows APIs bit differently now.

Change-Id: I2703b12addefbbac00ab06f62500bc7db2b8cba6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/359657
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-10-29 16:29:42 +00:00
Tobias Klauser
69cdffdb93 unix: use default directories in TestGetwd on darwin/arm64
Go 1.16 renamed the iOS port from darwin/arm64 to ios/arm64 and
darwin/arm64 was repurposed for the macOS ARM64 port (see
https://golang.org/doc/go1.16#darwin).

Now that Go 1.16 is the oldest supported release, the ios tag can be
used exclusively to detect iOS and TestGetwd can use the same list of
directories as other systems.

For golang/go#45696

Change-Id: Ic334df5ea88ac034a9d9271f6cd570617f208f05
Reviewed-on: https://go-review.googlesource.com/c/sys/+/358254
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-10-25 20:12:05 +00:00
Lorenz Bauer
711f33c999 unix: add ParseOrigDstAddr
Add a function which turns a SocketControlMessage into a Sockaddr.
This can be used with IP(V6)_RECVORIGDSTADDR to retrieve the original
destination address of a packet.

Change-Id: Ib2d80cd01be6642e8b918cbc1584d4a49c3c6f1e
Reviewed-on: https://go-review.googlesource.com/c/sys/+/355609
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-25 11:29:17 +00:00
Hao Mou
d6a326fbbf windows: add NtSetInformationFile
Added NtSetInformationFile and some const values related to it.

The doc for the function and the values of the file information class
can be found here:
  https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-ntsetinformationfile
The values of the flags in the individual FILE_INFORMATION_CLASS can be
found here:
  FILE_RENAME_INFORMATION - https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_file_rename_information
  FILE_DISPOSITION_INFORMATION_EX - https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntddk/ns-ntddk-_file_disposition_information_ex
  FILE_CASE_SENSITIVE_INFORMATION - https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_file_case_sensitive_information
  FILE_LINK_INFORMATION - https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/ns-ntifs-_file_link_information
The other file information classes do not have flag values.

Fixes golang/go#48933

Change-Id: I917ff4c8df132f8584fd6d924cf5a9626a065092
Reviewed-on: https://go-review.googlesource.com/c/sys/+/355495
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-10-23 08:55:30 +00:00
Lorenz Bauer
8e5104632a unix: add functions to encode Inet4Pktinfo and Inet6Pktinfo
It's possible to control the source address of a UDP packet by
passing a socket control message of type IP_PKTINFO or IPV6_PKTINFO.
This is a somewhat esoteric feature of the network stack, but it's
extremely useful feature when you really need it.

Change-Id: I8300575f975679f6689d6f1282af253ba62e8f9d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/355610
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-10-22 21:59:31 +00:00
Jason A. Donenfeld
9d61738499 windows: add dynamic exception function table manipulators
These are useful for loading new code into the address space at runtime
and having exceptions be handled.

https://docs.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-rtladdfunctiontable
https://docs.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-rtldeletefunctiontable

Change-Id: I4fce4d7003d87cf48486d6e09d8543c2f1325554
Reviewed-on: https://go-review.googlesource.com/c/sys/+/357409
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-20 17:42:00 +00:00
Jason A. Donenfeld
153b154469 windows: add system info and version related functions
This adds various version and system info functions and adds a test that
prints the version of all installed drivers.

Change-Id: I73a2b0a35dcedf88206979ec6f1a56552dc80899
Reviewed-on: https://go-review.googlesource.com/c/sys/+/357149
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-20 17:18:05 +00:00
Brad Fitzpatrick
fcb26fe61c windows: gofmt to add go:build lines
Change-Id: I71b9023fcb6c9860ea35ba0d2cf77a6eed5176b9
Reviewed-on: https://go-review.googlesource.com/c/sys/+/357329
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-10-20 15:40:33 +00:00
Jason A. Donenfeld
25fac919d9 windows/svc: do not close service handle
The documentation [1] says "The service status handle does not have to
be closed." That makes it seem like it's optional. But actually, closing
it raises a user exception, because it's not a legitimate handle to
close.

This commit also adds the right go build comments with a `go fmt` pass.

[1] https://docs.microsoft.com/en-us/windows/win32/api/winsvc/nf-winsvc-registerservicectrlhandlerexa

Change-Id: Ibf67c0e8d94c87068720472009b24cecdfda6519
Reviewed-on: https://go-review.googlesource.com/c/sys/+/357250
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-20 15:30:01 +00:00
Jason A. Donenfeld
0ec99a608a windows/svc: rewrite in Go
The old service management code was written in assembly and communicated
over Windows events, which resulted in non-obvious control flow.
NewCallback makes it possible to rewrite all of this in vanilla Go. This
also enables the service test on the Go builders, as modifying system
services shouldn't be an issue there.

Change-Id: I8003b57d11d4469f762058c648a4b7733530eeb8
Reviewed-on: https://go-review.googlesource.com/c/sys/+/330010
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2021-10-20 06:40:51 +00:00