From 1911637744c199cdad74ee1ee74d19ce61e3d9fa Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Fri, 31 Mar 2023 12:54:09 -0400 Subject: [PATCH 01/18] windows/svc: use separate (and more descriptive) service names in tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Notably, the DisplayName field was set to the same thing in both sys.TestExample and mrg.TestMyService, which may explain the collision reported in golang/go#59298. Moreover, the adjective ”my” conveys no information whatsoever — we shouldn't use it in tests or examples. Also skip the tests that install services if GO_BUILDER_NAME is not set, to reduce the likelihood of 'go test all' in a user's working directory being mistaken for a malicious or compromised program. Fixes golang/go#59298. Change-Id: Ib00bf7400bfaa34e1a1d49125c43b97019b53c82 Reviewed-on: https://go-review.googlesource.com/c/sys/+/481015 Reviewed-by: Carlos Amedee Run-TryBot: Bryan Mills Reviewed-by: Alex Brainman TryBot-Result: Gopher Robot Auto-Submit: Bryan Mills --- windows/svc/example/main.go | 8 ++++++-- windows/svc/example/service.go | 6 +++--- windows/svc/mgr/mgr_test.go | 21 +++++++++++---------- windows/svc/svc_test.go | 16 ++++++++++------ 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/windows/svc/example/main.go b/windows/svc/example/main.go index 2ea733010f..62f947027f 100644 --- a/windows/svc/example/main.go +++ b/windows/svc/example/main.go @@ -15,6 +15,7 @@ package main import ( + "flag" "fmt" "log" "os" @@ -33,8 +34,11 @@ func usage(errmsg string) { os.Exit(2) } +var svcName = "exampleservice" + func main() { - const svcName = "myservice" + flag.StringVar(&svcName, "name", svcName, "name of the service") + flag.Parse() inService, err := svc.IsWindowsService() if err != nil { @@ -55,7 +59,7 @@ func main() { runService(svcName, true) return case "install": - err = installService(svcName, "my service") + err = installService(svcName, "example service") case "remove": err = removeService(svcName) case "start": diff --git a/windows/svc/example/service.go b/windows/svc/example/service.go index c989abff7a..08d54b51a3 100644 --- a/windows/svc/example/service.go +++ b/windows/svc/example/service.go @@ -19,9 +19,9 @@ import ( var elog debug.Log -type myservice struct{} +type exampleService struct{} -func (m *myservice) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (ssec bool, errno uint32) { +func (m *exampleService) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (ssec bool, errno uint32) { const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown | svc.AcceptPauseAndContinue changes <- svc.Status{State: svc.StartPending} fasttick := time.Tick(500 * time.Millisecond) @@ -79,7 +79,7 @@ func runService(name string, isDebug bool) { if isDebug { run = debug.Run } - err = run(name, &myservice{}) + err = run(name, &exampleService{}) if err != nil { elog.Error(1, fmt.Sprintf("%s service failed: %v", name, err)) return diff --git a/windows/svc/mgr/mgr_test.go b/windows/svc/mgr/mgr_test.go index 6f849f3e30..10d2310790 100644 --- a/windows/svc/mgr/mgr_test.go +++ b/windows/svc/mgr/mgr_test.go @@ -227,25 +227,26 @@ func remove(t *testing.T, s *mgr.Service) { } func TestMyService(t *testing.T) { + if os.Getenv("GO_BUILDER_NAME") == "" { + // Don't install services on arbitrary users' machines. + t.Skip("skipping test that modifies system services: GO_BUILDER_NAME not set") + } if testing.Short() { - t.Skip("skipping test in short mode - it modifies system services") + t.Skip("skipping test in short mode that modifies system services") } - const name = "mymgrservice" + const name = "mgrtestservice" m, err := mgr.Connect() if err != nil { - if errno, ok := err.(syscall.Errno); ok && errno == syscall.ERROR_ACCESS_DENIED { - t.Skip("Skipping test: we don't have rights to manage services.") - } t.Fatalf("SCM connection failed: %s", err) } defer m.Disconnect() c := mgr.Config{ StartType: mgr.StartDisabled, - DisplayName: "my service", - Description: "my service is just a test", + DisplayName: "x-sys mgr test service", + Description: "x-sys mgr test service is just a test", Dependencies: []string{"LanmanServer", "W32Time"}, } @@ -288,14 +289,14 @@ func TestMyService(t *testing.T) { if err != nil { t.Fatalf("ListServices failed: %v", err) } - var myserviceIsInstalled bool + var serviceIsInstalled bool for _, sn := range svcnames { if sn == name { - myserviceIsInstalled = true + serviceIsInstalled = true break } } - if !myserviceIsInstalled { + if !serviceIsInstalled { t.Errorf("ListServices failed to find %q service", name) } diff --git a/windows/svc/svc_test.go b/windows/svc/svc_test.go index f7833adb14..5d794e1966 100644 --- a/windows/svc/svc_test.go +++ b/windows/svc/svc_test.go @@ -77,11 +77,15 @@ func stopAndDeleteIfInstalled(t *testing.T, m *mgr.Mgr, name string) { } func TestExample(t *testing.T) { - if testing.Short() && os.Getenv("GO_BUILDER_NAME") != "" { - t.Skip("skipping test in short mode - it modifies system services") + if os.Getenv("GO_BUILDER_NAME") == "" { + // Don't install services on arbitrary users' machines. + t.Skip("skipping test that modifies system services: GO_BUILDER_NAME not set") + } + if testing.Short() { + t.Skip("skipping test in short mode that modifies system services") } - const name = "myservice" + const name = "svctestservice" m, err := mgr.Connect() if err != nil { @@ -103,7 +107,7 @@ func TestExample(t *testing.T) { stopAndDeleteIfInstalled(t, m, name) - s, err := m.CreateService(name, exepath, mgr.Config{DisplayName: "my service"}, "is", "auto-started") + s, err := m.CreateService(name, exepath, mgr.Config{DisplayName: "x-sys svc test service"}, "-name", name) if err != nil { t.Fatalf("CreateService(%s) failed: %v", name, err) } @@ -141,7 +145,7 @@ func TestExample(t *testing.T) { t.Fatalf("Delete failed: %s", err) } - out, err := exec.Command("wevtutil.exe", "qe", "Application", "/q:*[System[Provider[@Name='myservice']]]", "/rd:true", "/c:10").CombinedOutput() + out, err := exec.Command("wevtutil.exe", "qe", "Application", "/q:*[System[Provider[@Name='"+name+"']]]", "/rd:true", "/c:10").CombinedOutput() if err != nil { t.Fatalf("wevtutil failed: %v\n%v", err, string(out)) } @@ -149,7 +153,7 @@ func TestExample(t *testing.T) { // Test context passing (see servicemain in sys_386.s and sys_amd64.s). want += "-123456" if !strings.Contains(string(out), want) { - t.Errorf("%q string does not contain %q", string(out), want) + t.Errorf("%q string does not contain %q", out, want) } } From c43fe1e1f5e94f8140de42e780509f73c20f34b2 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 15 May 2023 10:38:34 +0200 Subject: [PATCH 02/18] cpu: define IsBigEndian on wasm For golang/go#57237 Change-Id: Ia2aa943e93c8df51cd08003535fa026d2bb8003e Reviewed-on: https://go-review.googlesource.com/c/sys/+/494856 TryBot-Result: Gopher Robot Auto-Submit: Tobias Klauser Reviewed-by: Ian Lance Taylor Run-TryBot: Tobias Klauser Reviewed-by: Heschi Kreinick --- cpu/endian_little.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpu/endian_little.go b/cpu/endian_little.go index fe545966b6..55db853efb 100644 --- a/cpu/endian_little.go +++ b/cpu/endian_little.go @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh -// +build 386 amd64 amd64p32 alpha arm arm64 loong64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh +//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh || wasm +// +build 386 amd64 amd64p32 alpha arm arm64 loong64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh wasm package cpu From 352d8339e8b9a29c57d977f5c64810689466b25b Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 15 May 2023 14:32:57 +0200 Subject: [PATCH 03/18] cpu: add test for IsBigEndian For golang/go#57237 Change-Id: I11d1c954f942ebd836c4deb9c710c40778dc5599 Reviewed-on: https://go-review.googlesource.com/c/sys/+/494858 Auto-Submit: Tobias Klauser Run-TryBot: Tobias Klauser Reviewed-by: Ian Lance Taylor Reviewed-by: Heschi Kreinick TryBot-Result: Gopher Robot --- cpu/endian_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 cpu/endian_test.go diff --git a/cpu/endian_test.go b/cpu/endian_test.go new file mode 100644 index 0000000000..b066bfb3ff --- /dev/null +++ b/cpu/endian_test.go @@ -0,0 +1,21 @@ +// Copyright 2023 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. + +package cpu_test + +import ( + "testing" + "unsafe" + + "golang.org/x/sys/cpu" +) + +func TestIsBigEndian(t *testing.T) { + b := uint16(0xff00) + want := *(*byte)(unsafe.Pointer(&b)) == 0xff + if cpu.IsBigEndian != want { + t.Errorf("IsBigEndian = %t, want %t", + cpu.IsBigEndian, want) + } +} From c8ea6b0cbc9ffb7927e068f279c46cb342d0c956 Mon Sep 17 00:00:00 2001 From: Roman Mazur Date: Wed, 17 May 2023 22:45:36 +0200 Subject: [PATCH 04/18] windows: fix EnumProcesses to pass the correct array size Implementation generated directly with mkwinsyscall has a wrong assumption about the expected value for PIDs buffer size. This change adds some small manual code that converts the input slice length to the number of bytes of the array backing the slice. A test is also added. It fails with the previous implementation. Fixes golang/go#60223 Change-Id: I5e2414acb29c6c949e5e6acd328043f8a8883887 Reviewed-on: https://go-review.googlesource.com/c/sys/+/495995 Commit-Queue: Quim Muntal TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills Run-TryBot: Quim Muntal Reviewed-by: Quim Muntal Reviewed-by: Heschi Kreinick --- windows/syscall_windows.go | 13 ++++++++++++- windows/syscall_windows_test.go | 22 ++++++++++++++++++++++ windows/zsyscall_windows.go | 8 ++------ 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/windows/syscall_windows.go b/windows/syscall_windows.go index 3723b2c224..9645900754 100644 --- a/windows/syscall_windows.go +++ b/windows/syscall_windows.go @@ -405,7 +405,7 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys VerQueryValue(block unsafe.Pointer, subBlock string, pointerToBufferPointer unsafe.Pointer, bufSize *uint32) (err error) = version.VerQueryValueW // Process Status API (PSAPI) -//sys EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) = psapi.EnumProcesses +//sys enumProcesses(processIds *uint32, nSize uint32, bytesReturned *uint32) (err error) = psapi.EnumProcesses //sys EnumProcessModules(process Handle, module *Handle, cb uint32, cbNeeded *uint32) (err error) = psapi.EnumProcessModules //sys EnumProcessModulesEx(process Handle, module *Handle, cb uint32, cbNeeded *uint32, filterFlag uint32) (err error) = psapi.EnumProcessModulesEx //sys GetModuleInformation(process Handle, module Handle, modinfo *ModuleInfo, cb uint32) (err error) = psapi.GetModuleInformation @@ -1354,6 +1354,17 @@ func SetsockoptIPv6Mreq(fd Handle, level, opt int, mreq *IPv6Mreq) (err error) { return syscall.EWINDOWS } +func EnumProcesses(processIds []uint32, bytesReturned *uint32) error { + // EnumProcesses syscall expects the size parameter to be in bytes, but the code generated with mksyscall uses + // the length of the processIds slice instead. Hence, this wrapper function is added to fix the discrepancy. + var p *uint32 + if len(processIds) > 0 { + p = &processIds[0] + } + size := uint32(len(processIds) * 4) + return enumProcesses(p, size, bytesReturned) +} + func Getpid() (pid int) { return int(GetCurrentProcessId()) } func FindFirstFile(name *uint16, data *Win32finddata) (handle Handle, err error) { diff --git a/windows/syscall_windows_test.go b/windows/syscall_windows_test.go index 42c01fc968..81050d3370 100644 --- a/windows/syscall_windows_test.go +++ b/windows/syscall_windows_test.go @@ -717,6 +717,28 @@ func TestWinVerifyTrust(t *testing.T) { } +func TestEnumProcesses(t *testing.T) { + var ( + pids [2]uint32 + outSize uint32 + ) + err := windows.EnumProcesses(pids[:], &outSize) + if err != nil { + t.Fatalf("unable to enumerate processes: %v", err) + } + + // Regression check for go.dev/issue/60223 + if outSize != 8 { + t.Errorf("unexpected bytes returned: %d", outSize) + } + // Most likely, this should be [0, 4]. + // 0 is the system idle pseudo-process. 4 is the initial system process ID. + // This test expects that at least one of the PIDs is not 0. + if pids[0] == 0 && pids[1] == 0 { + t.Errorf("all PIDs are 0") + } +} + func TestProcessModules(t *testing.T) { process, err := windows.GetCurrentProcess() if err != nil { diff --git a/windows/zsyscall_windows.go b/windows/zsyscall_windows.go index a81ea2c700..566dd3e315 100644 --- a/windows/zsyscall_windows.go +++ b/windows/zsyscall_windows.go @@ -3516,12 +3516,8 @@ func EnumProcessModulesEx(process Handle, module *Handle, cb uint32, cbNeeded *u return } -func EnumProcesses(processIds []uint32, bytesReturned *uint32) (err error) { - var _p0 *uint32 - if len(processIds) > 0 { - _p0 = &processIds[0] - } - r1, _, e1 := syscall.Syscall(procEnumProcesses.Addr(), 3, uintptr(unsafe.Pointer(_p0)), uintptr(len(processIds)), uintptr(unsafe.Pointer(bytesReturned))) +func enumProcesses(processIds *uint32, nSize uint32, bytesReturned *uint32) (err error) { + r1, _, e1 := syscall.Syscall(procEnumProcesses.Addr(), 3, uintptr(unsafe.Pointer(processIds)), uintptr(nSize), uintptr(unsafe.Pointer(bytesReturned))) if r1 == 0 { err = errnoErr(e1) } From b5c7a0975ddc3d04a37152e997b3f70ecb531eb7 Mon Sep 17 00:00:00 2001 From: Florian Lehner Date: Fri, 19 May 2023 14:59:35 +0200 Subject: [PATCH 05/18] unix: update BPF constants with Linux kernel 6.2 Change-Id: Iaa92ec9e8ff6e337457ea4f57b4c046221128d43 Reviewed-on: https://go-review.googlesource.com/c/sys/+/496675 Run-TryBot: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: Tobias Klauser Reviewed-by: Ian Lance Taylor Reviewed-by: Matthew Dempsky TryBot-Result: Gopher Robot Auto-Submit: Ian Lance Taylor --- unix/linux/types.go | 46 +++++++++++++++++++++++++++++++++ unix/zerrors_linux_sparc64.go | 48 +++++++++++++++++++++++++++++++++++ unix/ztypes_linux.go | 46 +++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+) diff --git a/unix/linux/types.go b/unix/linux/types.go index 671453331c..fff4ed3001 100644 --- a/unix/linux/types.go +++ b/unix/linux/types.go @@ -2543,6 +2543,11 @@ const ( BPF_REG_8 = C.BPF_REG_8 BPF_REG_9 = C.BPF_REG_9 BPF_REG_10 = C.BPF_REG_10 + BPF_CGROUP_ITER_ORDER_UNSPEC = C.BPF_CGROUP_ITER_ORDER_UNSPEC + BPF_CGROUP_ITER_SELF_ONLY = C.BPF_CGROUP_ITER_SELF_ONLY + BPF_CGROUP_ITER_DESCENDANTS_PRE = C.BPF_CGROUP_ITER_DESCENDANTS_PRE + BPF_CGROUP_ITER_DESCENDANTS_POST = C.BPF_CGROUP_ITER_DESCENDANTS_POST + BPF_CGROUP_ITER_ANCESTORS_UP = C.BPF_CGROUP_ITER_ANCESTORS_UP BPF_MAP_CREATE = C.BPF_MAP_CREATE BPF_MAP_LOOKUP_ELEM = C.BPF_MAP_LOOKUP_ELEM BPF_MAP_UPDATE_ELEM = C.BPF_MAP_UPDATE_ELEM @@ -2554,6 +2559,7 @@ const ( BPF_PROG_ATTACH = C.BPF_PROG_ATTACH BPF_PROG_DETACH = C.BPF_PROG_DETACH BPF_PROG_TEST_RUN = C.BPF_PROG_TEST_RUN + BPF_PROG_RUN = C.BPF_PROG_RUN BPF_PROG_GET_NEXT_ID = C.BPF_PROG_GET_NEXT_ID BPF_MAP_GET_NEXT_ID = C.BPF_MAP_GET_NEXT_ID BPF_PROG_GET_FD_BY_ID = C.BPF_PROG_GET_FD_BY_ID @@ -2598,6 +2604,7 @@ const ( BPF_MAP_TYPE_CPUMAP = C.BPF_MAP_TYPE_CPUMAP BPF_MAP_TYPE_XSKMAP = C.BPF_MAP_TYPE_XSKMAP BPF_MAP_TYPE_SOCKHASH = C.BPF_MAP_TYPE_SOCKHASH + BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED = C.BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED BPF_MAP_TYPE_CGROUP_STORAGE = C.BPF_MAP_TYPE_CGROUP_STORAGE BPF_MAP_TYPE_REUSEPORT_SOCKARRAY = C.BPF_MAP_TYPE_REUSEPORT_SOCKARRAY BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = C.BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE @@ -2608,6 +2615,10 @@ const ( BPF_MAP_TYPE_STRUCT_OPS = C.BPF_MAP_TYPE_STRUCT_OPS BPF_MAP_TYPE_RINGBUF = C.BPF_MAP_TYPE_RINGBUF BPF_MAP_TYPE_INODE_STORAGE = C.BPF_MAP_TYPE_INODE_STORAGE + BPF_MAP_TYPE_TASK_STORAGE = C.BPF_MAP_TYPE_TASK_STORAGE + BPF_MAP_TYPE_BLOOM_FILTER = C.BPF_MAP_TYPE_BLOOM_FILTER + BPF_MAP_TYPE_USER_RINGBUF = C.BPF_MAP_TYPE_USER_RINGBUF + BPF_MAP_TYPE_CGRP_STORAGE = C.BPF_MAP_TYPE_CGRP_STORAGE BPF_PROG_TYPE_UNSPEC = C.BPF_PROG_TYPE_UNSPEC BPF_PROG_TYPE_SOCKET_FILTER = C.BPF_PROG_TYPE_SOCKET_FILTER BPF_PROG_TYPE_KPROBE = C.BPF_PROG_TYPE_KPROBE @@ -2639,6 +2650,7 @@ const ( BPF_PROG_TYPE_EXT = C.BPF_PROG_TYPE_EXT BPF_PROG_TYPE_LSM = C.BPF_PROG_TYPE_LSM BPF_PROG_TYPE_SK_LOOKUP = C.BPF_PROG_TYPE_SK_LOOKUP + BPF_PROG_TYPE_SYSCALL = C.BPF_PROG_TYPE_SYSCALL BPF_CGROUP_INET_INGRESS = C.BPF_CGROUP_INET_INGRESS BPF_CGROUP_INET_EGRESS = C.BPF_CGROUP_INET_EGRESS BPF_CGROUP_INET_SOCK_CREATE = C.BPF_CGROUP_INET_SOCK_CREATE @@ -2677,6 +2689,12 @@ const ( BPF_XDP_CPUMAP = C.BPF_XDP_CPUMAP BPF_SK_LOOKUP = C.BPF_SK_LOOKUP BPF_XDP = C.BPF_XDP + BPF_SK_SKB_VERDICT = C.BPF_SK_SKB_VERDICT + BPF_SK_REUSEPORT_SELECT = C.BPF_SK_REUSEPORT_SELECT + BPF_SK_REUSEPORT_SELECT_OR_MIGRATE = C.BPF_SK_REUSEPORT_SELECT_OR_MIGRATE + BPF_PERF_EVENT = C.BPF_PERF_EVENT + BPF_TRACE_KPROBE_MULTI = C.BPF_TRACE_KPROBE_MULTI + BPF_LSM_CGROUP = C.BPF_LSM_CGROUP BPF_LINK_TYPE_UNSPEC = C.BPF_LINK_TYPE_UNSPEC BPF_LINK_TYPE_RAW_TRACEPOINT = C.BPF_LINK_TYPE_RAW_TRACEPOINT BPF_LINK_TYPE_TRACING = C.BPF_LINK_TYPE_TRACING @@ -2684,6 +2702,9 @@ const ( BPF_LINK_TYPE_ITER = C.BPF_LINK_TYPE_ITER BPF_LINK_TYPE_NETNS = C.BPF_LINK_TYPE_NETNS BPF_LINK_TYPE_XDP = C.BPF_LINK_TYPE_XDP + BPF_LINK_TYPE_PERF_EVENT = C.BPF_LINK_TYPE_PERF_EVENT + BPF_LINK_TYPE_KPROBE_MULTI = C.BPF_LINK_TYPE_KPROBE_MULTI + BPF_LINK_TYPE_STRUCT_OPS = C.BPF_LINK_TYPE_STRUCT_OPS BPF_ANY = C.BPF_ANY BPF_NOEXIST = C.BPF_NOEXIST BPF_EXIST = C.BPF_EXIST @@ -2721,6 +2742,7 @@ const ( BPF_F_ZERO_CSUM_TX = C.BPF_F_ZERO_CSUM_TX BPF_F_DONT_FRAGMENT = C.BPF_F_DONT_FRAGMENT BPF_F_SEQ_NUMBER = C.BPF_F_SEQ_NUMBER + BPF_F_TUNINFO_FLAGS = C.BPF_F_TUNINFO_FLAGS BPF_F_INDEX_MASK = C.BPF_F_INDEX_MASK BPF_F_CURRENT_CPU = C.BPF_F_CURRENT_CPU BPF_F_CTXLEN_MASK = C.BPF_F_CTXLEN_MASK @@ -2735,6 +2757,7 @@ const ( BPF_F_ADJ_ROOM_ENCAP_L4_GRE = C.BPF_F_ADJ_ROOM_ENCAP_L4_GRE BPF_F_ADJ_ROOM_ENCAP_L4_UDP = C.BPF_F_ADJ_ROOM_ENCAP_L4_UDP BPF_F_ADJ_ROOM_NO_CSUM_RESET = C.BPF_F_ADJ_ROOM_NO_CSUM_RESET + BPF_F_ADJ_ROOM_ENCAP_L2_ETH = C.BPF_F_ADJ_ROOM_ENCAP_L2_ETH BPF_ADJ_ROOM_ENCAP_L2_MASK = C.BPF_ADJ_ROOM_ENCAP_L2_MASK BPF_ADJ_ROOM_ENCAP_L2_SHIFT = C.BPF_ADJ_ROOM_ENCAP_L2_SHIFT BPF_F_SYSCTL_BASE_NAME = C.BPF_F_SYSCTL_BASE_NAME @@ -2759,10 +2782,16 @@ const ( BPF_LWT_ENCAP_SEG6 = C.BPF_LWT_ENCAP_SEG6 BPF_LWT_ENCAP_SEG6_INLINE = C.BPF_LWT_ENCAP_SEG6_INLINE BPF_LWT_ENCAP_IP = C.BPF_LWT_ENCAP_IP + BPF_F_BPRM_SECUREEXEC = C.BPF_F_BPRM_SECUREEXEC + BPF_F_BROADCAST = C.BPF_F_BROADCAST + BPF_F_EXCLUDE_INGRESS = C.BPF_F_EXCLUDE_INGRESS + BPF_SKB_TSTAMP_UNSPEC = C.BPF_SKB_TSTAMP_UNSPEC + BPF_SKB_TSTAMP_DELIVERY_MONO = C.BPF_SKB_TSTAMP_DELIVERY_MONO BPF_OK = C.BPF_OK BPF_DROP = C.BPF_DROP BPF_REDIRECT = C.BPF_REDIRECT BPF_LWT_REROUTE = C.BPF_LWT_REROUTE + BPF_FLOW_DISSECTOR_CONTINUE = C.BPF_FLOW_DISSECTOR_CONTINUE BPF_SOCK_OPS_RTO_CB_FLAG = C.BPF_SOCK_OPS_RTO_CB_FLAG BPF_SOCK_OPS_RETRANS_CB_FLAG = C.BPF_SOCK_OPS_RETRANS_CB_FLAG BPF_SOCK_OPS_STATE_CB_FLAG = C.BPF_SOCK_OPS_STATE_CB_FLAG @@ -2826,6 +2855,10 @@ const ( BPF_FIB_LKUP_RET_UNSUPP_LWT = C.BPF_FIB_LKUP_RET_UNSUPP_LWT BPF_FIB_LKUP_RET_NO_NEIGH = C.BPF_FIB_LKUP_RET_NO_NEIGH BPF_FIB_LKUP_RET_FRAG_NEEDED = C.BPF_FIB_LKUP_RET_FRAG_NEEDED + BPF_MTU_CHK_SEGS = C.BPF_MTU_CHK_SEGS + BPF_MTU_CHK_RET_SUCCESS = C.BPF_MTU_CHK_RET_SUCCESS + BPF_MTU_CHK_RET_FRAG_NEEDED = C.BPF_MTU_CHK_RET_FRAG_NEEDED + BPF_MTU_CHK_RET_SEGS_TOOBIG = C.BPF_MTU_CHK_RET_SEGS_TOOBIG BPF_FD_TYPE_RAW_TRACEPOINT = C.BPF_FD_TYPE_RAW_TRACEPOINT BPF_FD_TYPE_TRACEPOINT = C.BPF_FD_TYPE_TRACEPOINT BPF_FD_TYPE_KPROBE = C.BPF_FD_TYPE_KPROBE @@ -2835,6 +2868,19 @@ const ( BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = C.BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = C.BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = C.BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP + BPF_CORE_FIELD_BYTE_OFFSET = C.BPF_CORE_FIELD_BYTE_OFFSET + BPF_CORE_FIELD_BYTE_SIZE = C.BPF_CORE_FIELD_BYTE_SIZE + BPF_CORE_FIELD_EXISTS = C.BPF_CORE_FIELD_EXISTS + BPF_CORE_FIELD_SIGNED = C.BPF_CORE_FIELD_SIGNED + BPF_CORE_FIELD_LSHIFT_U64 = C.BPF_CORE_FIELD_LSHIFT_U64 + BPF_CORE_FIELD_RSHIFT_U64 = C.BPF_CORE_FIELD_RSHIFT_U64 + BPF_CORE_TYPE_ID_LOCAL = C.BPF_CORE_TYPE_ID_LOCAL + BPF_CORE_TYPE_ID_TARGET = C.BPF_CORE_TYPE_ID_TARGET + BPF_CORE_TYPE_EXISTS = C.BPF_CORE_TYPE_EXISTS + BPF_CORE_TYPE_SIZE = C.BPF_CORE_TYPE_SIZE + BPF_CORE_ENUMVAL_EXISTS = C.BPF_CORE_ENUMVAL_EXISTS + BPF_CORE_ENUMVAL_VALUE = C.BPF_CORE_ENUMVAL_VALUE + BPF_CORE_TYPE_MATCHES = C.BPF_CORE_TYPE_MATCHES ) // generated by: diff --git a/unix/zerrors_linux_sparc64.go b/unix/zerrors_linux_sparc64.go index f619252691..48984202c6 100644 --- a/unix/zerrors_linux_sparc64.go +++ b/unix/zerrors_linux_sparc64.go @@ -329,6 +329,54 @@ const ( SCM_WIFI_STATUS = 0x25 SFD_CLOEXEC = 0x400000 SFD_NONBLOCK = 0x4000 + SF_FP = 0x38 + SF_I0 = 0x20 + SF_I1 = 0x24 + SF_I2 = 0x28 + SF_I3 = 0x2c + SF_I4 = 0x30 + SF_I5 = 0x34 + SF_L0 = 0x0 + SF_L1 = 0x4 + SF_L2 = 0x8 + SF_L3 = 0xc + SF_L4 = 0x10 + SF_L5 = 0x14 + SF_L6 = 0x18 + SF_L7 = 0x1c + SF_PC = 0x3c + SF_RETP = 0x40 + SF_V9_FP = 0x70 + SF_V9_I0 = 0x40 + SF_V9_I1 = 0x48 + SF_V9_I2 = 0x50 + SF_V9_I3 = 0x58 + SF_V9_I4 = 0x60 + SF_V9_I5 = 0x68 + SF_V9_L0 = 0x0 + SF_V9_L1 = 0x8 + SF_V9_L2 = 0x10 + SF_V9_L3 = 0x18 + SF_V9_L4 = 0x20 + SF_V9_L5 = 0x28 + SF_V9_L6 = 0x30 + SF_V9_L7 = 0x38 + SF_V9_PC = 0x78 + SF_V9_RETP = 0x80 + SF_V9_XARG0 = 0x88 + SF_V9_XARG1 = 0x90 + SF_V9_XARG2 = 0x98 + SF_V9_XARG3 = 0xa0 + SF_V9_XARG4 = 0xa8 + SF_V9_XARG5 = 0xb0 + SF_V9_XXARG = 0xb8 + SF_XARG0 = 0x44 + SF_XARG1 = 0x48 + SF_XARG2 = 0x4c + SF_XARG3 = 0x50 + SF_XARG4 = 0x54 + SF_XARG5 = 0x58 + SF_XXARG = 0x5c SIOCATMARK = 0x8905 SIOCGPGRP = 0x8904 SIOCGSTAMPNS_NEW = 0x40108907 diff --git a/unix/ztypes_linux.go b/unix/ztypes_linux.go index ca84727cfe..00c3b8c20f 100644 --- a/unix/ztypes_linux.go +++ b/unix/ztypes_linux.go @@ -2555,6 +2555,11 @@ const ( BPF_REG_8 = 0x8 BPF_REG_9 = 0x9 BPF_REG_10 = 0xa + BPF_CGROUP_ITER_ORDER_UNSPEC = 0x0 + BPF_CGROUP_ITER_SELF_ONLY = 0x1 + BPF_CGROUP_ITER_DESCENDANTS_PRE = 0x2 + BPF_CGROUP_ITER_DESCENDANTS_POST = 0x3 + BPF_CGROUP_ITER_ANCESTORS_UP = 0x4 BPF_MAP_CREATE = 0x0 BPF_MAP_LOOKUP_ELEM = 0x1 BPF_MAP_UPDATE_ELEM = 0x2 @@ -2566,6 +2571,7 @@ const ( BPF_PROG_ATTACH = 0x8 BPF_PROG_DETACH = 0x9 BPF_PROG_TEST_RUN = 0xa + BPF_PROG_RUN = 0xa BPF_PROG_GET_NEXT_ID = 0xb BPF_MAP_GET_NEXT_ID = 0xc BPF_PROG_GET_FD_BY_ID = 0xd @@ -2610,6 +2616,7 @@ const ( BPF_MAP_TYPE_CPUMAP = 0x10 BPF_MAP_TYPE_XSKMAP = 0x11 BPF_MAP_TYPE_SOCKHASH = 0x12 + BPF_MAP_TYPE_CGROUP_STORAGE_DEPRECATED = 0x13 BPF_MAP_TYPE_CGROUP_STORAGE = 0x13 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY = 0x14 BPF_MAP_TYPE_PERCPU_CGROUP_STORAGE = 0x15 @@ -2620,6 +2627,10 @@ const ( BPF_MAP_TYPE_STRUCT_OPS = 0x1a BPF_MAP_TYPE_RINGBUF = 0x1b BPF_MAP_TYPE_INODE_STORAGE = 0x1c + BPF_MAP_TYPE_TASK_STORAGE = 0x1d + BPF_MAP_TYPE_BLOOM_FILTER = 0x1e + BPF_MAP_TYPE_USER_RINGBUF = 0x1f + BPF_MAP_TYPE_CGRP_STORAGE = 0x20 BPF_PROG_TYPE_UNSPEC = 0x0 BPF_PROG_TYPE_SOCKET_FILTER = 0x1 BPF_PROG_TYPE_KPROBE = 0x2 @@ -2651,6 +2662,7 @@ const ( BPF_PROG_TYPE_EXT = 0x1c BPF_PROG_TYPE_LSM = 0x1d BPF_PROG_TYPE_SK_LOOKUP = 0x1e + BPF_PROG_TYPE_SYSCALL = 0x1f BPF_CGROUP_INET_INGRESS = 0x0 BPF_CGROUP_INET_EGRESS = 0x1 BPF_CGROUP_INET_SOCK_CREATE = 0x2 @@ -2689,6 +2701,12 @@ const ( BPF_XDP_CPUMAP = 0x23 BPF_SK_LOOKUP = 0x24 BPF_XDP = 0x25 + BPF_SK_SKB_VERDICT = 0x26 + BPF_SK_REUSEPORT_SELECT = 0x27 + BPF_SK_REUSEPORT_SELECT_OR_MIGRATE = 0x28 + BPF_PERF_EVENT = 0x29 + BPF_TRACE_KPROBE_MULTI = 0x2a + BPF_LSM_CGROUP = 0x2b BPF_LINK_TYPE_UNSPEC = 0x0 BPF_LINK_TYPE_RAW_TRACEPOINT = 0x1 BPF_LINK_TYPE_TRACING = 0x2 @@ -2696,6 +2714,9 @@ const ( BPF_LINK_TYPE_ITER = 0x4 BPF_LINK_TYPE_NETNS = 0x5 BPF_LINK_TYPE_XDP = 0x6 + BPF_LINK_TYPE_PERF_EVENT = 0x7 + BPF_LINK_TYPE_KPROBE_MULTI = 0x8 + BPF_LINK_TYPE_STRUCT_OPS = 0x9 BPF_ANY = 0x0 BPF_NOEXIST = 0x1 BPF_EXIST = 0x2 @@ -2733,6 +2754,7 @@ const ( BPF_F_ZERO_CSUM_TX = 0x2 BPF_F_DONT_FRAGMENT = 0x4 BPF_F_SEQ_NUMBER = 0x8 + BPF_F_TUNINFO_FLAGS = 0x10 BPF_F_INDEX_MASK = 0xffffffff BPF_F_CURRENT_CPU = 0xffffffff BPF_F_CTXLEN_MASK = 0xfffff00000000 @@ -2747,6 +2769,7 @@ const ( BPF_F_ADJ_ROOM_ENCAP_L4_GRE = 0x8 BPF_F_ADJ_ROOM_ENCAP_L4_UDP = 0x10 BPF_F_ADJ_ROOM_NO_CSUM_RESET = 0x20 + BPF_F_ADJ_ROOM_ENCAP_L2_ETH = 0x40 BPF_ADJ_ROOM_ENCAP_L2_MASK = 0xff BPF_ADJ_ROOM_ENCAP_L2_SHIFT = 0x38 BPF_F_SYSCTL_BASE_NAME = 0x1 @@ -2771,10 +2794,16 @@ const ( BPF_LWT_ENCAP_SEG6 = 0x0 BPF_LWT_ENCAP_SEG6_INLINE = 0x1 BPF_LWT_ENCAP_IP = 0x2 + BPF_F_BPRM_SECUREEXEC = 0x1 + BPF_F_BROADCAST = 0x8 + BPF_F_EXCLUDE_INGRESS = 0x10 + BPF_SKB_TSTAMP_UNSPEC = 0x0 + BPF_SKB_TSTAMP_DELIVERY_MONO = 0x1 BPF_OK = 0x0 BPF_DROP = 0x2 BPF_REDIRECT = 0x7 BPF_LWT_REROUTE = 0x80 + BPF_FLOW_DISSECTOR_CONTINUE = 0x81 BPF_SOCK_OPS_RTO_CB_FLAG = 0x1 BPF_SOCK_OPS_RETRANS_CB_FLAG = 0x2 BPF_SOCK_OPS_STATE_CB_FLAG = 0x4 @@ -2838,6 +2867,10 @@ const ( BPF_FIB_LKUP_RET_UNSUPP_LWT = 0x6 BPF_FIB_LKUP_RET_NO_NEIGH = 0x7 BPF_FIB_LKUP_RET_FRAG_NEEDED = 0x8 + BPF_MTU_CHK_SEGS = 0x1 + BPF_MTU_CHK_RET_SUCCESS = 0x0 + BPF_MTU_CHK_RET_FRAG_NEEDED = 0x1 + BPF_MTU_CHK_RET_SEGS_TOOBIG = 0x2 BPF_FD_TYPE_RAW_TRACEPOINT = 0x0 BPF_FD_TYPE_TRACEPOINT = 0x1 BPF_FD_TYPE_KPROBE = 0x2 @@ -2847,6 +2880,19 @@ const ( BPF_FLOW_DISSECTOR_F_PARSE_1ST_FRAG = 0x1 BPF_FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL = 0x2 BPF_FLOW_DISSECTOR_F_STOP_AT_ENCAP = 0x4 + BPF_CORE_FIELD_BYTE_OFFSET = 0x0 + BPF_CORE_FIELD_BYTE_SIZE = 0x1 + BPF_CORE_FIELD_EXISTS = 0x2 + BPF_CORE_FIELD_SIGNED = 0x3 + BPF_CORE_FIELD_LSHIFT_U64 = 0x4 + BPF_CORE_FIELD_RSHIFT_U64 = 0x5 + BPF_CORE_TYPE_ID_LOCAL = 0x6 + BPF_CORE_TYPE_ID_TARGET = 0x7 + BPF_CORE_TYPE_EXISTS = 0x8 + BPF_CORE_TYPE_SIZE = 0x9 + BPF_CORE_ENUMVAL_EXISTS = 0xa + BPF_CORE_ENUMVAL_VALUE = 0xb + BPF_CORE_TYPE_MATCHES = 0xc ) const ( From b52f5441ce4ee981d7a9295a5ddad71e196486a7 Mon Sep 17 00:00:00 2001 From: Mateusz Poliwczak Date: Tue, 30 May 2023 08:16:36 +0000 Subject: [PATCH 06/18] unix: add Getresuid, Getresgid for linux Fixes golang/go#60483 Change-Id: Id4c1bf8367066485a16bedeea337c384a3555942 GitHub-Last-Rev: 61f0fe6f6a5be1cd34ddf99e72a75cfd32355793 GitHub-Pull-Request: golang/sys#159 Reviewed-on: https://go-review.googlesource.com/c/sys/+/499055 Run-TryBot: Ian Lance Taylor Reviewed-by: Ian Lance Taylor TryBot-Result: Gopher Robot Run-TryBot: Ian Lance Taylor Auto-Submit: Ian Lance Taylor Reviewed-by: Tobias Klauser Reviewed-by: Michael Knyszek --- unix/syscall_linux.go | 15 +++++++++++++++ unix/zsyscall_linux.go | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go index fbaeb5fff1..aa0c55151a 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -2420,6 +2420,21 @@ func PthreadSigmask(how int, set, oldset *Sigset_t) error { return rtSigprocmask(how, set, oldset, _C__NSIG/8) } +//sysnb getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) +//sysnb getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) + +func Getresuid() (ruid, euid, suid int) { + var r, e, s _C_int + getresuid(&r, &e, &s) + return int(r), int(e), int(s) +} + +func Getresgid() (rgid, egid, sgid int) { + var r, e, s _C_int + getresgid(&r, &e, &s) + return int(r), int(e), int(s) +} + /* * Unimplemented */ diff --git a/unix/zsyscall_linux.go b/unix/zsyscall_linux.go index da63d9d782..722c29a008 100644 --- a/unix/zsyscall_linux.go +++ b/unix/zsyscall_linux.go @@ -2172,3 +2172,17 @@ func rtSigprocmask(how int, set *Sigset_t, oldset *Sigset_t, sigsetsize uintptr) } return } + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) { + RawSyscallNoError(SYS_GETRESUID, uintptr(unsafe.Pointer(ruid)), uintptr(unsafe.Pointer(euid)), uintptr(unsafe.Pointer(suid))) + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { + RawSyscallNoError(SYS_GETRESGID, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) + return +} From ff98eae2a0cc3ace67e30e3e41908d279a7c13cb Mon Sep 17 00:00:00 2001 From: Alvar Penning Date: Sun, 4 Jun 2023 15:20:27 +0000 Subject: [PATCH 07/18] unix: remove absolute path of pwd from mkall.sh The pwd command does not always reside under /bin for all Linux distributions. As a $PATH is otherwise always assumed, here too. Change-Id: I8a9b65fedc0bdd6b963f30e69d5c98b1550326cd GitHub-Last-Rev: ff9227dbe6029506a932d033feea2059c15b4fec GitHub-Pull-Request: golang/sys#161 Reviewed-on: https://go-review.googlesource.com/c/sys/+/500656 Run-TryBot: Ian Lance Taylor Auto-Submit: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot --- unix/mkall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unix/mkall.sh b/unix/mkall.sh index 8e3947c368..e6f31d374d 100755 --- a/unix/mkall.sh +++ b/unix/mkall.sh @@ -50,7 +50,7 @@ if [[ "$GOOS" = "linux" ]]; then # Use the Docker-based build system # Files generated through docker (use $cmd so you can Ctl-C the build or run) $cmd docker build --tag generate:$GOOS $GOOS - $cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && /bin/pwd):/build generate:$GOOS + $cmd docker run --interactive --tty --volume $(cd -- "$(dirname -- "$0")/.." && pwd):/build generate:$GOOS exit fi From 81c8a6c06d9eb977a4869e7a6b0f9c03f6be9c4e Mon Sep 17 00:00:00 2001 From: Alvar Penning Date: Sun, 4 Jun 2023 07:56:06 +0000 Subject: [PATCH 08/18] unix: add Getresuid and Getresgid for OpenBSD Addresses golang/go#60483 for OpenBSD. This change was successfully tested on amd64 and adjusted accordingly for the other architectures. Change-Id: Id63cca342d81d2cc5854eb2923ca7e66bfaa91bf GitHub-Last-Rev: cff11701438edc20bef2961bb73bf9c6ea81b4a1 GitHub-Pull-Request: golang/sys#160 Reviewed-on: https://go-review.googlesource.com/c/sys/+/500655 Reviewed-by: David Chase Run-TryBot: Ian Lance Taylor Auto-Submit: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Reviewed-by: Tobias Klauser TryBot-Result: Gopher Robot --- unix/syscall_openbsd.go | 17 +++++++++++++++-- unix/zsyscall_openbsd_386.go | 22 ++++++++++++++++++++++ unix/zsyscall_openbsd_386.s | 10 ++++++++++ unix/zsyscall_openbsd_amd64.go | 32 ++++++++++++++++++++++++++++---- unix/zsyscall_openbsd_amd64.s | 10 ++++++++++ unix/zsyscall_openbsd_arm.go | 22 ++++++++++++++++++++++ unix/zsyscall_openbsd_arm.s | 10 ++++++++++ unix/zsyscall_openbsd_arm64.go | 22 ++++++++++++++++++++++ unix/zsyscall_openbsd_arm64.s | 10 ++++++++++ unix/zsyscall_openbsd_mips64.go | 22 ++++++++++++++++++++++ unix/zsyscall_openbsd_mips64.s | 10 ++++++++++ unix/zsyscall_openbsd_ppc64.go | 22 ++++++++++++++++++++++ unix/zsyscall_openbsd_ppc64.s | 12 ++++++++++++ unix/zsyscall_openbsd_riscv64.go | 22 ++++++++++++++++++++++ unix/zsyscall_openbsd_riscv64.s | 10 ++++++++++ 15 files changed, 247 insertions(+), 6 deletions(-) diff --git a/unix/syscall_openbsd.go b/unix/syscall_openbsd.go index f9c7a9663c..c5f166a115 100644 --- a/unix/syscall_openbsd.go +++ b/unix/syscall_openbsd.go @@ -151,6 +151,21 @@ func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { return } +//sysnb getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) +//sysnb getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) + +func Getresuid() (ruid, euid, suid int) { + var r, e, s _C_int + getresuid(&r, &e, &s) + return int(r), int(e), int(s) +} + +func Getresgid() (rgid, egid, sgid int) { + var r, e, s _C_int + getresgid(&r, &e, &s) + return int(r), int(e), int(s) +} + //sys ioctl(fd int, req uint, arg uintptr) (err error) //sys ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) = SYS_IOCTL @@ -338,8 +353,6 @@ func Uname(uname *Utsname) error { // getgid // getitimer // getlogin -// getresgid -// getresuid // getthrid // ktrace // lfs_bmapv diff --git a/unix/zsyscall_openbsd_386.go b/unix/zsyscall_openbsd_386.go index 6699a783e1..9ab9abf721 100644 --- a/unix/zsyscall_openbsd_386.go +++ b/unix/zsyscall_openbsd_386.go @@ -519,6 +519,28 @@ var libc_getcwd_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) { + syscall_rawSyscall(libc_getresuid_trampoline_addr, uintptr(unsafe.Pointer(ruid)), uintptr(unsafe.Pointer(euid)), uintptr(unsafe.Pointer(suid))) + return +} + +var libc_getresuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresuid getresuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { + syscall_rawSyscall(libc_getresgid_trampoline_addr, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) + return +} + +var libc_getresgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresgid getresgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { diff --git a/unix/zsyscall_openbsd_386.s b/unix/zsyscall_openbsd_386.s index 04f0de34b2..3dcacd30d7 100644 --- a/unix/zsyscall_openbsd_386.s +++ b/unix/zsyscall_openbsd_386.s @@ -158,6 +158,16 @@ TEXT libc_getcwd_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_getcwd_trampoline_addr(SB), RODATA, $4 DATA ·libc_getcwd_trampoline_addr(SB)/4, $libc_getcwd_trampoline<>(SB) +TEXT libc_getresuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresuid(SB) +GLOBL ·libc_getresuid_trampoline_addr(SB), RODATA, $4 +DATA ·libc_getresuid_trampoline_addr(SB)/4, $libc_getresuid_trampoline<>(SB) + +TEXT libc_getresgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresgid(SB) +GLOBL ·libc_getresgid_trampoline_addr(SB), RODATA, $4 +DATA ·libc_getresgid_trampoline_addr(SB)/4, $libc_getresgid_trampoline<>(SB) + TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_ioctl(SB) GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $4 diff --git a/unix/zsyscall_openbsd_amd64.go b/unix/zsyscall_openbsd_amd64.go index 1e775fe057..915761eab7 100644 --- a/unix/zsyscall_openbsd_amd64.go +++ b/unix/zsyscall_openbsd_amd64.go @@ -519,6 +519,28 @@ var libc_getcwd_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) { + syscall_rawSyscall(libc_getresuid_trampoline_addr, uintptr(unsafe.Pointer(ruid)), uintptr(unsafe.Pointer(euid)), uintptr(unsafe.Pointer(suid))) + return +} + +var libc_getresuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresuid getresuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { + syscall_rawSyscall(libc_getresgid_trampoline_addr, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) + return +} + +var libc_getresgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresgid getresgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { @@ -527,6 +549,12 @@ func ioctl(fd int, req uint, arg uintptr) (err error) { return } +var libc_ioctl_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_ioctl ioctl "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { @@ -535,10 +563,6 @@ func ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) { return } -var libc_ioctl_trampoline_addr uintptr - -//go:cgo_import_dynamic libc_ioctl ioctl "libc.so" - // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) { diff --git a/unix/zsyscall_openbsd_amd64.s b/unix/zsyscall_openbsd_amd64.s index 27b6f4df74..2763620b01 100644 --- a/unix/zsyscall_openbsd_amd64.s +++ b/unix/zsyscall_openbsd_amd64.s @@ -158,6 +158,16 @@ TEXT libc_getcwd_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_getcwd_trampoline_addr(SB), RODATA, $8 DATA ·libc_getcwd_trampoline_addr(SB)/8, $libc_getcwd_trampoline<>(SB) +TEXT libc_getresuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresuid(SB) +GLOBL ·libc_getresuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresuid_trampoline_addr(SB)/8, $libc_getresuid_trampoline<>(SB) + +TEXT libc_getresgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresgid(SB) +GLOBL ·libc_getresgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresgid_trampoline_addr(SB)/8, $libc_getresgid_trampoline<>(SB) + TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_ioctl(SB) GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 diff --git a/unix/zsyscall_openbsd_arm.go b/unix/zsyscall_openbsd_arm.go index 7f6427899a..8e87fdf153 100644 --- a/unix/zsyscall_openbsd_arm.go +++ b/unix/zsyscall_openbsd_arm.go @@ -519,6 +519,28 @@ var libc_getcwd_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) { + syscall_rawSyscall(libc_getresuid_trampoline_addr, uintptr(unsafe.Pointer(ruid)), uintptr(unsafe.Pointer(euid)), uintptr(unsafe.Pointer(suid))) + return +} + +var libc_getresuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresuid getresuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { + syscall_rawSyscall(libc_getresgid_trampoline_addr, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) + return +} + +var libc_getresgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresgid getresgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { diff --git a/unix/zsyscall_openbsd_arm.s b/unix/zsyscall_openbsd_arm.s index b797045fd2..c922314048 100644 --- a/unix/zsyscall_openbsd_arm.s +++ b/unix/zsyscall_openbsd_arm.s @@ -158,6 +158,16 @@ TEXT libc_getcwd_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_getcwd_trampoline_addr(SB), RODATA, $4 DATA ·libc_getcwd_trampoline_addr(SB)/4, $libc_getcwd_trampoline<>(SB) +TEXT libc_getresuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresuid(SB) +GLOBL ·libc_getresuid_trampoline_addr(SB), RODATA, $4 +DATA ·libc_getresuid_trampoline_addr(SB)/4, $libc_getresuid_trampoline<>(SB) + +TEXT libc_getresgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresgid(SB) +GLOBL ·libc_getresgid_trampoline_addr(SB), RODATA, $4 +DATA ·libc_getresgid_trampoline_addr(SB)/4, $libc_getresgid_trampoline<>(SB) + TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_ioctl(SB) GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $4 diff --git a/unix/zsyscall_openbsd_arm64.go b/unix/zsyscall_openbsd_arm64.go index 756ef7b173..12a7a2160e 100644 --- a/unix/zsyscall_openbsd_arm64.go +++ b/unix/zsyscall_openbsd_arm64.go @@ -519,6 +519,28 @@ var libc_getcwd_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) { + syscall_rawSyscall(libc_getresuid_trampoline_addr, uintptr(unsafe.Pointer(ruid)), uintptr(unsafe.Pointer(euid)), uintptr(unsafe.Pointer(suid))) + return +} + +var libc_getresuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresuid getresuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { + syscall_rawSyscall(libc_getresgid_trampoline_addr, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) + return +} + +var libc_getresgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresgid getresgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { diff --git a/unix/zsyscall_openbsd_arm64.s b/unix/zsyscall_openbsd_arm64.s index a871266221..a6bc32c922 100644 --- a/unix/zsyscall_openbsd_arm64.s +++ b/unix/zsyscall_openbsd_arm64.s @@ -158,6 +158,16 @@ TEXT libc_getcwd_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_getcwd_trampoline_addr(SB), RODATA, $8 DATA ·libc_getcwd_trampoline_addr(SB)/8, $libc_getcwd_trampoline<>(SB) +TEXT libc_getresuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresuid(SB) +GLOBL ·libc_getresuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresuid_trampoline_addr(SB)/8, $libc_getresuid_trampoline<>(SB) + +TEXT libc_getresgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresgid(SB) +GLOBL ·libc_getresgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresgid_trampoline_addr(SB)/8, $libc_getresgid_trampoline<>(SB) + TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_ioctl(SB) GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 diff --git a/unix/zsyscall_openbsd_mips64.go b/unix/zsyscall_openbsd_mips64.go index 7bc2e24eb9..b19e8aa031 100644 --- a/unix/zsyscall_openbsd_mips64.go +++ b/unix/zsyscall_openbsd_mips64.go @@ -519,6 +519,28 @@ var libc_getcwd_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) { + syscall_rawSyscall(libc_getresuid_trampoline_addr, uintptr(unsafe.Pointer(ruid)), uintptr(unsafe.Pointer(euid)), uintptr(unsafe.Pointer(suid))) + return +} + +var libc_getresuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresuid getresuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { + syscall_rawSyscall(libc_getresgid_trampoline_addr, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) + return +} + +var libc_getresgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresgid getresgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { diff --git a/unix/zsyscall_openbsd_mips64.s b/unix/zsyscall_openbsd_mips64.s index 05d4bffd79..b4e7bceabf 100644 --- a/unix/zsyscall_openbsd_mips64.s +++ b/unix/zsyscall_openbsd_mips64.s @@ -158,6 +158,16 @@ TEXT libc_getcwd_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_getcwd_trampoline_addr(SB), RODATA, $8 DATA ·libc_getcwd_trampoline_addr(SB)/8, $libc_getcwd_trampoline<>(SB) +TEXT libc_getresuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresuid(SB) +GLOBL ·libc_getresuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresuid_trampoline_addr(SB)/8, $libc_getresuid_trampoline<>(SB) + +TEXT libc_getresgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresgid(SB) +GLOBL ·libc_getresgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresgid_trampoline_addr(SB)/8, $libc_getresgid_trampoline<>(SB) + TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_ioctl(SB) GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 diff --git a/unix/zsyscall_openbsd_ppc64.go b/unix/zsyscall_openbsd_ppc64.go index 739be6217a..fb99594c93 100644 --- a/unix/zsyscall_openbsd_ppc64.go +++ b/unix/zsyscall_openbsd_ppc64.go @@ -519,6 +519,28 @@ var libc_getcwd_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) { + syscall_rawSyscall(libc_getresuid_trampoline_addr, uintptr(unsafe.Pointer(ruid)), uintptr(unsafe.Pointer(euid)), uintptr(unsafe.Pointer(suid))) + return +} + +var libc_getresuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresuid getresuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { + syscall_rawSyscall(libc_getresgid_trampoline_addr, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) + return +} + +var libc_getresgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresgid getresgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { diff --git a/unix/zsyscall_openbsd_ppc64.s b/unix/zsyscall_openbsd_ppc64.s index 74a25f8d64..ca3f766009 100644 --- a/unix/zsyscall_openbsd_ppc64.s +++ b/unix/zsyscall_openbsd_ppc64.s @@ -189,6 +189,18 @@ TEXT libc_getcwd_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_getcwd_trampoline_addr(SB), RODATA, $8 DATA ·libc_getcwd_trampoline_addr(SB)/8, $libc_getcwd_trampoline<>(SB) +TEXT libc_getresuid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getresuid(SB) + RET +GLOBL ·libc_getresuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresuid_trampoline_addr(SB)/8, $libc_getresuid_trampoline<>(SB) + +TEXT libc_getresgid_trampoline<>(SB),NOSPLIT,$0-0 + CALL libc_getresgid(SB) + RET +GLOBL ·libc_getresgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresgid_trampoline_addr(SB)/8, $libc_getresgid_trampoline<>(SB) + TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 CALL libc_ioctl(SB) RET diff --git a/unix/zsyscall_openbsd_riscv64.go b/unix/zsyscall_openbsd_riscv64.go index 7d95a19780..32cbbbc52b 100644 --- a/unix/zsyscall_openbsd_riscv64.go +++ b/unix/zsyscall_openbsd_riscv64.go @@ -519,6 +519,28 @@ var libc_getcwd_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func getresuid(ruid *_C_int, euid *_C_int, suid *_C_int) { + syscall_rawSyscall(libc_getresuid_trampoline_addr, uintptr(unsafe.Pointer(ruid)), uintptr(unsafe.Pointer(euid)), uintptr(unsafe.Pointer(suid))) + return +} + +var libc_getresuid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresuid getresuid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) { + syscall_rawSyscall(libc_getresgid_trampoline_addr, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid))) + return +} + +var libc_getresgid_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_getresgid getresgid "libc.so" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func ioctl(fd int, req uint, arg uintptr) (err error) { _, _, e1 := syscall_syscall(libc_ioctl_trampoline_addr, uintptr(fd), uintptr(req), uintptr(arg)) if e1 != 0 { diff --git a/unix/zsyscall_openbsd_riscv64.s b/unix/zsyscall_openbsd_riscv64.s index 990be24574..477a7d5b21 100644 --- a/unix/zsyscall_openbsd_riscv64.s +++ b/unix/zsyscall_openbsd_riscv64.s @@ -158,6 +158,16 @@ TEXT libc_getcwd_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_getcwd_trampoline_addr(SB), RODATA, $8 DATA ·libc_getcwd_trampoline_addr(SB)/8, $libc_getcwd_trampoline<>(SB) +TEXT libc_getresuid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresuid(SB) +GLOBL ·libc_getresuid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresuid_trampoline_addr(SB)/8, $libc_getresuid_trampoline<>(SB) + +TEXT libc_getresgid_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_getresgid(SB) +GLOBL ·libc_getresgid_trampoline_addr(SB), RODATA, $8 +DATA ·libc_getresgid_trampoline_addr(SB)/8, $libc_getresgid_trampoline<>(SB) + TEXT libc_ioctl_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_ioctl(SB) GLOBL ·libc_ioctl_trampoline_addr(SB), RODATA, $8 From 304f187cdba97b70a86421a915114c328653f0de Mon Sep 17 00:00:00 2001 From: Josh Rickmar Date: Tue, 6 Jun 2023 13:44:54 +0000 Subject: [PATCH 09/18] unix: replace use of strcpy in mkerrors.sh On OpenBSD-current, clang emits a warning message to standard output for the use of strcpy, e.g.: _errors.c(/tmp/_errors-673190.o:(main)): warning: strcpy() is almost always misused, please use strlcpy() This message makes it into the Go source being created, causing gofmt to error on the invalid syntax, and leaving the zerrors file empty. Using strlcpy would be preferred here, but strncpy is enough to silence this message, and is more portable. Change-Id: I16404d74c4406dadda87f211fc0ba062de0d11ac GitHub-Last-Rev: a43b6fbc1b3c2bd9ee473d0dac9a73381e196abf GitHub-Pull-Request: golang/sys#147 Reviewed-on: https://go-review.googlesource.com/c/sys/+/468399 TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Auto-Submit: Ian Lance Taylor Reviewed-by: David Chase --- unix/mkerrors.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/unix/mkerrors.sh b/unix/mkerrors.sh index be0423e685..3156462715 100755 --- a/unix/mkerrors.sh +++ b/unix/mkerrors.sh @@ -741,7 +741,8 @@ main(void) e = errors[i].num; if(i > 0 && errors[i-1].num == e) continue; - strcpy(buf, strerror(e)); + strncpy(buf, strerror(e), sizeof(buf) - 1); + buf[sizeof(buf) - 1] = '\0'; // lowercase first letter: Bad -> bad, but STREAM -> STREAM. if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z) buf[0] += a - A; @@ -760,7 +761,8 @@ main(void) e = signals[i].num; if(i > 0 && signals[i-1].num == e) continue; - strcpy(buf, strsignal(e)); + strncpy(buf, strsignal(e), sizeof(buf) - 1); + buf[sizeof(buf) - 1] = '\0'; // lowercase first letter: Bad -> bad, but STREAM -> STREAM. if(A <= buf[0] && buf[0] <= Z && a <= buf[1] && buf[1] <= z) buf[0] += a - A; From 5059a07aa46a89cb45ca6eabd13f2173baa73bb3 Mon Sep 17 00:00:00 2001 From: Guoqi Chen Date: Wed, 7 Jun 2023 07:25:11 +0800 Subject: [PATCH 10/18] unix: implement Ptrace{Set,Get}Regs using PTRACE_{GET,SET}REGSET for Linux The same change was already done in CL 501756. Fixes #60679. Change-Id: I5d1f4ad89cabb0ac120b3d72876944fb3283ec6f Reviewed-on: https://go-review.googlesource.com/c/sys/+/501795 Auto-Submit: Ian Lance Taylor TryBot-Result: Gopher Robot Run-TryBot: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: David Chase Reviewed-by: Ian Lance Taylor --- unix/syscall_linux.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go index aa0c55151a..ec24faea59 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -12,6 +12,7 @@ package unix import ( + "debug/elf" "encoding/binary" "strconv" "syscall" @@ -1700,11 +1701,17 @@ func PtracePokeUser(pid int, addr uintptr, data []byte) (count int, err error) { } func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { - return ptracePtr(PTRACE_GETREGS, pid, 0, unsafe.Pointer(regsout)) + var iov Iovec + iov.Base = (*byte)(unsafe.Pointer(regsout)) + iov.SetLen(int(unsafe.Sizeof(*regsout))) + return ptracePtr(PTRACE_GETREGSET, pid, uintptr(elf.NT_PRSTATUS), unsafe.Pointer(&iov)) } func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { - return ptracePtr(PTRACE_SETREGS, pid, 0, unsafe.Pointer(regs)) + var iov Iovec + iov.Base = (*byte)(unsafe.Pointer(regs)) + iov.SetLen(int(unsafe.Sizeof(*regs))) + return ptracePtr(PTRACE_SETREGSET, pid, uintptr(elf.NT_PRSTATUS), unsafe.Pointer(&iov)) } func PtraceSetOptions(pid int, options int) (err error) { From 55b11dcdae8194618ad245a452849aa95e461114 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 11 Jun 2023 08:50:10 -0700 Subject: [PATCH 11/18] unix: remove recently introduced debug/elf dependency CL 501795 added a dependency on debug/elf (and thus compress/gzip, debug/dwarf, hash/adler32) Add a copy of the const instead. Change-Id: I2c86094ef7de61b8dd0bdd727f6e547ac7f58527 Reviewed-on: https://go-review.googlesource.com/c/sys/+/502356 Reviewed-by: Tobias Klauser Reviewed-by: David Chase Run-TryBot: Brad Fitzpatrick Reviewed-by: Ian Lance Taylor Auto-Submit: Brad Fitzpatrick TryBot-Result: Gopher Robot --- unix/syscall_linux.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go index ec24faea59..6de486befe 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -12,7 +12,6 @@ package unix import ( - "debug/elf" "encoding/binary" "strconv" "syscall" @@ -1700,18 +1699,23 @@ func PtracePokeUser(pid int, addr uintptr, data []byte) (count int, err error) { return ptracePoke(PTRACE_POKEUSR, PTRACE_PEEKUSR, pid, addr, data) } +// elfNT_PRSTATUS is a copy of the debug/elf.NT_PRSTATUS constant so +// x/sys/unix doesn't need to depend on debug/elf and thus +// compress/zlib, debug/dwarf, and other packages. +const elfNT_PRSTATUS = 1 + func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { var iov Iovec iov.Base = (*byte)(unsafe.Pointer(regsout)) iov.SetLen(int(unsafe.Sizeof(*regsout))) - return ptracePtr(PTRACE_GETREGSET, pid, uintptr(elf.NT_PRSTATUS), unsafe.Pointer(&iov)) + return ptracePtr(PTRACE_GETREGSET, pid, uintptr(elfNT_PRSTATUS), unsafe.Pointer(&iov)) } func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { var iov Iovec iov.Base = (*byte)(unsafe.Pointer(regs)) iov.SetLen(int(unsafe.Sizeof(*regs))) - return ptracePtr(PTRACE_SETREGSET, pid, uintptr(elf.NT_PRSTATUS), unsafe.Pointer(&iov)) + return ptracePtr(PTRACE_SETREGSET, pid, uintptr(elfNT_PRSTATUS), unsafe.Pointer(&iov)) } func PtraceSetOptions(pid int, options int) (err error) { From df9fef2097f5d2cc202cdebbb32ca0d31fa06ec1 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 14 Jun 2023 14:05:14 +0200 Subject: [PATCH 12/18] unix/linux: update to Linux kernel 6.3 and Go 1.20.5 Change-Id: I347341ae0e45e73477e9a310a3749d37bafa8da7 Reviewed-on: https://go-review.googlesource.com/c/sys/+/503255 Run-TryBot: Tobias Klauser Reviewed-by: Ian Lance Taylor Auto-Submit: Tobias Klauser Reviewed-by: Bryan Mills TryBot-Result: Gopher Robot --- unix/linux/Dockerfile | 8 ++++---- unix/zerrors_linux.go | 11 +++++++++++ unix/zerrors_linux_arm64.go | 2 ++ unix/ztypes_linux.go | 14 +++++++------- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/unix/linux/Dockerfile b/unix/linux/Dockerfile index 6ae6e464cf..a779033169 100644 --- a/unix/linux/Dockerfile +++ b/unix/linux/Dockerfile @@ -15,15 +15,15 @@ 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 19 Feb 2023 -RUN git clone --branch v6.2 --depth 1 https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux +# Linux Kernel: Released 23 Apr 2023 +RUN git clone --branch v6.3 --depth 1 https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux # GNU C library: Released 1 Feb 2022 RUN git clone --branch release/2.37/master --depth 1 https://sourceware.org/git/glibc.git # Get Go -ENV GOLANG_VERSION 1.20.1 +ENV GOLANG_VERSION 1.20.5 ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz -ENV GOLANG_DOWNLOAD_SHA256 000a5b1fca4f75895f78befeb2eecf10bfff3c428597f3f1e69133b63b911b02 +ENV GOLANG_DOWNLOAD_SHA256 d7ec48cde0d3d2be2c69203bc3e0a44de8660b9c09a6e85c4732a3f7dc442612 RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ diff --git a/unix/zerrors_linux.go b/unix/zerrors_linux.go index de936b677b..bd4a0fcf12 100644 --- a/unix/zerrors_linux.go +++ b/unix/zerrors_linux.go @@ -493,6 +493,7 @@ const ( BPF_F_TEST_RUN_ON_CPU = 0x1 BPF_F_TEST_STATE_FREQ = 0x8 BPF_F_TEST_XDP_LIVE_FRAMES = 0x2 + BPF_F_XDP_DEV_BOUND_ONLY = 0x40 BPF_F_XDP_HAS_FRAGS = 0x20 BPF_H = 0x8 BPF_IMM = 0x0 @@ -1197,6 +1198,7 @@ const ( FAN_EVENT_METADATA_LEN = 0x18 FAN_EVENT_ON_CHILD = 0x8000000 FAN_FS_ERROR = 0x8000 + FAN_INFO = 0x20 FAN_MARK_ADD = 0x1 FAN_MARK_DONT_FOLLOW = 0x4 FAN_MARK_EVICTABLE = 0x200 @@ -1233,6 +1235,8 @@ const ( FAN_REPORT_PIDFD = 0x80 FAN_REPORT_TARGET_FID = 0x1000 FAN_REPORT_TID = 0x100 + FAN_RESPONSE_INFO_AUDIT_RULE = 0x1 + FAN_RESPONSE_INFO_NONE = 0x0 FAN_UNLIMITED_MARKS = 0x20 FAN_UNLIMITED_QUEUE = 0x10 FD_CLOEXEC = 0x1 @@ -1860,6 +1864,7 @@ const ( MEMWRITEOOB64 = 0xc0184d15 MFD_ALLOW_SEALING = 0x2 MFD_CLOEXEC = 0x1 + MFD_EXEC = 0x10 MFD_HUGETLB = 0x4 MFD_HUGE_16GB = 0x88000000 MFD_HUGE_16MB = 0x60000000 @@ -1875,6 +1880,7 @@ const ( MFD_HUGE_8MB = 0x5c000000 MFD_HUGE_MASK = 0x3f MFD_HUGE_SHIFT = 0x1a + MFD_NOEXEC_SEAL = 0x8 MINIX2_SUPER_MAGIC = 0x2468 MINIX2_SUPER_MAGIC2 = 0x2478 MINIX3_SUPER_MAGIC = 0x4d5a @@ -2221,6 +2227,7 @@ const ( PERF_ATTR_SIZE_VER5 = 0x70 PERF_ATTR_SIZE_VER6 = 0x78 PERF_ATTR_SIZE_VER7 = 0x80 + PERF_ATTR_SIZE_VER8 = 0x88 PERF_AUX_FLAG_COLLISION = 0x8 PERF_AUX_FLAG_CORESIGHT_FORMAT_CORESIGHT = 0x0 PERF_AUX_FLAG_CORESIGHT_FORMAT_RAW = 0x100 @@ -2369,6 +2376,7 @@ const ( PR_GET_FP_MODE = 0x2e PR_GET_IO_FLUSHER = 0x3a PR_GET_KEEPCAPS = 0x7 + PR_GET_MDWE = 0x42 PR_GET_NAME = 0x10 PR_GET_NO_NEW_PRIVS = 0x27 PR_GET_PDEATHSIG = 0x2 @@ -2389,6 +2397,7 @@ const ( PR_MCE_KILL_GET = 0x22 PR_MCE_KILL_LATE = 0x0 PR_MCE_KILL_SET = 0x1 + PR_MDWE_REFUSE_EXEC_GAIN = 0x1 PR_MPX_DISABLE_MANAGEMENT = 0x2c PR_MPX_ENABLE_MANAGEMENT = 0x2b PR_MTE_TAG_MASK = 0x7fff8 @@ -2423,6 +2432,7 @@ const ( PR_SET_FP_MODE = 0x2d PR_SET_IO_FLUSHER = 0x39 PR_SET_KEEPCAPS = 0x8 + PR_SET_MDWE = 0x41 PR_SET_MM = 0x23 PR_SET_MM_ARG_END = 0x9 PR_SET_MM_ARG_START = 0x8 @@ -3238,6 +3248,7 @@ const ( TP_STATUS_COPY = 0x2 TP_STATUS_CSUMNOTREADY = 0x8 TP_STATUS_CSUM_VALID = 0x80 + TP_STATUS_GSO_TCP = 0x100 TP_STATUS_KERNEL = 0x0 TP_STATUS_LOSING = 0x4 TP_STATUS_SENDING = 0x2 diff --git a/unix/zerrors_linux_arm64.go b/unix/zerrors_linux_arm64.go index 9d5352c3e4..12a9a1389e 100644 --- a/unix/zerrors_linux_arm64.go +++ b/unix/zerrors_linux_arm64.go @@ -443,6 +443,7 @@ const ( TIOCSWINSZ = 0x5414 TIOCVHANGUP = 0x5437 TOSTOP = 0x100 + TPIDR2_MAGIC = 0x54504902 TUNATTACHFILTER = 0x401054d5 TUNDETACHFILTER = 0x401054d6 TUNGETDEVNETNS = 0x54e3 @@ -515,6 +516,7 @@ const ( XCASE = 0x4 XTABS = 0x1800 ZA_MAGIC = 0x54366345 + ZT_MAGIC = 0x5a544e01 _HIDIOCGRAWNAME = 0x80804804 _HIDIOCGRAWPHYS = 0x80404805 _HIDIOCGRAWUNIQ = 0x80404808 diff --git a/unix/ztypes_linux.go b/unix/ztypes_linux.go index 00c3b8c20f..56cd76a844 100644 --- a/unix/ztypes_linux.go +++ b/unix/ztypes_linux.go @@ -1968,7 +1968,7 @@ const ( NFT_MSG_GETFLOWTABLE = 0x17 NFT_MSG_DELFLOWTABLE = 0x18 NFT_MSG_GETRULE_RESET = 0x19 - NFT_MSG_MAX = 0x1a + NFT_MSG_MAX = 0x21 NFTA_LIST_UNSPEC = 0x0 NFTA_LIST_ELEM = 0x1 NFTA_HOOK_UNSPEC = 0x0 @@ -3651,7 +3651,7 @@ const ( ETHTOOL_MSG_PSE_GET = 0x24 ETHTOOL_MSG_PSE_SET = 0x25 ETHTOOL_MSG_RSS_GET = 0x26 - ETHTOOL_MSG_USER_MAX = 0x26 + ETHTOOL_MSG_USER_MAX = 0x2b ETHTOOL_MSG_KERNEL_NONE = 0x0 ETHTOOL_MSG_STRSET_GET_REPLY = 0x1 ETHTOOL_MSG_LINKINFO_GET_REPLY = 0x2 @@ -3691,7 +3691,7 @@ const ( ETHTOOL_MSG_MODULE_NTF = 0x24 ETHTOOL_MSG_PSE_GET_REPLY = 0x25 ETHTOOL_MSG_RSS_GET_REPLY = 0x26 - ETHTOOL_MSG_KERNEL_MAX = 0x26 + ETHTOOL_MSG_KERNEL_MAX = 0x2b ETHTOOL_A_HEADER_UNSPEC = 0x0 ETHTOOL_A_HEADER_DEV_INDEX = 0x1 ETHTOOL_A_HEADER_DEV_NAME = 0x2 @@ -3795,7 +3795,7 @@ const ( ETHTOOL_A_RINGS_TCP_DATA_SPLIT = 0xb ETHTOOL_A_RINGS_CQE_SIZE = 0xc ETHTOOL_A_RINGS_TX_PUSH = 0xd - ETHTOOL_A_RINGS_MAX = 0xd + ETHTOOL_A_RINGS_MAX = 0xe ETHTOOL_A_CHANNELS_UNSPEC = 0x0 ETHTOOL_A_CHANNELS_HEADER = 0x1 ETHTOOL_A_CHANNELS_RX_MAX = 0x2 @@ -3833,14 +3833,14 @@ 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 = 0x19 + ETHTOOL_A_COALESCE_MAX = 0x1c ETHTOOL_A_PAUSE_UNSPEC = 0x0 ETHTOOL_A_PAUSE_HEADER = 0x1 ETHTOOL_A_PAUSE_AUTONEG = 0x2 ETHTOOL_A_PAUSE_RX = 0x3 ETHTOOL_A_PAUSE_TX = 0x4 ETHTOOL_A_PAUSE_STATS = 0x5 - ETHTOOL_A_PAUSE_MAX = 0x5 + ETHTOOL_A_PAUSE_MAX = 0x6 ETHTOOL_A_PAUSE_STAT_UNSPEC = 0x0 ETHTOOL_A_PAUSE_STAT_PAD = 0x1 ETHTOOL_A_PAUSE_STAT_TX_FRAMES = 0x2 @@ -4490,7 +4490,7 @@ const ( NL80211_ATTR_MAC_HINT = 0xc8 NL80211_ATTR_MAC_MASK = 0xd7 NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca - NL80211_ATTR_MAX = 0x141 + NL80211_ATTR_MAX = 0x142 NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4 NL80211_ATTR_MAX_CSA_COUNTERS = 0xce NL80211_ATTR_MAX_MATCH_SETS = 0x85 From ca096e46e860c29133d442ddcdef9c6999385446 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 15 Jun 2023 11:26:01 +0200 Subject: [PATCH 13/18] unix: add missing IFLA_* consts on linux Change-Id: Ib221d98f8d7e5aac7ff2db207cdd92145fe1dc60 Reviewed-on: https://go-review.googlesource.com/c/sys/+/503715 Run-TryBot: Tobias Klauser Reviewed-by: Ian Lance Taylor Auto-Submit: Tobias Klauser TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills --- unix/linux/types.go | 4 ++++ unix/ztypes_linux.go | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/unix/linux/types.go b/unix/linux/types.go index fff4ed3001..c19661ffb6 100644 --- a/unix/linux/types.go +++ b/unix/linux/types.go @@ -1517,6 +1517,10 @@ const ( IFLA_GRO_MAX_SIZE = C.IFLA_GRO_MAX_SIZE IFLA_TSO_MAX_SIZE = C.IFLA_TSO_MAX_SIZE IFLA_TSO_MAX_SEGS = C.IFLA_TSO_MAX_SEGS + IFLA_ALLMULTI = C.IFLA_ALLMULTI + IFLA_DEVLINK_PORT = C.IFLA_DEVLINK_PORT + IFLA_GSO_IPV4_MAX_SIZE = C.IFLA_GSO_IPV4_MAX_SIZE + IFLA_GRO_IPV4_MAX_SIZE = C.IFLA_GRO_IPV4_MAX_SIZE IFLA_PROTO_DOWN_REASON_UNSPEC = C.IFLA_PROTO_DOWN_REASON_UNSPEC IFLA_PROTO_DOWN_REASON_MASK = C.IFLA_PROTO_DOWN_REASON_MASK IFLA_PROTO_DOWN_REASON_VALUE = C.IFLA_PROTO_DOWN_REASON_VALUE diff --git a/unix/ztypes_linux.go b/unix/ztypes_linux.go index 56cd76a844..daf91f36d0 100644 --- a/unix/ztypes_linux.go +++ b/unix/ztypes_linux.go @@ -1538,6 +1538,10 @@ const ( IFLA_GRO_MAX_SIZE = 0x3a IFLA_TSO_MAX_SIZE = 0x3b IFLA_TSO_MAX_SEGS = 0x3c + IFLA_ALLMULTI = 0x3d + IFLA_DEVLINK_PORT = 0x3e + IFLA_GSO_IPV4_MAX_SIZE = 0x3f + IFLA_GRO_IPV4_MAX_SIZE = 0x40 IFLA_PROTO_DOWN_REASON_UNSPEC = 0x0 IFLA_PROTO_DOWN_REASON_MASK = 0x1 IFLA_PROTO_DOWN_REASON_VALUE = 0x2 From e0c3b6e6ae3bf6387b753f5062211beed2e71ded Mon Sep 17 00:00:00 2001 From: Anton Kuklin Date: Fri, 16 Jun 2023 19:17:12 +0000 Subject: [PATCH 14/18] unix: add Mremap for linux For golang/go#60409 Change-Id: I75a9732ee996f0aeb91599d80803f96ada468c27 GitHub-Last-Rev: c348b6194d9fbe92f4f912c66709b0af75810e99 GitHub-Pull-Request: golang/sys#164 Reviewed-on: https://go-review.googlesource.com/c/sys/+/502715 Auto-Submit: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor --- unix/mkerrors.sh | 2 +- unix/mremap.go | 40 +++++++++++++++++++++++++++++++++++ unix/mremap_test.go | 47 ++++++++++++++++++++++++++++++++++++++++++ unix/syscall_linux.go | 17 ++++++++++----- unix/zerrors_linux.go | 3 +++ unix/zsyscall_linux.go | 11 ++++++++++ 6 files changed, 114 insertions(+), 6 deletions(-) create mode 100644 unix/mremap.go create mode 100644 unix/mremap_test.go diff --git a/unix/mkerrors.sh b/unix/mkerrors.sh index 3156462715..0c4d14929a 100755 --- a/unix/mkerrors.sh +++ b/unix/mkerrors.sh @@ -519,7 +519,7 @@ ccflags="$@" $2 ~ /^LOCK_(SH|EX|NB|UN)$/ || $2 ~ /^LO_(KEY|NAME)_SIZE$/ || $2 ~ /^LOOP_(CLR|CTL|GET|SET)_/ || - $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT|UDP)_/ || + $2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|MCAST|EVFILT|NOTE|SHUT|PROT|MAP|MREMAP|MFD|T?PACKET|MSG|SCM|MCL|DT|MADV|PR|LOCAL|TCPOPT|UDP)_/ || $2 ~ /^NFC_(GENL|PROTO|COMM|RF|SE|DIRECTION|LLCP|SOCKPROTO)_/ || $2 ~ /^NFC_.*_(MAX)?SIZE$/ || $2 ~ /^RAW_PAYLOAD_/ || diff --git a/unix/mremap.go b/unix/mremap.go new file mode 100644 index 0000000000..86213c05d6 --- /dev/null +++ b/unix/mremap.go @@ -0,0 +1,40 @@ +// Copyright 2023 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 +// +build linux + +package unix + +import "unsafe" + +type mremapMmapper struct { + mmapper + mremap func(oldaddr uintptr, oldlength uintptr, newlength uintptr, flags int, newaddr uintptr) (xaddr uintptr, err error) +} + +func (m *mremapMmapper) Mremap(oldData []byte, newLength int, flags int) (data []byte, err error) { + if newLength <= 0 || len(oldData) == 0 || len(oldData) != cap(oldData) || flags&MREMAP_FIXED != 0 { + return nil, EINVAL + } + + pOld := &oldData[cap(oldData)-1] + m.Lock() + defer m.Unlock() + bOld := m.active[pOld] + if bOld == nil || &bOld[0] != &oldData[0] { + return nil, EINVAL + } + newAddr, errno := m.mremap(uintptr(unsafe.Pointer(&bOld[0])), uintptr(len(bOld)), uintptr(newLength), flags, 0) + if errno != nil { + return nil, errno + } + bNew := unsafe.Slice((*byte)(unsafe.Pointer(newAddr)), newLength) + pNew := &bNew[cap(bNew)-1] + if flags&MREMAP_DONTUNMAP == 0 { + delete(m.active, pOld) + } + m.active[pNew] = bNew + return bNew, nil +} diff --git a/unix/mremap_test.go b/unix/mremap_test.go new file mode 100644 index 0000000000..7b1655b817 --- /dev/null +++ b/unix/mremap_test.go @@ -0,0 +1,47 @@ +// Copyright 2023 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 +// +build linux + +package unix_test + +import ( + "testing" + + "golang.org/x/sys/unix" +) + +func TestMremap(t *testing.T) { + b, err := unix.Mmap(-1, 0, unix.Getpagesize(), unix.PROT_NONE, unix.MAP_ANON|unix.MAP_PRIVATE) + if err != nil { + t.Fatalf("Mmap: %v", err) + } + if err := unix.Mprotect(b, unix.PROT_READ|unix.PROT_WRITE); err != nil { + t.Fatalf("Mprotect: %v", err) + } + + b[0] = 42 + + bNew, err := unix.Mremap(b, unix.Getpagesize()*2, unix.MREMAP_MAYMOVE) + if err != nil { + t.Fatalf("Mremap2: %v", err) + } + bNew[unix.Getpagesize()+1] = 84 // checks + + if bNew[0] != 42 { + t.Fatal("first element value was changed") + } + if len(bNew) != unix.Getpagesize()*2 { + t.Fatal("new memory len not equal to specified len") + } + if cap(bNew) != unix.Getpagesize()*2 { + t.Fatal("new memory cap not equal to specified len") + } + + _, err = unix.Mremap(b, unix.Getpagesize(), unix.MREMAP_FIXED) + if err != unix.EINVAL { + t.Fatalf("unix.MREMAP_FIXED should be forbidden") + } +} diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go index 6de486befe..39de5f1430 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -2124,11 +2124,15 @@ func writevRacedetect(iovecs []Iovec, n int) { // mmap varies by architecture; see syscall_linux_*.go. //sys munmap(addr uintptr, length uintptr) (err error) +//sys mremap(oldaddr uintptr, oldlength uintptr, newlength uintptr, flags int, newaddr uintptr) (xaddr uintptr, err error) -var mapper = &mmapper{ - active: make(map[*byte][]byte), - mmap: mmap, - munmap: munmap, +var mapper = &mremapMmapper{ + mmapper: mmapper{ + active: make(map[*byte][]byte), + mmap: mmap, + munmap: munmap, + }, + mremap: mremap, } func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { @@ -2139,6 +2143,10 @@ func Munmap(b []byte) (err error) { return mapper.Munmap(b) } +func Mremap(oldData []byte, newLength int, flags int) (data []byte, err error) { + return mapper.Mremap(oldData, newLength, flags) +} + //sys Madvise(b []byte, advice int) (err error) //sys Mprotect(b []byte, prot int) (err error) //sys Mlock(b []byte) (err error) @@ -2487,7 +2495,6 @@ func Getresgid() (rgid, egid, sgid int) { // MqTimedreceive // MqTimedsend // MqUnlink -// Mremap // Msgctl // Msgget // Msgrcv diff --git a/unix/zerrors_linux.go b/unix/zerrors_linux.go index bd4a0fcf12..c097b48dad 100644 --- a/unix/zerrors_linux.go +++ b/unix/zerrors_linux.go @@ -1904,6 +1904,9 @@ const ( MOUNT_ATTR_SIZE_VER0 = 0x20 MOUNT_ATTR_STRICTATIME = 0x20 MOUNT_ATTR__ATIME = 0x70 + MREMAP_DONTUNMAP = 0x4 + MREMAP_FIXED = 0x2 + MREMAP_MAYMOVE = 0x1 MSDOS_SUPER_MAGIC = 0x4d44 MSG_BATCH = 0x40000 MSG_CMSG_CLOEXEC = 0x40000000 diff --git a/unix/zsyscall_linux.go b/unix/zsyscall_linux.go index 722c29a008..7ceec233fb 100644 --- a/unix/zsyscall_linux.go +++ b/unix/zsyscall_linux.go @@ -1868,6 +1868,17 @@ func munmap(addr uintptr, length uintptr) (err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func mremap(oldaddr uintptr, oldlength uintptr, newlength uintptr, flags int, newaddr uintptr) (xaddr uintptr, err error) { + r0, _, e1 := Syscall6(SYS_MREMAP, uintptr(oldaddr), uintptr(oldlength), uintptr(newlength), uintptr(flags), uintptr(newaddr), 0) + xaddr = uintptr(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Madvise(b []byte, advice int) (err error) { var _p0 unsafe.Pointer if len(b) > 0 { From 2b751ddc668a14c2c680cdbf6281c0ec6add8161 Mon Sep 17 00:00:00 2001 From: Craig Davison Date: Wed, 3 May 2023 22:01:01 +0000 Subject: [PATCH 15/18] windows/svc/mgr: add Service.RecoveryActionsOnNonCrashFailures Fixes golang/go#59016 Change-Id: I5e16f61ea2fc384052565342c6517687562260a1 GitHub-Last-Rev: 3626b01fcf35da32b67d11e8439e757de177bbaa GitHub-Pull-Request: golang/sys#157 Reviewed-on: https://go-review.googlesource.com/c/sys/+/484896 Run-TryBot: Bryan Mills Reviewed-by: Alex Brainman Reviewed-by: Bryan Mills Reviewed-by: Dmitri Shuralyov TryBot-Result: Gopher Robot --- windows/service.go | 4 +++ windows/svc/mgr/mgr_test.go | 54 +++++++++++++++++++++++++++++++++++++ windows/svc/mgr/recovery.go | 27 +++++++++++++++++++ 3 files changed, 85 insertions(+) diff --git a/windows/service.go b/windows/service.go index c964b6848d..c44a1b9636 100644 --- a/windows/service.go +++ b/windows/service.go @@ -218,6 +218,10 @@ type SERVICE_FAILURE_ACTIONS struct { Actions *SC_ACTION } +type SERVICE_FAILURE_ACTIONS_FLAG struct { + FailureActionsOnNonCrashFailures int32 +} + type SC_ACTION struct { Type uint32 Delay uint32 diff --git a/windows/svc/mgr/mgr_test.go b/windows/svc/mgr/mgr_test.go index 10d2310790..285dc10ddd 100644 --- a/windows/svc/mgr/mgr_test.go +++ b/windows/svc/mgr/mgr_test.go @@ -209,6 +209,57 @@ func testRecoveryCommand(t *testing.T, s *mgr.Service, should string) { } } +func testRecoveryActionsOnNonCrashFailures(t *testing.T, s *mgr.Service, should bool) { + err := s.SetRecoveryActionsOnNonCrashFailures(should) + if err != nil { + t.Fatalf("SetRecoveryActionsOnNonCrashFailures failed: %v", err) + } + is, err := s.RecoveryActionsOnNonCrashFailures() + if err != nil { + t.Fatalf("RecoveryActionsOnNonCrashFailures failed: %v", err) + } + if should != is { + t.Errorf("RecoveryActionsOnNonCrashFailures mismatch: flag is %v, but should have %v", is, should) + } +} + +func testMultipleRecoverySettings(t *testing.T, s *mgr.Service, rebootMsgShould, recoveryCmdShould string, actionsFlagShould bool) { + err := s.SetRebootMessage(rebootMsgShould) + if err != nil { + t.Fatalf("SetRebootMessage failed: %v", err) + } + err = s.SetRecoveryActionsOnNonCrashFailures(actionsFlagShould) + if err != nil { + t.Fatalf("SetRecoveryActionsOnNonCrashFailures failed: %v", err) + } + err = s.SetRecoveryCommand(recoveryCmdShould) + if err != nil { + t.Fatalf("SetRecoveryCommand failed: %v", err) + } + + rebootMsgIs, err := s.RebootMessage() + if err != nil { + t.Fatalf("RebootMessage failed: %v", err) + } + if rebootMsgShould != rebootMsgIs { + t.Errorf("reboot message mismatch: message is %q, but should have %q", rebootMsgIs, rebootMsgShould) + } + recoveryCommandIs, err := s.RecoveryCommand() + if err != nil { + t.Fatalf("RecoveryCommand failed: %v", err) + } + if recoveryCmdShould != recoveryCommandIs { + t.Errorf("recovery command mismatch: command is %q, but should have %q", recoveryCommandIs, recoveryCmdShould) + } + actionsFlagIs, err := s.RecoveryActionsOnNonCrashFailures() + if err != nil { + t.Fatalf("RecoveryActionsOnNonCrashFailures failed: %v", err) + } + if actionsFlagShould != actionsFlagIs { + t.Errorf("RecoveryActionsOnNonCrashFailures mismatch: flag is %v, but should have %v", actionsFlagIs, actionsFlagShould) + } +} + func testControl(t *testing.T, s *mgr.Service, c svc.Cmd, expectedErr error, expectedStatus svc.Status) { status, err := s.Control(c) if err != expectedErr { @@ -305,6 +356,9 @@ func TestMyService(t *testing.T) { testRebootMessage(t, s, "") // delete reboot message testRecoveryCommand(t, s, fmt.Sprintf("sc query %s", name)) testRecoveryCommand(t, s, "") // delete recovery command + testRecoveryActionsOnNonCrashFailures(t, s, true) + testRecoveryActionsOnNonCrashFailures(t, s, false) + testMultipleRecoverySettings(t, s, fmt.Sprintf("%s failed", name), fmt.Sprintf("sc query %s", name), true) expectedStatus := svc.Status{ State: svc.Stopped, diff --git a/windows/svc/mgr/recovery.go b/windows/svc/mgr/recovery.go index 2e042dd695..321451990b 100644 --- a/windows/svc/mgr/recovery.go +++ b/windows/svc/mgr/recovery.go @@ -140,3 +140,30 @@ func (s *Service) RecoveryCommand() (string, error) { p := (*windows.SERVICE_FAILURE_ACTIONS)(unsafe.Pointer(&b[0])) return windows.UTF16PtrToString(p.Command), nil } + +// 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 +// nonzero exit code. +func (s *Service) SetRecoveryActionsOnNonCrashFailures(flag bool) error { + var setting windows.SERVICE_FAILURE_ACTIONS_FLAG + if flag { + setting.FailureActionsOnNonCrashFailures = 1 + } + return windows.ChangeServiceConfig2(s.Handle, windows.SERVICE_CONFIG_FAILURE_ACTIONS_FLAG, (*byte)(unsafe.Pointer(&setting))) +} + +// RecoveryActionsOnNonCrashFailures returns the current value of 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 nonzero exit code. +func (s *Service) RecoveryActionsOnNonCrashFailures() (bool, error) { + b, err := s.queryServiceConfig2(windows.SERVICE_CONFIG_FAILURE_ACTIONS_FLAG) + if err != nil { + return false, err + } + p := (*windows.SERVICE_FAILURE_ACTIONS_FLAG)(unsafe.Pointer(&b[0])) + return p.FailureActionsOnNonCrashFailures != 0, nil +} From d1abdad3a4e261d40157caf02c88c3ec80719ac2 Mon Sep 17 00:00:00 2001 From: Jordan Whited Date: Mon, 26 Jun 2023 22:34:47 +0000 Subject: [PATCH 16/18] unix/linux: update TUN flags and virtio_net_hdr constants TUN_F_USO{4,6} and VIRTIO_NET_HDR_GSO_UDP_L4 are new in Linux v6.2. Change-Id: I7e3dc34118d1c03afeb87fb8699d8167a6e49b7f GitHub-Last-Rev: c658b9bf0f669015f2b4413c0df43102b3875dc3 GitHub-Pull-Request: golang/sys#165 Reviewed-on: https://go-review.googlesource.com/c/sys/+/506455 Reviewed-by: Carlos Amedee Auto-Submit: Carlos Amedee TryBot-Result: Gopher Robot Reviewed-by: Tobias Klauser Run-TryBot: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- unix/linux/types.go | 13 ++++++++----- unix/ztypes_linux.go | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/unix/linux/types.go b/unix/linux/types.go index c19661ffb6..469ff6bcf7 100644 --- a/unix/linux/types.go +++ b/unix/linux/types.go @@ -5721,6 +5721,8 @@ const ( TUN_F_TSO6 = C.TUN_F_TSO6 TUN_F_TSO_ECN = C.TUN_F_TSO_ECN TUN_F_UFO = C.TUN_F_UFO + TUN_F_USO4 = C.TUN_F_USO4 + TUN_F_USO6 = C.TUN_F_USO6 ) // generated by: @@ -5734,9 +5736,10 @@ const ( // generated by: // perl -nlE '/^#define (VIRTIO_NET_HDR_GSO_\w+)/ && say "$1 = C.$1"' include/uapi/linux/virtio_net.h const ( - VIRTIO_NET_HDR_GSO_NONE = C.VIRTIO_NET_HDR_GSO_NONE - VIRTIO_NET_HDR_GSO_TCPV4 = C.VIRTIO_NET_HDR_GSO_TCPV4 - VIRTIO_NET_HDR_GSO_UDP = C.VIRTIO_NET_HDR_GSO_UDP - VIRTIO_NET_HDR_GSO_TCPV6 = C.VIRTIO_NET_HDR_GSO_TCPV6 - VIRTIO_NET_HDR_GSO_ECN = C.VIRTIO_NET_HDR_GSO_ECN + VIRTIO_NET_HDR_GSO_NONE = C.VIRTIO_NET_HDR_GSO_NONE + VIRTIO_NET_HDR_GSO_TCPV4 = C.VIRTIO_NET_HDR_GSO_TCPV4 + VIRTIO_NET_HDR_GSO_UDP = C.VIRTIO_NET_HDR_GSO_UDP + VIRTIO_NET_HDR_GSO_TCPV6 = C.VIRTIO_NET_HDR_GSO_TCPV6 + VIRTIO_NET_HDR_GSO_UDP_L4 = C.VIRTIO_NET_HDR_GSO_UDP_L4 + VIRTIO_NET_HDR_GSO_ECN = C.VIRTIO_NET_HDR_GSO_ECN ) diff --git a/unix/ztypes_linux.go b/unix/ztypes_linux.go index daf91f36d0..fce104b8fa 100644 --- a/unix/ztypes_linux.go +++ b/unix/ztypes_linux.go @@ -5845,6 +5845,8 @@ const ( TUN_F_TSO6 = 0x4 TUN_F_TSO_ECN = 0x8 TUN_F_UFO = 0x10 + TUN_F_USO4 = 0x20 + TUN_F_USO6 = 0x40 ) const ( @@ -5854,9 +5856,10 @@ const ( ) const ( - VIRTIO_NET_HDR_GSO_NONE = 0x0 - VIRTIO_NET_HDR_GSO_TCPV4 = 0x1 - VIRTIO_NET_HDR_GSO_UDP = 0x3 - VIRTIO_NET_HDR_GSO_TCPV6 = 0x4 - VIRTIO_NET_HDR_GSO_ECN = 0x80 + VIRTIO_NET_HDR_GSO_NONE = 0x0 + VIRTIO_NET_HDR_GSO_TCPV4 = 0x1 + VIRTIO_NET_HDR_GSO_UDP = 0x3 + VIRTIO_NET_HDR_GSO_TCPV6 = 0x4 + VIRTIO_NET_HDR_GSO_UDP_L4 = 0x5 + VIRTIO_NET_HDR_GSO_ECN = 0x80 ) From 0a92922092b21ff6097f5e152130b634b35a4674 Mon Sep 17 00:00:00 2001 From: Heschi Kreinick Date: Mon, 26 Jun 2023 12:46:44 -0400 Subject: [PATCH 17/18] windows: make TestSystemModuleVersions more tolerant One file can't be read on LUCI's Windows image: syscall_windows_test.go:892: CimFS.SYS: The specified resource type cannot be found in the image file. That doesn't seem like a good enough reason to fail the test. Skip the file if this error is encountered. Change-Id: Id9a65b3ff748bbf7ef7fac37d3741c16e001a4b0 Reviewed-on: https://go-review.googlesource.com/c/sys/+/505220 TryBot-Result: Gopher Robot Reviewed-by: Carlos Amedee Run-TryBot: Heschi Kreinick Auto-Submit: Heschi Kreinick Reviewed-by: Quim Muntal --- windows/syscall_windows_test.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/windows/syscall_windows_test.go b/windows/syscall_windows_test.go index 81050d3370..0129441531 100644 --- a/windows/syscall_windows_test.go +++ b/windows/syscall_windows_test.go @@ -888,22 +888,21 @@ func TestSystemModuleVersions(t *testing.T) { var zero windows.Handle infoSize, err := windows.GetFileVersionInfoSize(driverPath, &zero) if err != nil { - if err != windows.ERROR_FILE_NOT_FOUND { - t.Error(err) + if err != windows.ERROR_FILE_NOT_FOUND && err != windows.ERROR_RESOURCE_TYPE_NOT_FOUND { + t.Errorf("%v: %v", moduleName, err) } continue } versionInfo := make([]byte, infoSize) - err = windows.GetFileVersionInfo(driverPath, 0, infoSize, unsafe.Pointer(&versionInfo[0])) - if err != nil && err != windows.ERROR_FILE_NOT_FOUND { - t.Error(err) + if err = windows.GetFileVersionInfo(driverPath, 0, infoSize, unsafe.Pointer(&versionInfo[0])); err != nil { + t.Errorf("%v: %v", moduleName, err) continue } var fixedInfo *windows.VS_FIXEDFILEINFO fixedInfoLen := uint32(unsafe.Sizeof(*fixedInfo)) err = windows.VerQueryValue(unsafe.Pointer(&versionInfo[0]), `\`, (unsafe.Pointer)(&fixedInfo), &fixedInfoLen) if err != nil { - t.Error(err) + t.Errorf("%v: %v", moduleName, err) continue } t.Logf("%s: v%d.%d.%d.%d", moduleName, From a1a9c4b846b3a485ba94fede5b50579c7f432759 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 26 Jun 2023 15:37:18 +0200 Subject: [PATCH 18/18] unix/linux: update to Linux kernel 6.4 and Go 1.21rc2 Also fix the glibc 2.37 release date in a comment. Change-Id: Ibd972a2846f0085bacf67c847ce4726bf130d5ba Reviewed-on: https://go-review.googlesource.com/c/sys/+/506017 TryBot-Result: Gopher Robot Auto-Submit: Carlos Amedee Reviewed-by: Ian Lance Taylor Run-TryBot: Tobias Klauser Reviewed-by: Carlos Amedee --- unix/linux/Dockerfile | 10 +++++----- unix/zerrors_linux.go | 12 +++++++++--- unix/zsysnum_linux_s390x.go | 1 + unix/ztypes_linux.go | 8 ++++---- unix/ztypes_linux_386.go | 2 ++ unix/ztypes_linux_amd64.go | 2 ++ unix/ztypes_linux_arm.go | 2 ++ unix/ztypes_linux_arm64.go | 2 ++ unix/ztypes_linux_loong64.go | 2 ++ unix/ztypes_linux_mips.go | 2 ++ unix/ztypes_linux_mips64.go | 2 ++ unix/ztypes_linux_mips64le.go | 2 ++ unix/ztypes_linux_mipsle.go | 2 ++ unix/ztypes_linux_ppc.go | 2 ++ unix/ztypes_linux_ppc64.go | 2 ++ unix/ztypes_linux_ppc64le.go | 2 ++ unix/ztypes_linux_riscv64.go | 2 ++ unix/ztypes_linux_s390x.go | 2 ++ unix/ztypes_linux_sparc64.go | 2 ++ 19 files changed, 49 insertions(+), 12 deletions(-) diff --git a/unix/linux/Dockerfile b/unix/linux/Dockerfile index a779033169..18d3acd3aa 100644 --- a/unix/linux/Dockerfile +++ b/unix/linux/Dockerfile @@ -15,15 +15,15 @@ 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 23 Apr 2023 -RUN git clone --branch v6.3 --depth 1 https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux -# GNU C library: Released 1 Feb 2022 +# Linux Kernel: Released 25 June 2023 +RUN git clone --branch v6.4 --depth 1 https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux +# GNU C library: Released 1 Feb 2023 RUN git clone --branch release/2.37/master --depth 1 https://sourceware.org/git/glibc.git # Get Go -ENV GOLANG_VERSION 1.20.5 +ENV GOLANG_VERSION 1.21rc2 ENV GOLANG_DOWNLOAD_URL https://golang.org/dl/go$GOLANG_VERSION.linux-amd64.tar.gz -ENV GOLANG_DOWNLOAD_SHA256 d7ec48cde0d3d2be2c69203bc3e0a44de8660b9c09a6e85c4732a3f7dc442612 +ENV GOLANG_DOWNLOAD_SHA256 8fe90332727c606019e80a7368e23f5e65ad59520e45ee4010692f15572e45c6 RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ && echo "$GOLANG_DOWNLOAD_SHA256 golang.tar.gz" | sha256sum -c - \ diff --git a/unix/zerrors_linux.go b/unix/zerrors_linux.go index c097b48dad..3784f402e5 100644 --- a/unix/zerrors_linux.go +++ b/unix/zerrors_linux.go @@ -827,9 +827,9 @@ const ( DM_UUID_FLAG = 0x4000 DM_UUID_LEN = 0x81 DM_VERSION = 0xc138fd00 - DM_VERSION_EXTRA = "-ioctl (2022-07-28)" + DM_VERSION_EXTRA = "-ioctl (2023-03-01)" DM_VERSION_MAJOR = 0x4 - DM_VERSION_MINOR = 0x2f + DM_VERSION_MINOR = 0x30 DM_VERSION_PATCHLEVEL = 0x0 DT_BLK = 0x6 DT_CHR = 0x2 @@ -2213,6 +2213,7 @@ const ( PACKET_USER = 0x6 PACKET_VERSION = 0xa PACKET_VNET_HDR = 0xf + PACKET_VNET_HDR_SZ = 0x18 PARITY_CRC16_PR0 = 0x2 PARITY_CRC16_PR0_CCITT = 0x4 PARITY_CRC16_PR1 = 0x3 @@ -2371,6 +2372,7 @@ const ( PR_FP_EXC_UND = 0x40000 PR_FP_MODE_FR = 0x1 PR_FP_MODE_FRE = 0x2 + PR_GET_AUXV = 0x41555856 PR_GET_CHILD_SUBREAPER = 0x25 PR_GET_DUMPABLE = 0x3 PR_GET_ENDIAN = 0x13 @@ -2380,6 +2382,7 @@ const ( PR_GET_IO_FLUSHER = 0x3a PR_GET_KEEPCAPS = 0x7 PR_GET_MDWE = 0x42 + PR_GET_MEMORY_MERGE = 0x44 PR_GET_NAME = 0x10 PR_GET_NO_NEW_PRIVS = 0x27 PR_GET_PDEATHSIG = 0x2 @@ -2436,6 +2439,7 @@ const ( PR_SET_IO_FLUSHER = 0x39 PR_SET_KEEPCAPS = 0x8 PR_SET_MDWE = 0x41 + PR_SET_MEMORY_MERGE = 0x43 PR_SET_MM = 0x23 PR_SET_MM_ARG_END = 0x9 PR_SET_MM_ARG_START = 0x8 @@ -2519,6 +2523,7 @@ const ( PTRACE_GETSIGMASK = 0x420a PTRACE_GET_RSEQ_CONFIGURATION = 0x420f PTRACE_GET_SYSCALL_INFO = 0x420e + PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG = 0x4211 PTRACE_INTERRUPT = 0x4207 PTRACE_KILL = 0x8 PTRACE_LISTEN = 0x4208 @@ -2549,6 +2554,7 @@ const ( PTRACE_SETREGSET = 0x4205 PTRACE_SETSIGINFO = 0x4203 PTRACE_SETSIGMASK = 0x420b + PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG = 0x4210 PTRACE_SINGLESTEP = 0x9 PTRACE_SYSCALL = 0x18 PTRACE_SYSCALL_INFO_ENTRY = 0x1 @@ -3085,7 +3091,7 @@ const ( TASKSTATS_GENL_NAME = "TASKSTATS" TASKSTATS_GENL_VERSION = 0x1 TASKSTATS_TYPE_MAX = 0x6 - TASKSTATS_VERSION = 0xd + TASKSTATS_VERSION = 0xe TCIFLUSH = 0x0 TCIOFF = 0x2 TCIOFLUSH = 0x2 diff --git a/unix/zsysnum_linux_s390x.go b/unix/zsysnum_linux_s390x.go index 7ea465204b..e6ed7d637d 100644 --- a/unix/zsysnum_linux_s390x.go +++ b/unix/zsysnum_linux_s390x.go @@ -372,6 +372,7 @@ const ( SYS_LANDLOCK_CREATE_RULESET = 444 SYS_LANDLOCK_ADD_RULE = 445 SYS_LANDLOCK_RESTRICT_SELF = 446 + SYS_MEMFD_SECRET = 447 SYS_PROCESS_MRELEASE = 448 SYS_FUTEX_WAITV = 449 SYS_SET_MEMPOLICY_HOME_NODE = 450 diff --git a/unix/ztypes_linux.go b/unix/ztypes_linux.go index fce104b8fa..02e2462c8f 100644 --- a/unix/ztypes_linux.go +++ b/unix/ztypes_linux.go @@ -3799,7 +3799,7 @@ const ( ETHTOOL_A_RINGS_TCP_DATA_SPLIT = 0xb ETHTOOL_A_RINGS_CQE_SIZE = 0xc ETHTOOL_A_RINGS_TX_PUSH = 0xd - ETHTOOL_A_RINGS_MAX = 0xe + ETHTOOL_A_RINGS_MAX = 0x10 ETHTOOL_A_CHANNELS_UNSPEC = 0x0 ETHTOOL_A_CHANNELS_HEADER = 0x1 ETHTOOL_A_CHANNELS_RX_MAX = 0x2 @@ -4494,7 +4494,7 @@ const ( NL80211_ATTR_MAC_HINT = 0xc8 NL80211_ATTR_MAC_MASK = 0xd7 NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca - NL80211_ATTR_MAX = 0x142 + NL80211_ATTR_MAX = 0x145 NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4 NL80211_ATTR_MAX_CSA_COUNTERS = 0xce NL80211_ATTR_MAX_MATCH_SETS = 0x85 @@ -4723,7 +4723,7 @@ const ( NL80211_BAND_ATTR_HT_CAPA = 0x4 NL80211_BAND_ATTR_HT_MCS_SET = 0x3 NL80211_BAND_ATTR_IFTYPE_DATA = 0x9 - NL80211_BAND_ATTR_MAX = 0xb + NL80211_BAND_ATTR_MAX = 0xd NL80211_BAND_ATTR_RATES = 0x2 NL80211_BAND_ATTR_VHT_CAPA = 0x8 NL80211_BAND_ATTR_VHT_MCS_SET = 0x7 @@ -4864,7 +4864,7 @@ const ( NL80211_CMD_LEAVE_IBSS = 0x2c NL80211_CMD_LEAVE_MESH = 0x45 NL80211_CMD_LEAVE_OCB = 0x6d - NL80211_CMD_MAX = 0x98 + NL80211_CMD_MAX = 0x99 NL80211_CMD_MICHAEL_MIC_FAILURE = 0x29 NL80211_CMD_MODIFY_LINK_STA = 0x97 NL80211_CMD_NAN_MATCH = 0x78 diff --git a/unix/ztypes_linux_386.go b/unix/ztypes_linux_386.go index 4ecc1495cd..6d8acbcc57 100644 --- a/unix/ztypes_linux_386.go +++ b/unix/ztypes_linux_386.go @@ -337,6 +337,8 @@ type Taskstats struct { Ac_exe_inode uint64 Wpcopy_count uint64 Wpcopy_delay_total uint64 + Irq_count uint64 + Irq_delay_total uint64 } type cpuMask uint32 diff --git a/unix/ztypes_linux_amd64.go b/unix/ztypes_linux_amd64.go index 34fddff964..59293c6884 100644 --- a/unix/ztypes_linux_amd64.go +++ b/unix/ztypes_linux_amd64.go @@ -350,6 +350,8 @@ type Taskstats struct { Ac_exe_inode uint64 Wpcopy_count uint64 Wpcopy_delay_total uint64 + Irq_count uint64 + Irq_delay_total uint64 } type cpuMask uint64 diff --git a/unix/ztypes_linux_arm.go b/unix/ztypes_linux_arm.go index 3b14a6031f..40cfa38c29 100644 --- a/unix/ztypes_linux_arm.go +++ b/unix/ztypes_linux_arm.go @@ -328,6 +328,8 @@ type Taskstats struct { Ac_exe_inode uint64 Wpcopy_count uint64 Wpcopy_delay_total uint64 + Irq_count uint64 + Irq_delay_total uint64 } type cpuMask uint32 diff --git a/unix/ztypes_linux_arm64.go b/unix/ztypes_linux_arm64.go index 0517651ab3..055bc4216d 100644 --- a/unix/ztypes_linux_arm64.go +++ b/unix/ztypes_linux_arm64.go @@ -329,6 +329,8 @@ type Taskstats struct { Ac_exe_inode uint64 Wpcopy_count uint64 Wpcopy_delay_total uint64 + Irq_count uint64 + Irq_delay_total uint64 } type cpuMask uint64 diff --git a/unix/ztypes_linux_loong64.go b/unix/ztypes_linux_loong64.go index 3b0c518134..f28affbc60 100644 --- a/unix/ztypes_linux_loong64.go +++ b/unix/ztypes_linux_loong64.go @@ -330,6 +330,8 @@ type Taskstats struct { Ac_exe_inode uint64 Wpcopy_count uint64 Wpcopy_delay_total uint64 + Irq_count uint64 + Irq_delay_total uint64 } type cpuMask uint64 diff --git a/unix/ztypes_linux_mips.go b/unix/ztypes_linux_mips.go index fccdf4dd0f..9d71e7ccd8 100644 --- a/unix/ztypes_linux_mips.go +++ b/unix/ztypes_linux_mips.go @@ -333,6 +333,8 @@ type Taskstats struct { Ac_exe_inode uint64 Wpcopy_count uint64 Wpcopy_delay_total uint64 + Irq_count uint64 + Irq_delay_total uint64 } type cpuMask uint32 diff --git a/unix/ztypes_linux_mips64.go b/unix/ztypes_linux_mips64.go index 500de8fc07..fd5ccd332a 100644 --- a/unix/ztypes_linux_mips64.go +++ b/unix/ztypes_linux_mips64.go @@ -332,6 +332,8 @@ type Taskstats struct { Ac_exe_inode uint64 Wpcopy_count uint64 Wpcopy_delay_total uint64 + Irq_count uint64 + Irq_delay_total uint64 } type cpuMask uint64 diff --git a/unix/ztypes_linux_mips64le.go b/unix/ztypes_linux_mips64le.go index d0434cd2c6..7704de77a2 100644 --- a/unix/ztypes_linux_mips64le.go +++ b/unix/ztypes_linux_mips64le.go @@ -332,6 +332,8 @@ type Taskstats struct { Ac_exe_inode uint64 Wpcopy_count uint64 Wpcopy_delay_total uint64 + Irq_count uint64 + Irq_delay_total uint64 } type cpuMask uint64 diff --git a/unix/ztypes_linux_mipsle.go b/unix/ztypes_linux_mipsle.go index 84206ba534..df00b87571 100644 --- a/unix/ztypes_linux_mipsle.go +++ b/unix/ztypes_linux_mipsle.go @@ -333,6 +333,8 @@ type Taskstats struct { Ac_exe_inode uint64 Wpcopy_count uint64 Wpcopy_delay_total uint64 + Irq_count uint64 + Irq_delay_total uint64 } type cpuMask uint32 diff --git a/unix/ztypes_linux_ppc.go b/unix/ztypes_linux_ppc.go index ab078cf1f5..0942840db6 100644 --- a/unix/ztypes_linux_ppc.go +++ b/unix/ztypes_linux_ppc.go @@ -340,6 +340,8 @@ type Taskstats struct { Ac_exe_inode uint64 Wpcopy_count uint64 Wpcopy_delay_total uint64 + Irq_count uint64 + Irq_delay_total uint64 } type cpuMask uint32 diff --git a/unix/ztypes_linux_ppc64.go b/unix/ztypes_linux_ppc64.go index 42eb2c4cef..0348743950 100644 --- a/unix/ztypes_linux_ppc64.go +++ b/unix/ztypes_linux_ppc64.go @@ -339,6 +339,8 @@ type Taskstats struct { Ac_exe_inode uint64 Wpcopy_count uint64 Wpcopy_delay_total uint64 + Irq_count uint64 + Irq_delay_total uint64 } type cpuMask uint64 diff --git a/unix/ztypes_linux_ppc64le.go b/unix/ztypes_linux_ppc64le.go index 31304a4e8b..bad0670475 100644 --- a/unix/ztypes_linux_ppc64le.go +++ b/unix/ztypes_linux_ppc64le.go @@ -339,6 +339,8 @@ type Taskstats struct { Ac_exe_inode uint64 Wpcopy_count uint64 Wpcopy_delay_total uint64 + Irq_count uint64 + Irq_delay_total uint64 } type cpuMask uint64 diff --git a/unix/ztypes_linux_riscv64.go b/unix/ztypes_linux_riscv64.go index c311f9612d..9ea54b7b86 100644 --- a/unix/ztypes_linux_riscv64.go +++ b/unix/ztypes_linux_riscv64.go @@ -357,6 +357,8 @@ type Taskstats struct { Ac_exe_inode uint64 Wpcopy_count uint64 Wpcopy_delay_total uint64 + Irq_count uint64 + Irq_delay_total uint64 } type cpuMask uint64 diff --git a/unix/ztypes_linux_s390x.go b/unix/ztypes_linux_s390x.go index bba3cefac1..aa268d025c 100644 --- a/unix/ztypes_linux_s390x.go +++ b/unix/ztypes_linux_s390x.go @@ -352,6 +352,8 @@ type Taskstats struct { Ac_exe_inode uint64 Wpcopy_count uint64 Wpcopy_delay_total uint64 + Irq_count uint64 + Irq_delay_total uint64 } type cpuMask uint64 diff --git a/unix/ztypes_linux_sparc64.go b/unix/ztypes_linux_sparc64.go index ad8a013804..444045b6c5 100644 --- a/unix/ztypes_linux_sparc64.go +++ b/unix/ztypes_linux_sparc64.go @@ -334,6 +334,8 @@ type Taskstats struct { Ac_exe_inode uint64 Wpcopy_count uint64 Wpcopy_delay_total uint64 + Irq_count uint64 + Irq_delay_total uint64 } type cpuMask uint64