From c08bc6e187fc8d4d07c5eae96ac4a8ba6a326abb Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 4 Sep 2024 12:30:33 +0200 Subject: [PATCH 1/9] unix: update Go to 1.23.0 Change-Id: Ifd0f3aefd3699871fc875c8628aa4105b2c85f13 Reviewed-on: https://go-review.googlesource.com/c/sys/+/610016 LUCI-TryBot-Result: Go LUCI Reviewed-by: Ian Lance Taylor Auto-Submit: Tobias Klauser Reviewed-by: Dmitri Shuralyov --- unix/linux/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unix/linux/Dockerfile b/unix/linux/Dockerfile index 51b66ccba9..3f36a1be34 100644 --- a/unix/linux/Dockerfile +++ b/unix/linux/Dockerfile @@ -21,9 +21,9 @@ RUN git clone --branch v6.10 --depth 1 https://kernel.googlesource.com/pub/scm/l RUN git clone --branch release/2.40/master --depth 1 https://sourceware.org/git/glibc.git # Get Go -ENV GOLANG_VERSION 1.21.0 +ENV GOLANG_VERSION 1.23.0 ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz -ENV GOLANG_DOWNLOAD_SHA256 d0398903a16ba2232b389fb31032ddf57cac34efda306a0eebac34f0965a0742 +ENV GOLANG_DOWNLOAD_SHA256 905a297f19ead44780548933e0ff1a1b86e8327bb459e92f9c0012569f76f5e3 RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ From 68ed59b20bf0e0fefc232c3eb288c90c95732b3d Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Fri, 6 Sep 2024 06:22:10 -0400 Subject: [PATCH 2/9] windows/svc: fix printf(var) mistake detected by latest printf checker For golang/go#69267. Change-Id: Ie240b5c826bb96c0e2021a7e99a3c0f973f0a0e1 Reviewed-on: https://go-review.googlesource.com/c/sys/+/610940 Reviewed-by: Tim King Reviewed-by: Dmitri Shuralyov Auto-Submit: Dmitri Shuralyov LUCI-TryBot-Result: Go LUCI --- windows/svc/svc_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/svc/svc_test.go b/windows/svc/svc_test.go index be369ea211..cd2cd467c6 100644 --- a/windows/svc/svc_test.go +++ b/windows/svc/svc_test.go @@ -178,7 +178,7 @@ func TestIsWindowsServiceWhenParentExits(t *testing.T) { child.Env = append(os.Environ(), "GO_WANT_HELPER_PROCESS=child") err := child.Start() if err != nil { - fmt.Fprintf(os.Stderr, fmt.Sprintf("child start failed: %v", err)) + fmt.Fprintf(os.Stderr, "child start failed: %v", err) os.Exit(1) } os.Exit(0) From 30de3524c2229f51e499858e9201cbcd8b9c2b80 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 8 Sep 2024 18:48:53 +0200 Subject: [PATCH 3/9] unix: fix Test{Fd,}Xattr failure on NetBSD On NetBSD the namespace of an xattr is stored separately from the name and isn't returned by Listxattr and Flistxattr. Like on FreeBSD, strip the namespace before checking the returned xattrs. Fixes golang/go#69313 Fixes golang/go#69314 Change-Id: I7f2393cc63f9860332c0e07a51f3b9d32911e892 Cq-Include-Trybots: luci.golang.try:x_sys-gotip-netbsd-arm64 Reviewed-on: https://go-review.googlesource.com/c/sys/+/611695 Auto-Submit: Tobias Klauser LUCI-TryBot-Result: Go LUCI Reviewed-by: Benny Siegert Reviewed-by: Ian Lance Taylor Commit-Queue: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- unix/xattr_test.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/unix/xattr_test.go b/unix/xattr_test.go index a8e4fb86d1..a8be3ec5be 100644 --- a/unix/xattr_test.go +++ b/unix/xattr_test.go @@ -56,8 +56,9 @@ func TestXattr(t *testing.T) { xattrs := stringsFromByteSlice(buf[:read]) xattrWant := xattrName - if runtime.GOOS == "freebsd" { - // On FreeBSD, the namespace is stored separately from the xattr + switch runtime.GOOS { + case "freebsd", "netbsd": + // On FreeBSD and NetBSD, the namespace is stored separately from the xattr // name and Listxattr doesn't return the namespace prefix. xattrWant = strings.TrimPrefix(xattrWant, "user.") } @@ -65,11 +66,12 @@ func TestXattr(t *testing.T) { for _, name := range xattrs { if name == xattrWant { found = true + break } } if !found { - t.Errorf("Listxattr did not return previously set attribute '%s'", xattrName) + t.Errorf("Listxattr did not return previously set attribute %q in attributes %v", xattrName, xattrs) } // find size @@ -162,8 +164,9 @@ func TestFdXattr(t *testing.T) { xattrs := stringsFromByteSlice(buf[:read]) xattrWant := xattrName - if runtime.GOOS == "freebsd" { - // On FreeBSD, the namespace is stored separately from the xattr + switch runtime.GOOS { + case "freebsd", "netbsd": + // On FreeBSD and NetBSD, the namespace is stored separately from the xattr // name and Listxattr doesn't return the namespace prefix. xattrWant = strings.TrimPrefix(xattrWant, "user.") } @@ -171,11 +174,12 @@ func TestFdXattr(t *testing.T) { for _, name := range xattrs { if name == xattrWant { found = true + break } } if !found { - t.Errorf("Flistxattr did not return previously set attribute '%s'", xattrName) + t.Errorf("Flistxattr did not return previously set attribute %q in attributes %v", xattrName, xattrs) } // find size From d58f986c8984f0fb072181b6c10da9a2d4f9287f Mon Sep 17 00:00:00 2001 From: cuishuang Date: Mon, 9 Sep 2024 15:02:35 +0800 Subject: [PATCH 4/9] all: fix some typos in comment Change-Id: I40f9866661bad30ee2f4be2e9d0beee54db860b3 Reviewed-on: https://go-review.googlesource.com/c/sys/+/611775 Reviewed-by: Dmitri Shuralyov Commit-Queue: Ian Lance Taylor Auto-Submit: Dmitri Shuralyov Auto-Submit: Ian Lance Taylor Reviewed-by: Dmitri Shuralyov TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI --- unix/README.md | 2 +- unix/internal/mkmerge/mkmerge.go | 2 +- unix/mkpost.go | 2 +- unix/mksyscall_zos_s390x.go | 2 +- unix/syscall_aix.go | 2 +- unix/syscall_solaris_test.go | 2 +- unix/syscall_zos_test.go | 4 ++-- unix/sysvshm_unix_test.go | 2 +- unix/xattr_test.go | 2 +- windows/dll_windows.go | 2 +- windows/registry/registry_test.go | 2 +- windows/svc/mgr/config.go | 2 +- windows/svc/mgr/recovery.go | 4 ++-- windows/syscall_windows_test.go | 4 ++-- 14 files changed, 17 insertions(+), 17 deletions(-) diff --git a/unix/README.md b/unix/README.md index 7d3c060e12..6e08a76a71 100644 --- a/unix/README.md +++ b/unix/README.md @@ -156,7 +156,7 @@ from the generated architecture-specific files listed below, and merge these into a common file for each OS. The merge is performed in the following steps: -1. Construct the set of common code that is idential in all architecture-specific files. +1. Construct the set of common code that is identical in all architecture-specific files. 2. Write this common code to the merged file. 3. Remove the common code from all architecture-specific files. diff --git a/unix/internal/mkmerge/mkmerge.go b/unix/internal/mkmerge/mkmerge.go index db8098c7f0..52f1d12bb2 100644 --- a/unix/internal/mkmerge/mkmerge.go +++ b/unix/internal/mkmerge/mkmerge.go @@ -427,7 +427,7 @@ func filterImports(fileSrc []byte) ([]byte, error) { } // merge extracts duplicate code from archFiles and merges it to mergeFile. -// 1. Construct commonSet: the set of code that is idential in all archFiles. +// 1. Construct commonSet: the set of code that is identical in all archFiles. // 2. Write the code in commonSet to mergedFile. // 3. Remove the commonSet code from all archFiles. func merge(mergedFile string, archFiles ...string) error { diff --git a/unix/mkpost.go b/unix/mkpost.go index c98a77d7f6..ecacf010c9 100644 --- a/unix/mkpost.go +++ b/unix/mkpost.go @@ -153,7 +153,7 @@ func main() { b = controlRegsRegex.ReplaceAll(b, []byte("_ [0]uint64")) // Remove fields that are added by glibc - // Note that this is unstable as the identifers are private. + // Note that this is unstable as the identifiers are private. removeFieldsRegex := regexp.MustCompile(`X__glibc\S*`) b = removeFieldsRegex.ReplaceAll(b, []byte("_")) diff --git a/unix/mksyscall_zos_s390x.go b/unix/mksyscall_zos_s390x.go index f4fd945b39..12db6378af 100644 --- a/unix/mksyscall_zos_s390x.go +++ b/unix/mksyscall_zos_s390x.go @@ -374,7 +374,7 @@ func processStream(s *bufio.Scanner, asm, go1 *bufio.Writer, m *map[string]int64 } // Prepare arguments to Syscall. var args []string - var fargs []string // for call fowarding + var fargs []string // for call forwarding n := 0 for _, param := range in { p := parseParam(param) diff --git a/unix/syscall_aix.go b/unix/syscall_aix.go index 67ce6cef2d..6f15ba1eaf 100644 --- a/unix/syscall_aix.go +++ b/unix/syscall_aix.go @@ -360,7 +360,7 @@ func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, var status _C_int var r Pid_t err = ERESTART - // AIX wait4 may return with ERESTART errno, while the processus is still + // AIX wait4 may return with ERESTART errno, while the process is still // active. for err == ERESTART { r, err = wait4(Pid_t(pid), &status, options, rusage) diff --git a/unix/syscall_solaris_test.go b/unix/syscall_solaris_test.go index a9d486a10f..738733b21f 100644 --- a/unix/syscall_solaris_test.go +++ b/unix/syscall_solaris_test.go @@ -207,7 +207,7 @@ func TestEventPortErrors(t *testing.T) { defer port.Close() err = port.AssociatePath(path, stat, unix.FILE_MODIFIED, nil) if err == nil { - t.Errorf("unexpected success associating nonexistant file") + t.Errorf("unexpected success associating nonexistent file") } err = port.DissociatePath(path) if err == nil { diff --git a/unix/syscall_zos_test.go b/unix/syscall_zos_test.go index 2589e9ccd0..c04f5a00f7 100644 --- a/unix/syscall_zos_test.go +++ b/unix/syscall_zos_test.go @@ -3350,7 +3350,7 @@ func TestCreat(t *testing.T) { t.Fatal("Creat error: Cannot truncate file") } if string(b) != string(writeContent) { - t.Fatal("data missmatch: expect ", string(writeContent), " actual: ", string(b)) + t.Fatal("data mismatch: expect ", string(writeContent), " actual: ", string(b)) } // testing file create function @@ -3375,7 +3375,7 @@ func TestCreat(t *testing.T) { t.Fatal("Creat error: Cannot truncate file") } if string(b) != string(writeContent) { - t.Fatal("data missmatch: expect ", string(writeContent), " actual: ", string(b)) + t.Fatal("data mismatch: expect ", string(writeContent), " actual: ", string(b)) } } diff --git a/unix/sysvshm_unix_test.go b/unix/sysvshm_unix_test.go index cf234b83e3..af90637c2c 100644 --- a/unix/sysvshm_unix_test.go +++ b/unix/sysvshm_unix_test.go @@ -66,7 +66,7 @@ func TestSysvSharedMemory(t *testing.T) { } if runtime.GOOS == "zos" { - // The returned shared memory alligns with the pagesize. + // The returned shared memory aligns with the pagesize. // If pagesize is not 1024 bytes, the shared memory could be larger if len(b2) < 1024 { t.Fatalf("b1 len = %v, less than 1024", len(b2)) diff --git a/unix/xattr_test.go b/unix/xattr_test.go index a8be3ec5be..dfa208f160 100644 --- a/unix/xattr_test.go +++ b/unix/xattr_test.go @@ -119,7 +119,7 @@ func TestXattr(t *testing.T) { err = unix.Lsetxattr(s, xattrName, []byte(xattrDataSet), 0) if err != nil { - // Linux and Android doen't support xattrs on symlinks according + // Linux and Android doesn't support xattrs on symlinks according // to xattr(7), so just test that we get the proper error. if (runtime.GOOS != "linux" && runtime.GOOS != "android") || err != unix.EPERM { t.Fatalf("Lsetxattr: %v", err) diff --git a/windows/dll_windows.go b/windows/dll_windows.go index 115341fba6..4e613cf633 100644 --- a/windows/dll_windows.go +++ b/windows/dll_windows.go @@ -65,7 +65,7 @@ func LoadDLL(name string) (dll *DLL, err error) { return d, nil } -// MustLoadDLL is like LoadDLL but panics if load operation failes. +// MustLoadDLL is like LoadDLL but panics if load operation fails. func MustLoadDLL(name string) *DLL { d, e := LoadDLL(name) if e != nil { diff --git a/windows/registry/registry_test.go b/windows/registry/registry_test.go index c227a5db62..6e7bec505e 100644 --- a/windows/registry/registry_test.go +++ b/windows/registry/registry_test.go @@ -214,7 +214,7 @@ func enumerateValues(t *testing.T, k registry.Key) { } } for n, v := range haveNames { - t.Errorf("value %s (%v) is found while enumerating, but has not been cretaed", n, v) + t.Errorf("value %s (%v) is found while enumerating, but has not been created", n, v) } } diff --git a/windows/svc/mgr/config.go b/windows/svc/mgr/config.go index a6d3e8a88a..3c7ba08f58 100644 --- a/windows/svc/mgr/config.go +++ b/windows/svc/mgr/config.go @@ -63,7 +63,7 @@ func toStringSlice(ps *uint16) []string { return r } -// Config retrieves service s configuration paramteres. +// Config retrieves service s configuration parameters. func (s *Service) Config() (Config, error) { var p *windows.QUERY_SERVICE_CONFIG n := uint32(1024) diff --git a/windows/svc/mgr/recovery.go b/windows/svc/mgr/recovery.go index cdf880e13a..ef2a687840 100644 --- a/windows/svc/mgr/recovery.go +++ b/windows/svc/mgr/recovery.go @@ -137,7 +137,7 @@ func (s *Service) RecoveryCommand() (string, error) { // SetRecoveryActionsOnNonCrashFailures sets the failure actions flag. If the // flag is set to false, recovery actions will only be performed if the service // terminates without reporting a status of SERVICE_STOPPED. If the flag is set -// to true, recovery actions are also perfomed if the service stops with a +// to true, recovery actions are also performed if the service stops with a // nonzero exit code. func (s *Service) SetRecoveryActionsOnNonCrashFailures(flag bool) error { var setting windows.SERVICE_FAILURE_ACTIONS_FLAG @@ -151,7 +151,7 @@ func (s *Service) SetRecoveryActionsOnNonCrashFailures(flag bool) error { // actions flag. If the flag is set to false, recovery actions will only be // performed if the service terminates without reporting a status of // SERVICE_STOPPED. If the flag is set to true, recovery actions are also -// perfomed if the service stops with a nonzero exit code. +// performed if the service stops with a nonzero exit code. func (s *Service) RecoveryActionsOnNonCrashFailures() (bool, error) { b, err := s.queryServiceConfig2(windows.SERVICE_CONFIG_FAILURE_ACTIONS_FLAG) if err != nil { diff --git a/windows/syscall_windows_test.go b/windows/syscall_windows_test.go index b7703dfe15..1e686a4fd3 100644 --- a/windows/syscall_windows_test.go +++ b/windows/syscall_windows_test.go @@ -830,9 +830,9 @@ func FuzzComposeCommandLine(f *testing.F) { // If args[0] contains a space or control character, we must quote it // to avoid it being split into multiple arguments. // If args[0] already starts with a quote character, we have no way - // to indicate that that character is part of the literal argument. + // to indicate that character is part of the literal argument. // In either case, if the string already contains a quote character - // we must avoid misinterpriting that character as the end of the + // we must avoid misinterpreting that character as the end of the // quoted argument string. // // Unfortunately, ComposeCommandLine does not return an error, so we From 48aad76ed3ac439edae50adb78dbdbc46080878a Mon Sep 17 00:00:00 2001 From: Leo Antunes Date: Mon, 16 Sep 2024 08:39:39 +0000 Subject: [PATCH 5/9] linux: add tcp_cc_info and its related types Add the ability to retrieve congestion control information from a socket via TCP_CC_INFO. Fixes golang/go#68232 Change-Id: I2ea15928ec0e3192b670759bab4b659e62be553b GitHub-Last-Rev: b8b8c44f1f047fe6c60fae8adc695f2633dadd7c GitHub-Pull-Request: golang/sys#200 Reviewed-on: https://go-review.googlesource.com/c/sys/+/595676 LUCI-TryBot-Result: Go LUCI Reviewed-by: Carlos Amedee Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- unix/linux/types.go | 8 ++++++++ unix/syscall_linux.go | 42 ++++++++++++++++++++++++++++++++++++++++++ unix/ztypes_linux.go | 24 ++++++++++++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/unix/linux/types.go b/unix/linux/types.go index 75acaec896..0ba570fe16 100644 --- a/unix/linux/types.go +++ b/unix/linux/types.go @@ -112,6 +112,7 @@ struct termios2 { #include #include #include +#include #include #include #include @@ -757,6 +758,12 @@ type Ucred C.struct_ucred type TCPInfo C.struct_tcp_info +type TCPVegasInfo C.struct_tcpvegas_info + +type TCPDCTCPInfo C.struct_tcp_dctcp_info + +type TCPBBRInfo C.struct_tcp_bbr_info + type CanFilter C.struct_can_filter type ifreq C.struct_ifreq @@ -798,6 +805,7 @@ const ( SizeofICMPv6Filter = C.sizeof_struct_icmp6_filter SizeofUcred = C.sizeof_struct_ucred SizeofTCPInfo = C.sizeof_struct_tcp_info + SizeofTCPCCInfo = C.sizeof_union_tcp_cc_info SizeofCanFilter = C.sizeof_struct_can_filter SizeofTCPRepairOpt = C.sizeof_struct_tcp_repair_opt ) diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go index 3f1d3d4cb2..c5bb17ae5e 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -1295,6 +1295,48 @@ func GetsockoptTCPInfo(fd, level, opt int) (*TCPInfo, error) { return &value, err } +// GetsockoptTCPCCVegasInfo returns algorithm specific congestion control information for a socket using the "vegas" +// algorithm. +// +// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option: +// +// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION) +func GetsockoptTCPCCVegasInfo(fd, level, opt int) (*TCPVegasInfo, error) { + var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment + vallen := _Socklen(SizeofTCPCCInfo) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen) + out := (*TCPVegasInfo)(unsafe.Pointer(&value[0])) + return out, err +} + +// GetsockoptTCPCCDCTCPInfo returns algorithm specific congestion control information for a socket using the "dctp" +// algorithm. +// +// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option: +// +// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION) +func GetsockoptTCPCCDCTCPInfo(fd, level, opt int) (*TCPDCTCPInfo, error) { + var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment + vallen := _Socklen(SizeofTCPCCInfo) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen) + out := (*TCPDCTCPInfo)(unsafe.Pointer(&value[0])) + return out, err +} + +// GetsockoptTCPCCBBRInfo returns algorithm specific congestion control information for a socket using the "bbr" +// algorithm. +// +// The socket's congestion control algorighm can be retrieved via [GetsockoptString] with the [TCP_CONGESTION] option: +// +// algo, err := unix.GetsockoptString(fd, unix.IPPROTO_TCP, unix.TCP_CONGESTION) +func GetsockoptTCPCCBBRInfo(fd, level, opt int) (*TCPBBRInfo, error) { + var value [SizeofTCPCCInfo / 4]uint32 // ensure proper alignment + vallen := _Socklen(SizeofTCPCCInfo) + err := getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen) + out := (*TCPBBRInfo)(unsafe.Pointer(&value[0])) + return out, err +} + // GetsockoptString returns the string value of the socket option opt for the // socket associated with fd at the given socket level. func GetsockoptString(fd, level, opt int) (string, error) { diff --git a/unix/ztypes_linux.go b/unix/ztypes_linux.go index 9f2550dc31..cabdee2407 100644 --- a/unix/ztypes_linux.go +++ b/unix/ztypes_linux.go @@ -516,6 +516,29 @@ type TCPInfo struct { Total_rto_time uint32 } +type TCPVegasInfo struct { + Enabled uint32 + Rttcnt uint32 + Rtt uint32 + Minrtt uint32 +} + +type TCPDCTCPInfo struct { + Enabled uint16 + Ce_state uint16 + Alpha uint32 + Ab_ecn uint32 + Ab_tot uint32 +} + +type TCPBBRInfo struct { + Bw_lo uint32 + Bw_hi uint32 + Min_rtt uint32 + Pacing_gain uint32 + Cwnd_gain uint32 +} + type CanFilter struct { Id uint32 Mask uint32 @@ -557,6 +580,7 @@ const ( SizeofICMPv6Filter = 0x20 SizeofUcred = 0xc SizeofTCPInfo = 0xf8 + SizeofTCPCCInfo = 0x14 SizeofCanFilter = 0x8 SizeofTCPRepairOpt = 0x8 ) From 981de40f5c9d8dc49087c2d351624288ee17b34c Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 24 Sep 2024 03:29:28 +0200 Subject: [PATCH 6/9] unix: use vDSO for getrandom() on linux With CL 614835 adding support in the runtime for calling into the getrandom() vDSO function, wire up x/sys/unix's Getrandom() function to it, so that callers can benefit from the increased speed and shared vDSO state with the runtime. Updates golang/go#69577. Change-Id: I17734409982c51bb984a6337f4ffa8f60414ebee Reviewed-on: https://go-review.googlesource.com/c/sys/+/615335 Reviewed-by: Michael Pratt Reviewed-by: David Chase LUCI-TryBot-Result: Go LUCI --- unix/syscall_linux.go | 21 ++++++++++++++++++++- unix/vgetrandom_linux.go | 12 ++++++++++++ unix/vgetrandom_unsupported.go | 11 +++++++++++ unix/zsyscall_linux.go | 17 ----------------- 4 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 unix/vgetrandom_linux.go create mode 100644 unix/vgetrandom_unsupported.go diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go index c5bb17ae5e..f08abd434f 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -2001,7 +2001,26 @@ func Getpgrp() (pid int) { //sysnb Getpid() (pid int) //sysnb Getppid() (ppid int) //sys Getpriority(which int, who int) (prio int, err error) -//sys Getrandom(buf []byte, flags int) (n int, err error) + +func Getrandom(buf []byte, flags int) (n int, err error) { + vdsoRet, supported := vgetrandom(buf, uint32(flags)) + if supported { + if vdsoRet < 0 { + return 0, errnoErr(syscall.Errno(-vdsoRet)) + } + return vdsoRet, nil + } + var p *byte + if len(buf) > 0 { + p = &buf[0] + } + r, _, e := Syscall(SYS_GETRANDOM, uintptr(unsafe.Pointer(p)), uintptr(len(buf)), uintptr(flags)) + if e != 0 { + return 0, errnoErr(e) + } + return int(r), nil +} + //sysnb Getrusage(who int, rusage *Rusage) (err error) //sysnb Getsid(pid int) (sid int, err error) //sysnb Gettid() (tid int) diff --git a/unix/vgetrandom_linux.go b/unix/vgetrandom_linux.go new file mode 100644 index 0000000000..47cce9bbdc --- /dev/null +++ b/unix/vgetrandom_linux.go @@ -0,0 +1,12 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build linux && go1.24 + +package unix + +import _ "unsafe" + +//go:linkname vgetrandom runtime.vgetrandom +func vgetrandom(p []byte, flags uint32) (ret int, supported bool) diff --git a/unix/vgetrandom_unsupported.go b/unix/vgetrandom_unsupported.go new file mode 100644 index 0000000000..297e97bce9 --- /dev/null +++ b/unix/vgetrandom_unsupported.go @@ -0,0 +1,11 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +//go:build !linux || !go1.24 + +package unix + +func vgetrandom(p []byte, flags uint32) (ret int, supported bool) { + return -1, false +} diff --git a/unix/zsyscall_linux.go b/unix/zsyscall_linux.go index 1bc1a5adb2..af30da5578 100644 --- a/unix/zsyscall_linux.go +++ b/unix/zsyscall_linux.go @@ -971,23 +971,6 @@ func Getpriority(which int, who int) (prio int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Getrandom(buf []byte, flags int) (n int, err error) { - var _p0 unsafe.Pointer - if len(buf) > 0 { - _p0 = unsafe.Pointer(&buf[0]) - } else { - _p0 = unsafe.Pointer(&_zero) - } - r0, _, e1 := Syscall(SYS_GETRANDOM, uintptr(_p0), uintptr(len(buf)), uintptr(flags)) - n = int(r0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getrusage(who int, rusage *Rusage) (err error) { _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0) if e1 != 0 { From e7397b9a65e3b9b49ff8a63a5156bbfe90df8786 Mon Sep 17 00:00:00 2001 From: Mauri de Souza Meneguzzo Date: Fri, 27 Sep 2024 20:20:15 +0000 Subject: [PATCH 7/9] unix: update to Linux 6.11 Change-Id: I1cc777822da1b557e69634faade8e24d06c00ce8 GitHub-Last-Rev: d09238ecd0989901b5d92e7a0ae2556c6e441d27 GitHub-Pull-Request: golang/sys#218 Reviewed-on: https://go-review.googlesource.com/c/sys/+/613855 LUCI-TryBot-Result: Go LUCI Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor Reviewed-by: Tobias Klauser Reviewed-by: Michael Knyszek --- unix/linux/Dockerfile | 4 +-- unix/linux/mksysnum.go | 14 ++++++++ unix/syscall_linux_arm64.go | 2 ++ unix/syscall_linux_loong64.go | 2 ++ unix/syscall_linux_riscv64.go | 2 ++ unix/zerrors_linux.go | 13 +++++-- unix/zerrors_linux_386.go | 5 +++ unix/zerrors_linux_amd64.go | 5 +++ unix/zerrors_linux_arm.go | 5 +++ unix/zerrors_linux_arm64.go | 5 +++ unix/zerrors_linux_loong64.go | 5 +++ unix/zerrors_linux_mips.go | 5 +++ unix/zerrors_linux_mips64.go | 5 +++ unix/zerrors_linux_mips64le.go | 5 +++ unix/zerrors_linux_mipsle.go | 5 +++ unix/zerrors_linux_ppc.go | 5 +++ unix/zerrors_linux_ppc64.go | 5 +++ unix/zerrors_linux_ppc64le.go | 5 +++ unix/zerrors_linux_riscv64.go | 5 +++ unix/zerrors_linux_s390x.go | 5 +++ unix/zerrors_linux_sparc64.go | 5 +++ unix/zsysnum_linux_amd64.go | 1 + unix/zsysnum_linux_arm64.go | 2 +- unix/zsysnum_linux_loong64.go | 2 ++ unix/zsysnum_linux_riscv64.go | 2 +- unix/ztypes_linux.go | 64 ++++++++++++++++++---------------- 26 files changed, 147 insertions(+), 36 deletions(-) diff --git a/unix/linux/Dockerfile b/unix/linux/Dockerfile index 3f36a1be34..0e533d89a7 100644 --- a/unix/linux/Dockerfile +++ b/unix/linux/Dockerfile @@ -15,8 +15,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ # Get the git sources. If not cached, this takes O(5 minutes). WORKDIR /git RUN git config --global advice.detachedHead false -# Linux Kernel: Released 14 July 2024 -RUN git clone --branch v6.10 --depth 1 https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux +# Linux Kernel: Released 15 Sep 2024 +RUN git clone --branch v6.11 --depth 1 https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux # GNU C library: Released 21 July 2024 RUN git clone --branch release/2.40/master --depth 1 https://sourceware.org/git/glibc.git diff --git a/unix/linux/mksysnum.go b/unix/linux/mksysnum.go index be425325f9..612b60e9b5 100644 --- a/unix/linux/mksysnum.go +++ b/unix/linux/mksysnum.go @@ -8,6 +8,7 @@ package main import ( "bufio" + "bytes" "fmt" "os" "os/exec" @@ -125,6 +126,19 @@ func main() { fmt.Fprintf(os.Stderr, "can't run %s", cc) os.Exit(1) } + + switch goarch { + case "riscv64", "loong64", "arm64": + // Kernel linux v6.11 removed some __NR_* macros that only + // existed on some architectures as an implementation detail. In + // order to keep backwards compatibility we add them back. + // + // See https://lkml.org/lkml/2024/8/5/1283. + if !bytes.Contains(cmd, []byte("#define __NR_arch_specific_syscall")) { + cmd = append(cmd, []byte("#define __NR_arch_specific_syscall 244\n")...) + } + } + s := bufio.NewScanner(strings.NewReader(string(cmd))) var offset, prev, asOffset int var nums syscallNums diff --git a/unix/syscall_linux_arm64.go b/unix/syscall_linux_arm64.go index cf2ee6c75e..745e5c7e6c 100644 --- a/unix/syscall_linux_arm64.go +++ b/unix/syscall_linux_arm64.go @@ -182,3 +182,5 @@ func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error } return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) } + +const SYS_FSTATAT = SYS_NEWFSTATAT diff --git a/unix/syscall_linux_loong64.go b/unix/syscall_linux_loong64.go index 3d0e98451f..dd2262a407 100644 --- a/unix/syscall_linux_loong64.go +++ b/unix/syscall_linux_loong64.go @@ -214,3 +214,5 @@ func KexecFileLoad(kernelFd int, initrdFd int, cmdline string, flags int) error } return kexecFileLoad(kernelFd, initrdFd, cmdlineLen, cmdline, flags) } + +const SYS_FSTATAT = SYS_NEWFSTATAT diff --git a/unix/syscall_linux_riscv64.go b/unix/syscall_linux_riscv64.go index 6f5a288944..8cf3670bda 100644 --- a/unix/syscall_linux_riscv64.go +++ b/unix/syscall_linux_riscv64.go @@ -187,3 +187,5 @@ func RISCVHWProbe(pairs []RISCVHWProbePairs, set *CPUSet, flags uint) (err error } return riscvHWProbe(pairs, setSize, set, flags) } + +const SYS_FSTATAT = SYS_NEWFSTATAT diff --git a/unix/zerrors_linux.go b/unix/zerrors_linux.go index 01a70b2463..de3b462489 100644 --- a/unix/zerrors_linux.go +++ b/unix/zerrors_linux.go @@ -495,6 +495,7 @@ const ( BPF_F_TEST_REG_INVARIANTS = 0x80 BPF_F_TEST_RND_HI32 = 0x4 BPF_F_TEST_RUN_ON_CPU = 0x1 + BPF_F_TEST_SKB_CHECKSUM_COMPLETE = 0x4 BPF_F_TEST_STATE_FREQ = 0x8 BPF_F_TEST_XDP_LIVE_FRAMES = 0x2 BPF_F_XDP_DEV_BOUND_ONLY = 0x40 @@ -1922,6 +1923,7 @@ const ( MNT_EXPIRE = 0x4 MNT_FORCE = 0x1 MNT_ID_REQ_SIZE_VER0 = 0x18 + MNT_ID_REQ_SIZE_VER1 = 0x20 MODULE_INIT_COMPRESSED_FILE = 0x4 MODULE_INIT_IGNORE_MODVERSIONS = 0x1 MODULE_INIT_IGNORE_VERMAGIC = 0x2 @@ -2187,7 +2189,7 @@ const ( NFT_REG_SIZE = 0x10 NFT_REJECT_ICMPX_MAX = 0x3 NFT_RT_MAX = 0x4 - NFT_SECMARK_CTX_MAXLEN = 0x100 + NFT_SECMARK_CTX_MAXLEN = 0x1000 NFT_SET_MAXNAMELEN = 0x100 NFT_SOCKET_MAX = 0x3 NFT_TABLE_F_MASK = 0x7 @@ -2356,9 +2358,11 @@ const ( PERF_MEM_LVLNUM_IO = 0xa PERF_MEM_LVLNUM_L1 = 0x1 PERF_MEM_LVLNUM_L2 = 0x2 + PERF_MEM_LVLNUM_L2_MHB = 0x5 PERF_MEM_LVLNUM_L3 = 0x3 PERF_MEM_LVLNUM_L4 = 0x4 PERF_MEM_LVLNUM_LFB = 0xc + PERF_MEM_LVLNUM_MSC = 0x6 PERF_MEM_LVLNUM_NA = 0xf PERF_MEM_LVLNUM_PMEM = 0xe PERF_MEM_LVLNUM_RAM = 0xd @@ -2431,6 +2435,7 @@ const ( PRIO_PGRP = 0x1 PRIO_PROCESS = 0x0 PRIO_USER = 0x2 + PROCFS_IOCTL_MAGIC = 'f' PROC_SUPER_MAGIC = 0x9fa0 PROT_EXEC = 0x4 PROT_GROWSDOWN = 0x1000000 @@ -2933,11 +2938,12 @@ const ( RUSAGE_SELF = 0x0 RUSAGE_THREAD = 0x1 RWF_APPEND = 0x10 + RWF_ATOMIC = 0x40 RWF_DSYNC = 0x2 RWF_HIPRI = 0x1 RWF_NOAPPEND = 0x20 RWF_NOWAIT = 0x8 - RWF_SUPPORTED = 0x3f + RWF_SUPPORTED = 0x7f RWF_SYNC = 0x4 RWF_WRITE_LIFE_NOT_SET = 0x0 SCHED_BATCH = 0x3 @@ -3210,6 +3216,7 @@ const ( STATX_ATTR_MOUNT_ROOT = 0x2000 STATX_ATTR_NODUMP = 0x40 STATX_ATTR_VERITY = 0x100000 + STATX_ATTR_WRITE_ATOMIC = 0x400000 STATX_BASIC_STATS = 0x7ff STATX_BLOCKS = 0x400 STATX_BTIME = 0x800 @@ -3226,6 +3233,7 @@ const ( STATX_SUBVOL = 0x8000 STATX_TYPE = 0x1 STATX_UID = 0x8 + STATX_WRITE_ATOMIC = 0x10000 STATX__RESERVED = 0x80000000 SYNC_FILE_RANGE_WAIT_AFTER = 0x4 SYNC_FILE_RANGE_WAIT_BEFORE = 0x1 @@ -3624,6 +3632,7 @@ const ( XDP_UMEM_PGOFF_COMPLETION_RING = 0x180000000 XDP_UMEM_PGOFF_FILL_RING = 0x100000000 XDP_UMEM_REG = 0x4 + XDP_UMEM_TX_METADATA_LEN = 0x4 XDP_UMEM_TX_SW_CSUM = 0x2 XDP_UMEM_UNALIGNED_CHUNK_FLAG = 0x1 XDP_USE_NEED_WAKEUP = 0x8 diff --git a/unix/zerrors_linux_386.go b/unix/zerrors_linux_386.go index 684a5168da..8aa6d77c01 100644 --- a/unix/zerrors_linux_386.go +++ b/unix/zerrors_linux_386.go @@ -153,9 +153,14 @@ const ( NFDBITS = 0x20 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x8008b705 NS_GET_NSTYPE = 0xb703 NS_GET_OWNER_UID = 0xb704 NS_GET_PARENT = 0xb702 + NS_GET_PID_FROM_PIDNS = 0x8004b706 + NS_GET_PID_IN_PIDNS = 0x8004b708 + NS_GET_TGID_FROM_PIDNS = 0x8004b707 + NS_GET_TGID_IN_PIDNS = 0x8004b709 NS_GET_USERNS = 0xb701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/unix/zerrors_linux_amd64.go b/unix/zerrors_linux_amd64.go index 61d74b592d..da428f4253 100644 --- a/unix/zerrors_linux_amd64.go +++ b/unix/zerrors_linux_amd64.go @@ -153,9 +153,14 @@ const ( NFDBITS = 0x40 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x8008b705 NS_GET_NSTYPE = 0xb703 NS_GET_OWNER_UID = 0xb704 NS_GET_PARENT = 0xb702 + NS_GET_PID_FROM_PIDNS = 0x8004b706 + NS_GET_PID_IN_PIDNS = 0x8004b708 + NS_GET_TGID_FROM_PIDNS = 0x8004b707 + NS_GET_TGID_IN_PIDNS = 0x8004b709 NS_GET_USERNS = 0xb701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/unix/zerrors_linux_arm.go b/unix/zerrors_linux_arm.go index a28c9e3e89..bf45bfec78 100644 --- a/unix/zerrors_linux_arm.go +++ b/unix/zerrors_linux_arm.go @@ -150,9 +150,14 @@ const ( NFDBITS = 0x20 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x8008b705 NS_GET_NSTYPE = 0xb703 NS_GET_OWNER_UID = 0xb704 NS_GET_PARENT = 0xb702 + NS_GET_PID_FROM_PIDNS = 0x8004b706 + NS_GET_PID_IN_PIDNS = 0x8004b708 + NS_GET_TGID_FROM_PIDNS = 0x8004b707 + NS_GET_TGID_IN_PIDNS = 0x8004b709 NS_GET_USERNS = 0xb701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/unix/zerrors_linux_arm64.go b/unix/zerrors_linux_arm64.go index ab5d1fe8ea..71c67162b7 100644 --- a/unix/zerrors_linux_arm64.go +++ b/unix/zerrors_linux_arm64.go @@ -154,9 +154,14 @@ const ( NFDBITS = 0x40 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x8008b705 NS_GET_NSTYPE = 0xb703 NS_GET_OWNER_UID = 0xb704 NS_GET_PARENT = 0xb702 + NS_GET_PID_FROM_PIDNS = 0x8004b706 + NS_GET_PID_IN_PIDNS = 0x8004b708 + NS_GET_TGID_FROM_PIDNS = 0x8004b707 + NS_GET_TGID_IN_PIDNS = 0x8004b709 NS_GET_USERNS = 0xb701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/unix/zerrors_linux_loong64.go b/unix/zerrors_linux_loong64.go index c523090e7c..9476628fa0 100644 --- a/unix/zerrors_linux_loong64.go +++ b/unix/zerrors_linux_loong64.go @@ -154,9 +154,14 @@ const ( NFDBITS = 0x40 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x8008b705 NS_GET_NSTYPE = 0xb703 NS_GET_OWNER_UID = 0xb704 NS_GET_PARENT = 0xb702 + NS_GET_PID_FROM_PIDNS = 0x8004b706 + NS_GET_PID_IN_PIDNS = 0x8004b708 + NS_GET_TGID_FROM_PIDNS = 0x8004b707 + NS_GET_TGID_IN_PIDNS = 0x8004b709 NS_GET_USERNS = 0xb701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/unix/zerrors_linux_mips.go b/unix/zerrors_linux_mips.go index 01e6ea7804..b9e85f3cf0 100644 --- a/unix/zerrors_linux_mips.go +++ b/unix/zerrors_linux_mips.go @@ -150,9 +150,14 @@ const ( NFDBITS = 0x20 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x4008b705 NS_GET_NSTYPE = 0x2000b703 NS_GET_OWNER_UID = 0x2000b704 NS_GET_PARENT = 0x2000b702 + NS_GET_PID_FROM_PIDNS = 0x4004b706 + NS_GET_PID_IN_PIDNS = 0x4004b708 + NS_GET_TGID_FROM_PIDNS = 0x4004b707 + NS_GET_TGID_IN_PIDNS = 0x4004b709 NS_GET_USERNS = 0x2000b701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/unix/zerrors_linux_mips64.go b/unix/zerrors_linux_mips64.go index 7aa610b1e7..a48b68a764 100644 --- a/unix/zerrors_linux_mips64.go +++ b/unix/zerrors_linux_mips64.go @@ -150,9 +150,14 @@ const ( NFDBITS = 0x40 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x4008b705 NS_GET_NSTYPE = 0x2000b703 NS_GET_OWNER_UID = 0x2000b704 NS_GET_PARENT = 0x2000b702 + NS_GET_PID_FROM_PIDNS = 0x4004b706 + NS_GET_PID_IN_PIDNS = 0x4004b708 + NS_GET_TGID_FROM_PIDNS = 0x4004b707 + NS_GET_TGID_IN_PIDNS = 0x4004b709 NS_GET_USERNS = 0x2000b701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/unix/zerrors_linux_mips64le.go b/unix/zerrors_linux_mips64le.go index 92af771b44..ea00e8522a 100644 --- a/unix/zerrors_linux_mips64le.go +++ b/unix/zerrors_linux_mips64le.go @@ -150,9 +150,14 @@ const ( NFDBITS = 0x40 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x4008b705 NS_GET_NSTYPE = 0x2000b703 NS_GET_OWNER_UID = 0x2000b704 NS_GET_PARENT = 0x2000b702 + NS_GET_PID_FROM_PIDNS = 0x4004b706 + NS_GET_PID_IN_PIDNS = 0x4004b708 + NS_GET_TGID_FROM_PIDNS = 0x4004b707 + NS_GET_TGID_IN_PIDNS = 0x4004b709 NS_GET_USERNS = 0x2000b701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/unix/zerrors_linux_mipsle.go b/unix/zerrors_linux_mipsle.go index b27ef5e6f1..91c6468717 100644 --- a/unix/zerrors_linux_mipsle.go +++ b/unix/zerrors_linux_mipsle.go @@ -150,9 +150,14 @@ const ( NFDBITS = 0x20 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x4008b705 NS_GET_NSTYPE = 0x2000b703 NS_GET_OWNER_UID = 0x2000b704 NS_GET_PARENT = 0x2000b702 + NS_GET_PID_FROM_PIDNS = 0x4004b706 + NS_GET_PID_IN_PIDNS = 0x4004b708 + NS_GET_TGID_FROM_PIDNS = 0x4004b707 + NS_GET_TGID_IN_PIDNS = 0x4004b709 NS_GET_USERNS = 0x2000b701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/unix/zerrors_linux_ppc.go b/unix/zerrors_linux_ppc.go index 237a2cefb3..8cbf38d639 100644 --- a/unix/zerrors_linux_ppc.go +++ b/unix/zerrors_linux_ppc.go @@ -152,9 +152,14 @@ const ( NL3 = 0x300 NLDLY = 0x300 NOFLSH = 0x80000000 + NS_GET_MNTNS_ID = 0x4008b705 NS_GET_NSTYPE = 0x2000b703 NS_GET_OWNER_UID = 0x2000b704 NS_GET_PARENT = 0x2000b702 + NS_GET_PID_FROM_PIDNS = 0x4004b706 + NS_GET_PID_IN_PIDNS = 0x4004b708 + NS_GET_TGID_FROM_PIDNS = 0x4004b707 + NS_GET_TGID_IN_PIDNS = 0x4004b709 NS_GET_USERNS = 0x2000b701 OLCUC = 0x4 ONLCR = 0x2 diff --git a/unix/zerrors_linux_ppc64.go b/unix/zerrors_linux_ppc64.go index 4a5c555a36..a2df734191 100644 --- a/unix/zerrors_linux_ppc64.go +++ b/unix/zerrors_linux_ppc64.go @@ -152,9 +152,14 @@ const ( NL3 = 0x300 NLDLY = 0x300 NOFLSH = 0x80000000 + NS_GET_MNTNS_ID = 0x4008b705 NS_GET_NSTYPE = 0x2000b703 NS_GET_OWNER_UID = 0x2000b704 NS_GET_PARENT = 0x2000b702 + NS_GET_PID_FROM_PIDNS = 0x4004b706 + NS_GET_PID_IN_PIDNS = 0x4004b708 + NS_GET_TGID_FROM_PIDNS = 0x4004b707 + NS_GET_TGID_IN_PIDNS = 0x4004b709 NS_GET_USERNS = 0x2000b701 OLCUC = 0x4 ONLCR = 0x2 diff --git a/unix/zerrors_linux_ppc64le.go b/unix/zerrors_linux_ppc64le.go index a02fb49a5f..2479137923 100644 --- a/unix/zerrors_linux_ppc64le.go +++ b/unix/zerrors_linux_ppc64le.go @@ -152,9 +152,14 @@ const ( NL3 = 0x300 NLDLY = 0x300 NOFLSH = 0x80000000 + NS_GET_MNTNS_ID = 0x4008b705 NS_GET_NSTYPE = 0x2000b703 NS_GET_OWNER_UID = 0x2000b704 NS_GET_PARENT = 0x2000b702 + NS_GET_PID_FROM_PIDNS = 0x4004b706 + NS_GET_PID_IN_PIDNS = 0x4004b708 + NS_GET_TGID_FROM_PIDNS = 0x4004b707 + NS_GET_TGID_IN_PIDNS = 0x4004b709 NS_GET_USERNS = 0x2000b701 OLCUC = 0x4 ONLCR = 0x2 diff --git a/unix/zerrors_linux_riscv64.go b/unix/zerrors_linux_riscv64.go index e26a7c61b2..d265f146ee 100644 --- a/unix/zerrors_linux_riscv64.go +++ b/unix/zerrors_linux_riscv64.go @@ -150,9 +150,14 @@ const ( NFDBITS = 0x40 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x8008b705 NS_GET_NSTYPE = 0xb703 NS_GET_OWNER_UID = 0xb704 NS_GET_PARENT = 0xb702 + NS_GET_PID_FROM_PIDNS = 0x8004b706 + NS_GET_PID_IN_PIDNS = 0x8004b708 + NS_GET_TGID_FROM_PIDNS = 0x8004b707 + NS_GET_TGID_IN_PIDNS = 0x8004b709 NS_GET_USERNS = 0xb701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/unix/zerrors_linux_s390x.go b/unix/zerrors_linux_s390x.go index c48f7c2103..3f2d644396 100644 --- a/unix/zerrors_linux_s390x.go +++ b/unix/zerrors_linux_s390x.go @@ -150,9 +150,14 @@ const ( NFDBITS = 0x40 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x8008b705 NS_GET_NSTYPE = 0xb703 NS_GET_OWNER_UID = 0xb704 NS_GET_PARENT = 0xb702 + NS_GET_PID_FROM_PIDNS = 0x8004b706 + NS_GET_PID_IN_PIDNS = 0x8004b708 + NS_GET_TGID_FROM_PIDNS = 0x8004b707 + NS_GET_TGID_IN_PIDNS = 0x8004b709 NS_GET_USERNS = 0xb701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/unix/zerrors_linux_sparc64.go b/unix/zerrors_linux_sparc64.go index ad4b9aace7..5d8b727a1c 100644 --- a/unix/zerrors_linux_sparc64.go +++ b/unix/zerrors_linux_sparc64.go @@ -155,9 +155,14 @@ const ( NFDBITS = 0x40 NLDLY = 0x100 NOFLSH = 0x80 + NS_GET_MNTNS_ID = 0x4008b705 NS_GET_NSTYPE = 0x2000b703 NS_GET_OWNER_UID = 0x2000b704 NS_GET_PARENT = 0x2000b702 + NS_GET_PID_FROM_PIDNS = 0x4004b706 + NS_GET_PID_IN_PIDNS = 0x4004b708 + NS_GET_TGID_FROM_PIDNS = 0x4004b707 + NS_GET_TGID_IN_PIDNS = 0x4004b709 NS_GET_USERNS = 0x2000b701 OLCUC = 0x2 ONLCR = 0x4 diff --git a/unix/zsysnum_linux_amd64.go b/unix/zsysnum_linux_amd64.go index d3e38f681a..f485dbf456 100644 --- a/unix/zsysnum_linux_amd64.go +++ b/unix/zsysnum_linux_amd64.go @@ -341,6 +341,7 @@ const ( SYS_STATX = 332 SYS_IO_PGETEVENTS = 333 SYS_RSEQ = 334 + SYS_URETPROBE = 335 SYS_PIDFD_SEND_SIGNAL = 424 SYS_IO_URING_SETUP = 425 SYS_IO_URING_ENTER = 426 diff --git a/unix/zsysnum_linux_arm64.go b/unix/zsysnum_linux_arm64.go index 6c778c2327..1893e2fe88 100644 --- a/unix/zsysnum_linux_arm64.go +++ b/unix/zsysnum_linux_arm64.go @@ -85,7 +85,7 @@ const ( SYS_SPLICE = 76 SYS_TEE = 77 SYS_READLINKAT = 78 - SYS_FSTATAT = 79 + SYS_NEWFSTATAT = 79 SYS_FSTAT = 80 SYS_SYNC = 81 SYS_FSYNC = 82 diff --git a/unix/zsysnum_linux_loong64.go b/unix/zsysnum_linux_loong64.go index 37281cf51a..16a4017da0 100644 --- a/unix/zsysnum_linux_loong64.go +++ b/unix/zsysnum_linux_loong64.go @@ -84,6 +84,8 @@ const ( SYS_SPLICE = 76 SYS_TEE = 77 SYS_READLINKAT = 78 + SYS_NEWFSTATAT = 79 + SYS_FSTAT = 80 SYS_SYNC = 81 SYS_FSYNC = 82 SYS_FDATASYNC = 83 diff --git a/unix/zsysnum_linux_riscv64.go b/unix/zsysnum_linux_riscv64.go index 9889f6a559..a5459e766f 100644 --- a/unix/zsysnum_linux_riscv64.go +++ b/unix/zsysnum_linux_riscv64.go @@ -84,7 +84,7 @@ const ( SYS_SPLICE = 76 SYS_TEE = 77 SYS_READLINKAT = 78 - SYS_FSTATAT = 79 + SYS_NEWFSTATAT = 79 SYS_FSTAT = 80 SYS_SYNC = 81 SYS_FSYNC = 82 diff --git a/unix/ztypes_linux.go b/unix/ztypes_linux.go index cabdee2407..3a69e45496 100644 --- a/unix/ztypes_linux.go +++ b/unix/ztypes_linux.go @@ -87,31 +87,35 @@ type StatxTimestamp struct { } type Statx_t struct { - Mask uint32 - Blksize uint32 - Attributes uint64 - Nlink uint32 - Uid uint32 - Gid uint32 - Mode uint16 - _ [1]uint16 - Ino uint64 - Size uint64 - Blocks uint64 - Attributes_mask uint64 - Atime StatxTimestamp - Btime StatxTimestamp - Ctime StatxTimestamp - Mtime StatxTimestamp - Rdev_major uint32 - Rdev_minor uint32 - Dev_major uint32 - Dev_minor uint32 - Mnt_id uint64 - Dio_mem_align uint32 - Dio_offset_align uint32 - Subvol uint64 - _ [11]uint64 + Mask uint32 + Blksize uint32 + Attributes uint64 + Nlink uint32 + Uid uint32 + Gid uint32 + Mode uint16 + _ [1]uint16 + Ino uint64 + Size uint64 + Blocks uint64 + Attributes_mask uint64 + Atime StatxTimestamp + Btime StatxTimestamp + Ctime StatxTimestamp + Mtime StatxTimestamp + Rdev_major uint32 + Rdev_minor uint32 + Dev_major uint32 + Dev_minor uint32 + Mnt_id uint64 + Dio_mem_align uint32 + Dio_offset_align uint32 + Subvol uint64 + Atomic_write_unit_min uint32 + Atomic_write_unit_max uint32 + Atomic_write_segments_max uint32 + _ [1]uint32 + _ [9]uint64 } type Fsid struct { @@ -3790,7 +3794,7 @@ const ( ETHTOOL_MSG_PSE_GET = 0x24 ETHTOOL_MSG_PSE_SET = 0x25 ETHTOOL_MSG_RSS_GET = 0x26 - ETHTOOL_MSG_USER_MAX = 0x2b + ETHTOOL_MSG_USER_MAX = 0x2c ETHTOOL_MSG_KERNEL_NONE = 0x0 ETHTOOL_MSG_STRSET_GET_REPLY = 0x1 ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2 @@ -3830,7 +3834,7 @@ const ( ETHTOOL_MSG_MODULE_NTF = 0x24 ETHTOOL_MSG_PSE_GET_REPLY = 0x25 ETHTOOL_MSG_RSS_GET_REPLY = 0x26 - ETHTOOL_MSG_KERNEL_MAX = 0x2b + ETHTOOL_MSG_KERNEL_MAX = 0x2c ETHTOOL_FLAG_COMPACT_BITSETS = 0x1 ETHTOOL_FLAG_OMIT_REPLY = 0x2 ETHTOOL_FLAG_STATS = 0x4 @@ -3975,7 +3979,7 @@ const ( ETHTOOL_A_COALESCE_RATE_SAMPLE_INTERVAL = 0x17 ETHTOOL_A_COALESCE_USE_CQE_MODE_TX = 0x18 ETHTOOL_A_COALESCE_USE_CQE_MODE_RX = 0x19 - ETHTOOL_A_COALESCE_MAX = 0x1c + ETHTOOL_A_COALESCE_MAX = 0x1e ETHTOOL_A_PAUSE_UNSPEC = 0x0 ETHTOOL_A_PAUSE_HEADER = 0x1 ETHTOOL_A_PAUSE_AUTONEG = 0x2 @@ -4633,7 +4637,7 @@ const ( NL80211_ATTR_MAC_HINT = 0xc8 NL80211_ATTR_MAC_MASK = 0xd7 NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca - NL80211_ATTR_MAX = 0x14a + NL80211_ATTR_MAX = 0x14c NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4 NL80211_ATTR_MAX_CSA_COUNTERS = 0xce NL80211_ATTR_MAX_MATCH_SETS = 0x85 @@ -5237,7 +5241,7 @@ const ( NL80211_FREQUENCY_ATTR_GO_CONCURRENT = 0xf NL80211_FREQUENCY_ATTR_INDOOR_ONLY = 0xe NL80211_FREQUENCY_ATTR_IR_CONCURRENT = 0xf - NL80211_FREQUENCY_ATTR_MAX = 0x20 + NL80211_FREQUENCY_ATTR_MAX = 0x21 NL80211_FREQUENCY_ATTR_MAX_TX_POWER = 0x6 NL80211_FREQUENCY_ATTR_NO_10MHZ = 0x11 NL80211_FREQUENCY_ATTR_NO_160MHZ = 0xc From cbf0eb65e7bacca61a408b25429879f49c878a0b Mon Sep 17 00:00:00 2001 From: John Troy Date: Fri, 27 Sep 2024 19:29:44 +0000 Subject: [PATCH 8/9] unix: fix grep syntax to work on non-GNU greps CL 432835 changed two grep commands in unix/mkerrors.sh in such a way that is incompatible with AIX's grep, which, unlike GNU grep, does not support extended regular expressions without the -E flag. The intent of this PR is to restore the egrep behavior by invoking grep as grep -E. My assumption is that GNU grep is not meant to be a requirement to run mkerrors.sh, and given that, grep -E looks like the most cross-platform approach. Example of current (incorrect) behavior on AIX: bash-5.2$ printf 'SIGHUP\nSIGMAX64\nSIGTERM' | grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' SIGHUP SIGMAX64 SIGTERM Behavior before CL 432835: bash-5.2$ printf 'SIGHUP\nSIGMAX64\nSIGTERM' | egrep -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' SIGHUP SIGTERM Behavior of proposed change: bash-5.2$ printf 'SIGHUP\nSIGMAX64\nSIGTERM' | grep -E -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' SIGHUP SIGTERM OpenBSD's grep behaves the same as AIX for the above commands, which is why I cast this as GNU vs. non-GNU. I haven't tested any other implementations. Fixes golang/go#69365 Change-Id: I009353ee630463475a5c131d019f59c5e69efd34 GitHub-Last-Rev: e1166046e1f6d97d0efe28f96e692f2df790be6f GitHub-Pull-Request: golang/sys#217 Reviewed-on: https://go-review.googlesource.com/c/sys/+/615755 Reviewed-by: Michael Knyszek Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Reviewed-by: Ian Lance Taylor --- unix/mkerrors.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unix/mkerrors.sh b/unix/mkerrors.sh index e14b766a32..ac54ecaba0 100755 --- a/unix/mkerrors.sh +++ b/unix/mkerrors.sh @@ -656,7 +656,7 @@ errors=$( signals=$( echo '#include ' | $CC -x c - -E -dM $ccflags | awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print $2 }' | - grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' | + grep -E -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' | sort ) @@ -666,7 +666,7 @@ echo '#include ' | $CC -x c - -E -dM $ccflags | sort >_error.grep echo '#include ' | $CC -x c - -E -dM $ccflags | awk '$1=="#define" && $2 ~ /^SIG[A-Z0-9]+$/ { print "^\t" $2 "[ \t]*=" }' | - grep -v 'SIGSTKSIZE\|SIGSTKSZ\|SIGRT\|SIGMAX64' | + grep -E -v '(SIGSTKSIZE|SIGSTKSZ|SIGRT|SIGMAX64)' | sort >_signal.grep echo '// mkerrors.sh' "$@" From 23b0dabe630b463b28ffc2871505befb3c5d3b4b Mon Sep 17 00:00:00 2001 From: Mateusz Poliwczak Date: Mon, 30 Sep 2024 17:01:15 +0000 Subject: [PATCH 9/9] unix: mark vgetrandom as non-escaping For golang/go#69577 Change-Id: Id1942d252c813126aa2f110e3f426714db73b9c7 GitHub-Last-Rev: 10e6a30b78d5945a8a0bdb2aa732d653eb08c1ee GitHub-Pull-Request: golang/sys#220 Reviewed-on: https://go-review.googlesource.com/c/sys/+/616795 Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Reviewed-by: Michael Knyszek Reviewed-by: Jason Donenfeld --- unix/vgetrandom_linux.go | 1 + 1 file changed, 1 insertion(+) diff --git a/unix/vgetrandom_linux.go b/unix/vgetrandom_linux.go index 47cce9bbdc..07ac8e09d1 100644 --- a/unix/vgetrandom_linux.go +++ b/unix/vgetrandom_linux.go @@ -9,4 +9,5 @@ package unix import _ "unsafe" //go:linkname vgetrandom runtime.vgetrandom +//go:noescape func vgetrandom(p []byte, flags uint32) (ret int, supported bool)