1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
From: Reinhard Tartler <siretart@tauware.de>
Date: Sat, 23 Aug 2025 18:44:09 -0400
Subject: Revert "internal/linux: use unix.Auxv"
Forwarded: not-needed
This reverts commit 8462e8fdd5f99819b1c6ec4cde32703dc2f7954f.
---
go.mod | 2 +-
go.sum | 4 ++--
internal/linux/auxv.go | 21 +++++++++++++--------
internal/unix/types_linux.go | 4 ----
internal/unix/types_other.go | 4 ----
5 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/go.mod b/go.mod
index 439844a..03dc022 100644
--- a/go.mod
+++ b/go.mod
@@ -6,7 +6,7 @@ require (
github.com/go-quicktest/qt v1.101.0
github.com/google/go-cmp v0.6.0
github.com/jsimonetti/rtnetlink/v2 v2.0.1
- golang.org/x/sys v0.30.0
+ golang.org/x/sys v0.28.0
)
require (
diff --git a/go.sum b/go.sum
index c154a61..3fe5a63 100644
--- a/go.sum
+++ b/go.sum
@@ -23,5 +23,5 @@ golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
-golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
-golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
+golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
diff --git a/internal/linux/auxv.go b/internal/linux/auxv.go
index 10508fd..07d5efe 100644
--- a/internal/linux/auxv.go
+++ b/internal/linux/auxv.go
@@ -1,11 +1,12 @@
package linux
import (
+ "errors"
"fmt"
"io"
+ _ "unsafe"
"github.com/cilium/ebpf/internal"
- "github.com/cilium/ebpf/internal/unix"
)
type auxvPairReader interface {
@@ -19,8 +20,11 @@ const (
_AT_SYSINFO_EHDR = 33 // Offset to vDSO blob in process image
)
+//go:linkname runtime_getAuxv runtime.getAuxv
+func runtime_getAuxv() []uintptr
+
type auxvRuntimeReader struct {
- data [][2]uintptr
+ data []uintptr
index int
}
@@ -36,12 +40,12 @@ func (r *auxvRuntimeReader) ReadAuxvPair() (uint64, uint64, error) {
// we manually add the (_AT_NULL, _AT_NULL) pair at the end
// that is not provided by the go runtime
var tag, value uintptr
- if r.index < len(r.data) {
- tag, value = r.data[r.index][0], r.data[r.index][1]
+ if r.index+1 < len(r.data) {
+ tag, value = r.data[r.index], r.data[r.index+1]
} else {
tag, value = _AT_NULL, _AT_NULL
}
- r.index += 1
+ r.index += 2
return uint64(tag), uint64(value), nil
}
@@ -50,9 +54,10 @@ func newAuxvRuntimeReader() (auxvPairReader, error) {
return nil, fmt.Errorf("read auxv from runtime: %w", internal.ErrNotSupportedOnOS)
}
- data, err := unix.Auxv()
- if err != nil {
- return nil, fmt.Errorf("read auxv from runtime: %w", err)
+ data := runtime_getAuxv()
+
+ if len(data)%2 != 0 {
+ return nil, errors.New("malformed auxv passed from runtime")
}
return &auxvRuntimeReader{
diff --git a/internal/unix/types_linux.go b/internal/unix/types_linux.go
index 385adf0..1421add 100644
--- a/internal/unix/types_linux.go
+++ b/internal/unix/types_linux.go
@@ -195,7 +195,3 @@ func SchedSetaffinity(pid int, set *CPUSet) error {
func SchedGetaffinity(pid int, set *CPUSet) error {
return linux.SchedGetaffinity(pid, set)
}
-
-func Auxv() ([][2]uintptr, error) {
- return linux.Auxv()
-}
diff --git a/internal/unix/types_other.go b/internal/unix/types_other.go
index 323f7ff..7687373 100644
--- a/internal/unix/types_other.go
+++ b/internal/unix/types_other.go
@@ -278,7 +278,3 @@ func SchedSetaffinity(pid int, set *CPUSet) error {
func SchedGetaffinity(pid int, set *CPUSet) error {
return errNonLinux()
}
-
-func Auxv() ([][2]uintptr, error) {
- return nil, errNonLinux()
-}
|