Commit Graph

1699 Commits

Author SHA1 Message Date
database64128
ea436ef09d windows: add iphlpapi routing functions
NotifyRouteChange2 registers to be notified for changes to IP route
entries. Call GetIpForwardEntry2 on received row to retrieve complete
information.

GetIpForwardTable2 retrieves the full routing table.
FreeMibTable frees the buffer allocated by the functions that return
tables of network interfaces, addresses, and routes.

Change-Id: I9fba75f1f728661e45dc3092e35eb9099b0570dd
Reviewed-on: https://go-review.googlesource.com/c/sys/+/695195
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-10-21 11:10:28 -07:00
Kir Kolyshkin
28c5bda5d4 unix: add SetMemPolicy and its mode/flag values
This reuses CPUSet type as it fits perfectly.

No GetMemPolicy support yet.

Change-Id: I549361bc1ed95ee73fd38d00277ec0f9f348a9ba
Reviewed-on: https://go-review.googlesource.com/c/sys/+/706917
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Antti Kervinen <antti.kervinen@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-10-08 14:29:03 -07:00
Kir Kolyshkin
b731f782ac unix/linux: switch to ubuntu 25.04, Go 1.25.1
Ubuntu 24.10 is not supported since July 2025 (and some of its apt repos
are apparently removed), and so mkall.sh no longer works (as of today).

Fix this by switching to (currently supported) Ubuntu 25.04.

NOTE that we can't switch to
 - Ubuntu 24.04 LTS release (see CL 618075);
 - Ubuntu 25.10 as it lacks mips support;
 - Debian Stable (13) as it also lacks mips support.

Also, bump Go to 1.25.1.

No changes in generated content after running

	GOOS=linux GOARCH=amd64 ./mkall.sh

Change-Id: I58a4856cda93a85af51f4a519c6e4e25f31a39b4
Reviewed-on: https://go-review.googlesource.com/c/sys/+/706915
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2025-10-08 14:29:00 -07:00
Kir Kolyshkin
1edeebeea0 unix: mkall.sh: fail if docker build failed
When docker build fails, docker run (in my case podman) tries to find
the generate:linux image from various mirrors, which is very confusing.
We should error out if docker build fails.

Change-Id: I4fd78e9fa339e03029b1bf003b3239ca23a7ed1b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/706916
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Kirill Kolyshkin <kolyshkin@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Carlos Amedee <carlos@golang.org>
v0.37.0
2025-10-02 13:28:30 -07:00
Tobias Klauser
ecada54126 unix: use slices.{Equal,Sort} in tests
Same as CL 587655 and CL 690475 did for package syscall tests.

Change-Id: Ie3c8726a4e2c859b5d7992ea1baec14083b9fdba
Reviewed-on: https://go-review.googlesource.com/c/sys/+/708558
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Florian Lehner <lehner.florian86@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
2025-10-02 11:15:31 -07:00
qmuntal
5e63aa5e0f windows: export O_FILE_FLAG_* to be used in os.OpenFile on windows
These file flags are supported by os.OpenFile since CL 699415.

Closes golang/go#73676

Change-Id: Iaf846c9cb98c1458bbc30d05ad8a331ef1f332df
Reviewed-on: https://go-review.googlesource.com/c/sys/+/700975
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-09-26 11:36:48 -07:00
Aleksa Sarai
033906b9f0 unix: add (*CPUSet).Fill helper to enable all CPUs
Some programs (such as container runtimes) want to reset their CPU
affinity if they are spawned by processes with a particular CPU
affinity. Container runtimes didn't really have to deal with this issue
until Linux 6.2 when the cpuset cgroup was changed to no longer
auto-reset CPU affinity in this case.

A naive approach to resetting your CPU affinity would be to get the
number of CPUs by looking at "/proc/stat" or "/sys/devices/system/cpu"
(note that runtime.NumCPU() actually returns the CPU affinity of the
process at startup time, which isn't useful for this purpose) and then
asking for all of those CPUs.

However, sched_setaffinity(2) will silently ignore any CPU bits set in
the provided CPUSet if they do not exist or are not enabled in the
cpuset cgroup of the process. This means that you can reset your CPU
affinity by just setting every CPU bit in CPUSet and passing it to
sched_setaffinity(2).

Unfortunately, setting every CPU bit in CPUSet with (*CPUSet).Set() is
very inefficient. If it were possible to just memset(0xFF) the CPUSet
array, users would be able to reset their CPU affinity even more
cheaply. However, Go doesn't have a memset primitive that can be used in
that way.

Obvious solutions like setting the array elements of CPUSet to (^0) do
not work because CPUSet is an array of a private newtype and so the
compiler complains if you try to use a constant like (^0) without a
cast (and we cannot use a cast because the type is private):

    cannot use ^0 (untyped int constant -1) as
    "golang.org/x/sys/unix".cpuMask value in assignment (overflows)

The only real alternative is to do something quite hacky like:

    cpuset := unix.CPUSet{}
    for i := range cpuset {
        cpuset[i]-- // underflow to 0xFF..FF
    }

... which is the solution we use in runc.

It would be much nicer to have a helper that does this memset for us in
a less hacky way, since resetting CPU affinity seems like a fairly
common operation.

Ref: Linux kernel commit da019032819a ("sched: Enforce user requested affinity")
Fixes golang/go#75186

Change-Id: I211ddeafd54ce35079a67493123d28e1bb76966a
GitHub-Last-Rev: 71871db0f3
GitHub-Pull-Request: golang/sys#259
Reviewed-on: https://go-review.googlesource.com/c/sys/+/698015
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-09-26 10:17:15 -07:00
Ayman Bagabas
6be6c584a2 windows: add FlushConsoleInputBuffer and GetNumberOfConsoleInputEvents
This adds syscall wrappers for FlushConsoleInputBuffer and GetNumberOfConsoleInputEvents on Windows.

Change-Id: I2365aebc42a57f83cfc951e10520270e1f3e0606
GitHub-Last-Rev: 1f711a5f3c
GitHub-Pull-Request: golang/sys#264
Reviewed-on: https://go-review.googlesource.com/c/sys/+/704715
Reviewed-by: Mark Freeman <markfreeman@google.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-09-18 15:33:41 -07:00
Kir Kolyshkin
32e203842b unix: use Go 1.21+ clear built-in
Inspired by CL 698495.

Change-Id: Ic6ff68a60d41b6ffb6a28f523597c5d36c1e4d2f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/704915
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Mark Freeman <markfreeman@google.com>
2025-09-18 13:57:09 -07:00
Thomas Klausner
137f2eda35 sys: add support for NetBSD getvfsstat
NetBSD replaced the getfsstat interface with getvfsstat in NetBSD 3.0.

Add a test for it.

With help from Benny Siegert and Ian Lance Taylor.

Change-Id: I115ae48c287cc32181006e9e8f7c15851e7e36c0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/550476
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Benny Siegert <bsiegert@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2025-09-17 07:50:20 -07:00
Thomas Gibson-Robinson
b06ce0514e windows: add FILE_ZERO_DATA_INFORMATION
This is needed for invoking windows.DeviceIoControl with
windows.FSCTL_SET_ZERO_DATA.

Change-Id: I20f93a40a86b92e6bdeeec096ffc0245e8184672
GitHub-Last-Rev: 01d299ab84
GitHub-Pull-Request: golang/sys#261
Reviewed-on: https://go-review.googlesource.com/c/sys/+/698436
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
v0.36.0
2025-09-05 08:44:06 -07:00
Jiwon Na
689cc11b26 unix: fix Listen on solaris
libsocket has __xnet_listen, not __xnet_llisten
which prevents listen from working.

Change-Id: Ia06dc569fcb9950893d91fc1b86257c7742e9e3d
GitHub-Last-Rev: 6f37c4b814
GitHub-Pull-Request: golang/sys#258
Reviewed-on: https://go-review.googlesource.com/c/sys/+/691735
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Jes Cok <xigua67damn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2025-09-05 08:17:06 -07:00
Tobias Klauser
a4712b9054 plan9: drop go version tags for unsupported versions
go.mod specifies go 1.24. Drop code for older, unsupported versions.

Change-Id: I8a1ecd9e5634c1cf9619fbb89b2ecd0bda7eaf21
Reviewed-on: https://go-review.googlesource.com/c/sys/+/579515
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-09-04 07:42:06 -07:00
Juan-Luis de Sousa-Valadas Castaño
0293703b0a unix: add IFAL_* consts and ifaddrlblmsg on linux
Implments consts and structs related to ifaddrlabel

Change-Id: I6dd78e74a8e32a26286b95b0a7a20343cb16a446
GitHub-Last-Rev: 11be45c36d
GitHub-Pull-Request: golang/sys#252
Reviewed-on: https://go-review.googlesource.com/c/sys/+/683775
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Florian Lehner <lehner.florian86@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2025-09-03 08:33:29 -07:00
Florian Lehner
ab85cbbe91 unix/linux: extend rtnetlink constants
Change-Id: Icc356897519c0aa229a948918a253b9e4b367aff
Reviewed-on: https://go-review.googlesource.com/c/sys/+/697795
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2025-08-25 12:31:12 -07:00
Aleksa Sarai
9bd37534d8 unix: switch (*CPUSet).Zero to clear builtin
clear was added to Go 1.21 and is better than the manual loop approach.

Change-Id: I851203714446e21b6329e2bcf308f2571d339e36
GitHub-Last-Rev: 71dc7f073e
GitHub-Pull-Request: golang/sys#262
Reviewed-on: https://go-review.googlesource.com/c/sys/+/698495
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@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: Keith Randall <khr@golang.org>
2025-08-25 10:48:03 -07:00
mertakman
899c23279d windows/mkwinsyscall: use syscall.SyscallN instead of syscall.Syscall{6,9,12,15}
Replace syscall.Syscall6, Syscall9, Syscall12, and Syscall15 with
syscall.SyscallN for Go 1.18+. This simplifies system calls by allowing
the exact number of arguments needed, eliminating zero padding and
reducing potential errors.

Updated TestSyscallXGeneration to TestSyscallNGeneration to verify
correct SyscallN generation for different argument counts.

Change-Id: Iaf01c7bddd7ad6a80ee462879e382b0066f35b4d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/691715
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sean Liao <sean@liao.dev>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2025-08-22 12:22:44 -07:00
Gopher Robot
543f21a056 all: upgrade go directive to at least 1.24.0 [generated]
By now Go 1.25.0 has been released, and Go 1.23 is no longer supported
per the Go Release Policy (see https://go.dev/doc/devel/release#policy).

For golang/go#69095.

[git-generate]
(cd . && go get go@1.24.0 && go mod tidy && go fix ./... && go mod edit -toolchain=none)

Change-Id: I0a3cdf3452806d955a3c293c9bdd59e4c1f56f8a
Reviewed-on: https://go-review.googlesource.com/c/sys/+/695616
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
2025-08-13 07:47:20 -07:00
Tobias Klauser
5b936e1f12 unix/linux: update to Linux kernel 6.16, Go to 1.24.5
Change-Id: Id0b60b5bbc33c48e49ba655babf0856878960e29
Reviewed-on: https://go-review.googlesource.com/c/sys/+/693215
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
v0.35.0
2025-08-06 14:03:43 -07:00
database64128
3a827038f2 unix: remove redundant xnu version check for {p}readv/{p}writev
As discussed later in golang/go#64710, these checks are unnecessary.

For golang/go#64710

Change-Id: I8693af81cc543b886732922eb5cd64e07ed4b7a8
Reviewed-on: https://go-review.googlesource.com/c/sys/+/688858
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2025-07-30 07:39:06 -07:00
nickgarlis
9920300fc8 unix: add missing nft conntrack constants
The following constants were missing for nft conntrack:

- NFT_CT_SRC_IP
- NFT_CT_DST_IP
- NFT_CT_SRC_IP6
- NFT_CT_DST_IP6
- NFT_CT_ID

https://git.netfilter.org/libnftnl/tree/include/linux/netfilter/nf_tables.h?id=7a7722ee336fac14690851f6c84965582a741601#n1173

Change-Id: I2f9bd12c1ab8569ee019310c040b46b214f65b76
GitHub-Last-Rev: 8fac63b187
GitHub-Pull-Request: golang/sys#257
Reviewed-on: https://go-review.googlesource.com/c/sys/+/689922
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <mark@golang.org>
2025-07-28 12:41:30 -07:00
cuishuang
ad4e0fcb71 unix: remove redundant word in comment
Change-Id: I8b05b5cea86d41423dac9fd96a5000a6daa1e8c3
Reviewed-on: https://go-review.googlesource.com/c/sys/+/690816
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Mark Freeman <mark@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-07-28 11:24:37 -07:00
database64128
084ad875b3 unix: fix //sys decl after CL 548795
CL 548795 mistakenly changed one of the //sys declaration to "// sys"
while resolving a merge conflict.

For golang/go#64710

Change-Id: I029b461fd3ca7b76f3bd23b3343f7e63c4bb09f3
Reviewed-on: https://go-review.googlesource.com/c/sys/+/688857
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-07-25 11:55:20 -07:00
Que Zhiyong
751c3c6ac2 unix: add missing NFT_PAYLOAD_* consts on linux
Change-Id: Id222e11029596d2ea2679e065780171ed3c7708a
GitHub-Last-Rev: 649d64b1c3
GitHub-Pull-Request: golang/sys#250
Reviewed-on: https://go-review.googlesource.com/c/sys/+/681435
Reviewed-by: Cherry Mui <cherryyz@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: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
v0.34.0
2025-06-17 10:35:38 -07:00
Tobias Klauser
0c740cc0f8 unix: update Go to 1.24.3
Change-Id: I526bfbde6e57b8e7aea6cd31e3cff46608755aa0
Reviewed-on: https://go-review.googlesource.com/c/sys/+/673055
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-06-13 07:34:22 -07:00
Tobias Klauser
d62d31c616 unix: update Linux constants and types to v6.14
CL 660375 updated the kernel version in the Dockerfile but for some
reason no constant or types were updated. Refresh them now and also add
new ETHTOOL_* and NL80211_* enum types while at it.

Change-Id: I73bc509963f0b89f6d461eeca4b210626ab44975
Reviewed-on: https://go-review.googlesource.com/c/sys/+/673076
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
2025-06-13 07:33:12 -07:00
qmuntal
3d9a6b8079 windows: add WSADuplicateSocket
WSADuplicateSocket is useful to pass sockets between processes on
Windows.

For golang/go#10350.

Change-Id: I6563184fe4d4477d402a6af81b254bd8aa992d2e
Reviewed-on: https://go-review.googlesource.com/c/sys/+/668215
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>
Auto-Submit: Carlos Amedee <carlos@golang.org>
v0.33.0
2025-05-02 09:05:10 -07:00
Meng Zhuo
c0a9559877 cpu: add crypto extensions detection for riscv64
This CL adds RISC-V cryptography extensions detection.
Direct detection of the extensions zvkned, zvknhb, zvksed and
zvksh is not supported, since the crypto spec requires these
extensions implemented with data independent timing (zkt).

However, their presence may be inferred by checking for
the shorthand extensions: zvkn, zvknc, zvkng, zvks, zvksc, zvksg.

Change-Id: Ic00038cebf1b9f77426876b06b08f206473ad6fb
Reviewed-on: https://go-review.googlesource.com/c/sys/+/664375
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Pengcheng Wang <wangpengcheng.pp@bytedance.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-05-01 02:30:04 -07:00
Ayman Bagabas
8e9e04625d windows: add virtual key codes and console input consts
This adds console input related key codes and consts

Change-Id: I8ebd76995a2c9ddd150cf04890a9e5053841fcab
GitHub-Last-Rev: 8e534f4589
GitHub-Pull-Request: golang/sys#226
Reviewed-on: https://go-review.googlesource.com/c/sys/+/621495
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-22 10:17:31 -07:00
Keith Randall
7138967c19 windows: fix slicing of NTUnicodeString values
We were slicing using a count of bytes, not a count of uint16s.

Fixes golang/go#73460

Change-Id: If0fd19e795078c01fda5b976e3c34af115b25dcc
Reviewed-on: https://go-review.googlesource.com/c/sys/+/667235
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2025-04-22 08:26:09 -07:00
thepudds
6a85559a3f windows: fix dangling pointers in (*SECURITY_DESCRIPTOR).ToAbsolute
Prior to this CL, a byte slice was allocated via make to use as the
absoluteSD argument passed to the Windows API MakeAbsoluteSD.

MakeAbsoluteSD then sets pointers outside the view of the GC, including
pointers within absoluteSD that point to other chunks of memory
we pass into MakeAbsoluteSD.

CL 653856 recently allowed more make results to be stack allocated,
which worsened the problems here and made it easier for those
pointers in absoluteSD to become dangling pointers, though the
core problems here existed before.

This CL instead allocates absoluteSD as a proper SECURITY_DESCRIPTOR
struct so that the GC can be aware of its pointers. We also verify the
pointers are as we expect, and then set them explicitly
in view of the GC.

Updates golang/go#73199

Change-Id: Id8038d38a887bb8ff3ffc6eae603589b97e92cdc
Reviewed-on: https://go-review.googlesource.com/c/sys/+/663355
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2025-04-09 11:19:55 -07:00
Tobias Klauser
01aaa8342f all: simplify code by using modern Go constructs
Generated using modernize by running:

    go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./...

Change-Id: Ifc7d61cf6735cc53f2bdf890a338961f55075af5
Reviewed-on: https://go-review.googlesource.com/c/sys/+/661975
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
v0.32.0
2025-04-03 13:04:48 -07:00
Douglas Danger Manley
1b2bd6bb49 windows: replace all StringToUTF16 calls with UTF16FromString
`StringToUTF16` is deprecated and will panic if given an "invalid"
string (in particular, one that has a null byte in it).  The replacement
function is `UTF16FromString`, and it returns an error if there was
a problem.

This change replaces all uses of `StringToUTF16` with `UTF16FromString`.
The `service` struct now no longer stores a `string` name but rather
a `*uint16` pointer to the name.

It should not be possible to panic due to UTF16 string conversion
at this point.

Fixes golang/go#73006

Change-Id: Idce9cdbb4651fef8481f0cad19b5df0314fd4277
Reviewed-on: https://go-review.googlesource.com/c/sys/+/659936
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-02 11:32:38 -07:00
Mauri de Souza Meneguzzo
1c3b72f1c1 unix: update Linux kernel to 6.14
No new syscalls or constants in this release, just bumping the version number.

Change-Id: I97f7e1092bb78d99342552ba18e1ea3cd40681f4
GitHub-Last-Rev: df5cca1a90
GitHub-Pull-Request: golang/sys#247
Reviewed-on: https://go-review.googlesource.com/c/sys/+/660375
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-03-26 05:30:21 -07:00
database64128
c175b6ba67 windows: add cmsghdr and pktinfo structures
- CMSGHDR from ws2def.h, corresponds to Cmsghdr in unix
- IN_PKTINFO from ws2ipdef.h, corresponds to InetPktinfo in unix
- IN6_PKTINFO from ws2ipdef.h, corresponds to Inet6Pktinfo in unix

Change-Id: I74f6812588859c3a6080e6675df28998fc435965
GitHub-Last-Rev: 7377c793c6
GitHub-Pull-Request: golang/sys#246
Reviewed-on: https://go-review.googlesource.com/c/sys/+/658175
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2025-03-26 01:10:13 -07:00
Manuel Schönlaub
3330b5e756 unix: support Readv, Preadv, Writev and Pwritev for darwin
Darwin, starting with Big Sur, supports vectorized IO.

Fixes golang/go#64710

Change-Id: Ic3a3c51009eab24f70665d8d3a145b328a7713c6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/548795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-03-20 08:06:05 -07:00
Guoqi Chen
7401cce313 cpu: replace specific instructions with WORD in the function get_cpucfg on loong64
The CPUCFG instruction on loong64 was introduced in Go1.24, which caused
compilation errors when using this feature in Go1.23 and earlier versions.

Change-Id: I68891bbfc527194ecdafebac3398e700bfb53c2f
Reviewed-on: https://go-review.googlesource.com/c/sys/+/656915
Reviewed-by: Meidan Li <limeidan@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-03-12 17:52:00 -07:00
Guoqi Chen
b8f7da6c5a cpu: add support for detecting cpu features on loong64
Except for lasx, all other features have been implemented
in the Go mainline.

Change-Id: I61a09396ed23d17991b641a1265e952585cb5636
Reviewed-on: https://go-review.googlesource.com/c/sys/+/655355
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
2025-03-11 18:36:47 -07:00
database64128
f2ce62c21a windows: add constants for PMTUD socket options
Related documentation:

- https://learn.microsoft.com/en-us/windows/win32/winsock/ipproto-ip-socket-options
- https://learn.microsoft.com/en-us/windows/win32/winsock/ipproto-ipv6-socket-options

Change-Id: I21b23ca815d1d8135ce5724115b9ca23819ea10a
GitHub-Last-Rev: 9054c5c790
GitHub-Pull-Request: golang/sys#245
Reviewed-on: https://go-review.googlesource.com/c/sys/+/654495
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>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-03-05 07:56:48 -08:00
Gopher Robot
74cfc93a99 all: upgrade go directive to at least 1.23.0 [generated]
By now Go 1.24.0 has been released, and Go 1.22 is no longer supported
per the Go Release Policy (https://go.dev/doc/devel/release#policy).

For golang/go#69095.

[git-generate]
(cd . && go get go@1.23.0 && go mod tidy && go fix ./... && go mod edit -toolchain=none)

Change-Id: Ibb66e9edd9b097ab8ff838138f8116664bb50158
Reviewed-on: https://go-review.googlesource.com/c/sys/+/649697
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
v0.31.0
2025-02-14 13:48:03 -08:00
Mauri de Souza Meneguzzo
863b3c4ac4 unix: update glibc to 2.41
Change-Id: I1796b552f854a15e8ef5e019e247c4d7e0644086
GitHub-Last-Rev: 3518c62005
GitHub-Pull-Request: golang/sys#244
Reviewed-on: https://go-review.googlesource.com/c/sys/+/645436
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
v0.30.0
2025-01-31 07:57:49 -08:00
Florian Lehner
4d4692e1b0 unix: add Auxv
Fixes golang/go#67839

Change-Id: I3af38d21159f7cac3786b49ac17657d314fbc178
Reviewed-on: https://go-review.googlesource.com/c/sys/+/644295
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
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>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2025-01-31 07:53:42 -08:00
Mauri de Souza Meneguzzo
b215a1c6fc unix: update to Linux kernel 6.13
Change-Id: I4c49a78bd2abf2ac9e4d461680c92ae65be14544
GitHub-Last-Rev: 888e68d533
GitHub-Pull-Request: golang/sys#243
Reviewed-on: https://go-review.googlesource.com/c/sys/+/642199
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-01-21 14:32:54 -08:00
Grigorii Khvatskii
c75621413d cpu: add support for AVX-VNNI and IFMA detection
Added detection for x86 AVX-VNNI (VEX-coded Vector Neural Network
Instructions) and AVX-IFMA (VEX-coded Integer Fused Multiply Add),
including both the base VNNI set and the Int8 extention.

Fixes golang/go#71142

Change-Id: I9e8d18b2e8bf81d5d4313a4a47fdf731fb3d44dd
GitHub-Last-Rev: 32ea443fc2
GitHub-Pull-Request: golang/sys#242
Reviewed-on: https://go-review.googlesource.com/c/sys/+/641155
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-01-10 12:06:19 -08:00
Nahum Shalman
1c14dcadc3 unix: add GetPeerUcred and UcredGet for solaris
Change-Id: I74ba119fb729ef46899de04c686115f960975bb3
Reviewed-on: https://go-review.googlesource.com/c/sys/+/639755
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: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2025-01-07 00:03:00 -08:00
Sebastiaan van Stijn
d4ac05dc8c windows: update NewLazyDLL, LoadDLL docs to point to NewLazySystemDLL
Point users to the NewLazySystemDLL utility that was added in CL 21592.

Change-Id: I5fddd927fe6628f06a6266b225949c4227fb79f1
GitHub-Last-Rev: 1fe36ed335
GitHub-Pull-Request: golang/sys#240
Reviewed-on: https://go-review.googlesource.com/c/sys/+/638715
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.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>
v0.29.0
2024-12-26 08:00:01 -08:00
Sebastiaan van Stijn
680bd24a5f windows: remove unused errString type
It's no longer used since CL 165759.

Change-Id: Ie8c834a6dd1147889ec47bf92a5d4cce08bbf4fd
GitHub-Last-Rev: 3f0c460db1
GitHub-Pull-Request: golang/sys#241
Reviewed-on: https://go-review.googlesource.com/c/sys/+/638716
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-12-26 07:58:30 -08:00
Tobias Klauser
a7f19e9c20 unix: add Dup3 on dragonfly
Use the same implementation as on freebsd which is also what the
dragonfly libc uses.

Change-Id: I0ed513ae15fcb6dac77b2fc76f662723d66b75c6
Reviewed-on: https://go-review.googlesource.com/c/sys/+/636435
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-12-17 08:13:49 -08:00
Ian Lance Taylor
fe16172d11 unix: define IfMsghdr2, IfData64, and RtMsghdr2 on darwin
Change-Id: I6943f6b5bd9f7d0ef5bad24ed638b8cf5dd0353d
Reviewed-on: https://go-review.googlesource.com/c/sys/+/633077
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
v0.28.0
2024-12-03 18:44:20 +00:00
Mauri de Souza Meneguzzo
0a57dbcf35 unix: update to kernel Linux 6.12
Change-Id: I7c8157d5f1b597b6ae249b20866bbad918b46fa4
GitHub-Last-Rev: 0bbc2efbab
GitHub-Pull-Request: golang/sys#238
Reviewed-on: https://go-review.googlesource.com/c/sys/+/629075
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-11-18 19:38:36 +00:00