aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-10-23 13:20:36 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-10-23 13:20:51 +0200
commitdaea55513afe4637c57f5dde24f8d99ca371acd4 (patch)
tree17702291a35d92f50c03229710ac2ec8fec269da
parentRevert "NetworkExtension: don't use exit(0) hack on Catalina" (diff)
downloadwireguard-apple-master.tar.xz
wireguard-apple-master.zip
wireguard-go-bridge: work around Go 1.13.3 regressionHEADmaster
-rw-r--r--wireguard-go-bridge/Makefile2
-rw-r--r--wireguard-go-bridge/goruntime-reenable-sysctl.diff417
2 files changed, 418 insertions, 1 deletions
diff --git a/wireguard-go-bridge/Makefile b/wireguard-go-bridge/Makefile
index 861f4fb..108c58a 100644
--- a/wireguard-go-bridge/Makefile
+++ b/wireguard-go-bridge/Makefile
@@ -28,7 +28,7 @@ $(GOROOT)/.prepared:
[ -n "$(REAL_GOROOT)" ]
mkdir -p "$(GOROOT)"
rsync -a --delete --exclude=pkg/obj/go-build "$(REAL_GOROOT)/" "$(GOROOT)/"
- patch -p1 -f -N -r- -d "$(GOROOT)" < goruntime-boottime-over-monotonic.diff
+ cat goruntime-*.diff | patch -p1 -f -N -r- -d "$(GOROOT)"
touch "$@"
define libwg-go-a
diff --git a/wireguard-go-bridge/goruntime-reenable-sysctl.diff b/wireguard-go-bridge/goruntime-reenable-sysctl.diff
new file mode 100644
index 0000000..364db55
--- /dev/null
+++ b/wireguard-go-bridge/goruntime-reenable-sysctl.diff
@@ -0,0 +1,417 @@
+From 84066be0c739d4ce23e3472e8be76a7c1de61fc6 Mon Sep 17 00:00:00 2001
+From: Jason A. Donenfeld <Jason@zx2c4.com>
+Date: Wed, 23 Oct 2019 13:08:46 +0200
+Subject: [PATCH] syscall: reenable sysctl on iOS
+
+This was disabled due to a report that the App Store rejects the symbol
+__sysctl. However, we use the sysctl symbol, which is fine. The __sysctl
+symbol is used by x/sys/unix, which needs fixing instead. So, this
+commit reenables sysctl on iOS, so that things like net.InterfaceByName
+can work again.
+
+This reverts the following commits:
+- 78d9949103 ("syscall: disable sysctl on iOS")
+- a5025fdcde ("log/syslog: skip unsupported tests on iOS")
+- 2711fababd ("net,os: disable more sysctl tests on iOS")
+- 83a78eb911 ("syscall: re-generate zsyscall_darwin_arm*.s")
+
+Fixes #35101
+Updates #34133
+Updates #35103
+
+Change-Id: Ib8eb9f87b81db24965b0de29d99eb52887c7c60a
+---
+
+diff --git a/src/log/syslog/syslog_test.go b/src/log/syslog/syslog_test.go
+index dd1a1c4..8df8ebb 100644
+--- a/src/log/syslog/syslog_test.go
++++ b/src/log/syslog/syslog_test.go
+@@ -134,9 +134,6 @@
+ }
+
+ func TestWithSimulated(t *testing.T) {
+- if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") {
+- t.Skipf("sysctl is not supported on iOS")
+- }
+ t.Parallel()
+ msg := "Test 123"
+ var transport []string
+@@ -275,9 +272,6 @@
+ }
+
+ func TestWrite(t *testing.T) {
+- if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") {
+- t.Skipf("sysctl is not supported on iOS")
+- }
+ t.Parallel()
+ tests := []struct {
+ pri Priority
+diff --git a/src/net/interface_test.go b/src/net/interface_test.go
+index 7379a8f..b2ef21e 100644
+--- a/src/net/interface_test.go
++++ b/src/net/interface_test.go
+@@ -50,18 +50,7 @@
+ return ""
+ }
+
+-func condSkipInterfaceTest(t *testing.T) {
+- t.Helper()
+- switch runtime.GOOS {
+- case "darwin":
+- if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
+- t.Skipf("sysctl is not supported on iOS")
+- }
+- }
+-}
+-
+ func TestInterfaces(t *testing.T) {
+- condSkipInterfaceTest(t)
+ ift, err := Interfaces()
+ if err != nil {
+ t.Fatal(err)
+@@ -93,7 +82,6 @@
+ }
+
+ func TestInterfaceAddrs(t *testing.T) {
+- condSkipInterfaceTest(t)
+ ift, err := Interfaces()
+ if err != nil {
+ t.Fatal(err)
+@@ -113,7 +101,6 @@
+ }
+
+ func TestInterfaceUnicastAddrs(t *testing.T) {
+- condSkipInterfaceTest(t)
+ ift, err := Interfaces()
+ if err != nil {
+ t.Fatal(err)
+@@ -141,7 +128,6 @@
+ }
+
+ func TestInterfaceMulticastAddrs(t *testing.T) {
+- condSkipInterfaceTest(t)
+ ift, err := Interfaces()
+ if err != nil {
+ t.Fatal(err)
+diff --git a/src/os/os_test.go b/src/os/os_test.go
+index ae6bad1..93ac7ad 100644
+--- a/src/os/os_test.go
++++ b/src/os/os_test.go
+@@ -1515,9 +1515,6 @@
+ }
+
+ func TestHostname(t *testing.T) {
+- if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") {
+- t.Skipf("sysctl is not supported on iOS")
+- }
+ hostname, err := Hostname()
+ if err != nil {
+ t.Fatal(err)
+diff --git a/src/syscall/syscall_darwin.go b/src/syscall/syscall_darwin.go
+index 2efcf3b..7d795ee 100644
+--- a/src/syscall/syscall_darwin.go
++++ b/src/syscall/syscall_darwin.go
+@@ -337,6 +337,7 @@
+ //sysnb ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) = SYS_ioctl
+ //sysnb execve(path *byte, argv **byte, envp **byte) (err error)
+ //sysnb exit(res int) (err error)
++//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error)
+ //sys fcntlPtr(fd int, cmd int, arg unsafe.Pointer) (val int, err error) = SYS_fcntl
+ //sys unlinkat(fd int, path string, flags int) (err error)
+ //sys openat(fd int, path string, flags int, perm uint32) (fdret int, err error)
+diff --git a/src/syscall/syscall_darwin_386.go b/src/syscall/syscall_darwin_386.go
+index 46714ba..8c5b82d 100644
+--- a/src/syscall/syscall_darwin_386.go
++++ b/src/syscall/syscall_darwin_386.go
+@@ -22,7 +22,6 @@
+ //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_statfs64
+ //sys fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_fstatat64
+ //sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
+-//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error)
+
+ func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint32(fd)
+diff --git a/src/syscall/syscall_darwin_amd64.go b/src/syscall/syscall_darwin_amd64.go
+index 43506e4..23a4e5f 100644
+--- a/src/syscall/syscall_darwin_amd64.go
++++ b/src/syscall/syscall_darwin_amd64.go
+@@ -22,7 +22,6 @@
+ //sys Statfs(path string, stat *Statfs_t) (err error) = SYS_statfs64
+ //sys fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_fstatat64
+ //sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
+-//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error)
+
+ func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint64(fd)
+diff --git a/src/syscall/syscall_darwin_arm.go b/src/syscall/syscall_darwin_arm.go
+index 4ca2e30..7f39cf4 100644
+--- a/src/syscall/syscall_darwin_arm.go
++++ b/src/syscall/syscall_darwin_arm.go
+@@ -29,10 +29,6 @@
+ return ENOTSUP
+ }
+
+-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error {
+- return ENOTSUP
+-}
+-
+ func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint32(fd)
+ k.Filter = int16(mode)
+diff --git a/src/syscall/syscall_darwin_arm64.go b/src/syscall/syscall_darwin_arm64.go
+index fde48f3..bd110f2 100644
+--- a/src/syscall/syscall_darwin_arm64.go
++++ b/src/syscall/syscall_darwin_arm64.go
+@@ -29,10 +29,6 @@
+ return ENOTSUP
+ }
+
+-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error {
+- return ENOTSUP
+-}
+-
+ func SetKevent(k *Kevent_t, fd, mode, flags int) {
+ k.Ident = uint64(fd)
+ k.Filter = int16(mode)
+diff --git a/src/syscall/zsyscall_darwin_386.go b/src/syscall/zsyscall_darwin_386.go
+index 0ffc692..2c3b15f 100644
+--- a/src/syscall/zsyscall_darwin_386.go
++++ b/src/syscall/zsyscall_darwin_386.go
+@@ -1870,6 +1870,27 @@
+
+ // 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) {
++ var _p0 unsafe.Pointer
++ if len(mib) > 0 {
++ _p0 = unsafe.Pointer(&mib[0])
++ } else {
++ _p0 = unsafe.Pointer(&_zero)
++ }
++ _, _, e1 := syscall6(funcPC(libc_sysctl_trampoline), uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
++ if e1 != 0 {
++ err = errnoErr(e1)
++ }
++ return
++}
++
++func libc_sysctl_trampoline()
++
++//go:linkname libc_sysctl libc_sysctl
++//go:cgo_import_dynamic libc_sysctl sysctl "/usr/lib/libSystem.B.dylib"
++
++// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
++
+ func fcntlPtr(fd int, cmd int, arg unsafe.Pointer) (val int, err error) {
+ r0, _, e1 := syscall(funcPC(libc_fcntl_trampoline), uintptr(fd), uintptr(cmd), uintptr(arg))
+ val = int(r0)
+@@ -2060,24 +2081,3 @@
+
+ //go:linkname libc_ptrace libc_ptrace
+ //go:cgo_import_dynamic libc_ptrace ptrace "/usr/lib/libSystem.B.dylib"
+-
+-// 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) {
+- var _p0 unsafe.Pointer
+- if len(mib) > 0 {
+- _p0 = unsafe.Pointer(&mib[0])
+- } else {
+- _p0 = unsafe.Pointer(&_zero)
+- }
+- _, _, e1 := syscall6(funcPC(libc_sysctl_trampoline), uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
+- if e1 != 0 {
+- err = errnoErr(e1)
+- }
+- return
+-}
+-
+-func libc_sysctl_trampoline()
+-
+-//go:linkname libc_sysctl libc_sysctl
+-//go:cgo_import_dynamic libc_sysctl sysctl "/usr/lib/libSystem.B.dylib"
+diff --git a/src/syscall/zsyscall_darwin_386.s b/src/syscall/zsyscall_darwin_386.s
+index 0dec5ba..d84b462 100644
+--- a/src/syscall/zsyscall_darwin_386.s
++++ b/src/syscall/zsyscall_darwin_386.s
+@@ -229,6 +229,8 @@
+ JMP libc_execve(SB)
+ TEXT ·libc_exit_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_exit(SB)
++TEXT ·libc_sysctl_trampoline(SB),NOSPLIT,$0-0
++ JMP libc_sysctl(SB)
+ TEXT ·libc_unlinkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_unlinkat(SB)
+ TEXT ·libc_openat_trampoline(SB),NOSPLIT,$0-0
+@@ -249,5 +251,3 @@
+ JMP libc_fstatat64(SB)
+ TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ptrace(SB)
+-TEXT ·libc_sysctl_trampoline(SB),NOSPLIT,$0-0
+- JMP libc_sysctl(SB)
+diff --git a/src/syscall/zsyscall_darwin_amd64.go b/src/syscall/zsyscall_darwin_amd64.go
+index 942152a..83214de 100644
+--- a/src/syscall/zsyscall_darwin_amd64.go
++++ b/src/syscall/zsyscall_darwin_amd64.go
+@@ -1870,6 +1870,27 @@
+
+ // 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) {
++ var _p0 unsafe.Pointer
++ if len(mib) > 0 {
++ _p0 = unsafe.Pointer(&mib[0])
++ } else {
++ _p0 = unsafe.Pointer(&_zero)
++ }
++ _, _, e1 := syscall6(funcPC(libc_sysctl_trampoline), uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
++ if e1 != 0 {
++ err = errnoErr(e1)
++ }
++ return
++}
++
++func libc_sysctl_trampoline()
++
++//go:linkname libc_sysctl libc_sysctl
++//go:cgo_import_dynamic libc_sysctl sysctl "/usr/lib/libSystem.B.dylib"
++
++// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
++
+ func fcntlPtr(fd int, cmd int, arg unsafe.Pointer) (val int, err error) {
+ r0, _, e1 := syscall(funcPC(libc_fcntl_trampoline), uintptr(fd), uintptr(cmd), uintptr(arg))
+ val = int(r0)
+@@ -2060,24 +2081,3 @@
+
+ //go:linkname libc_ptrace libc_ptrace
+ //go:cgo_import_dynamic libc_ptrace ptrace "/usr/lib/libSystem.B.dylib"
+-
+-// 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) {
+- var _p0 unsafe.Pointer
+- if len(mib) > 0 {
+- _p0 = unsafe.Pointer(&mib[0])
+- } else {
+- _p0 = unsafe.Pointer(&_zero)
+- }
+- _, _, e1 := syscall6(funcPC(libc_sysctl_trampoline), uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
+- if e1 != 0 {
+- err = errnoErr(e1)
+- }
+- return
+-}
+-
+-func libc_sysctl_trampoline()
+-
+-//go:linkname libc_sysctl libc_sysctl
+-//go:cgo_import_dynamic libc_sysctl sysctl "/usr/lib/libSystem.B.dylib"
+diff --git a/src/syscall/zsyscall_darwin_amd64.s b/src/syscall/zsyscall_darwin_amd64.s
+index fcb7f9c..23ddbe0 100644
+--- a/src/syscall/zsyscall_darwin_amd64.s
++++ b/src/syscall/zsyscall_darwin_amd64.s
+@@ -229,6 +229,8 @@
+ JMP libc_execve(SB)
+ TEXT ·libc_exit_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_exit(SB)
++TEXT ·libc_sysctl_trampoline(SB),NOSPLIT,$0-0
++ JMP libc_sysctl(SB)
+ TEXT ·libc_unlinkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_unlinkat(SB)
+ TEXT ·libc_openat_trampoline(SB),NOSPLIT,$0-0
+@@ -249,5 +251,3 @@
+ JMP libc_fstatat64(SB)
+ TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_ptrace(SB)
+-TEXT ·libc_sysctl_trampoline(SB),NOSPLIT,$0-0
+- JMP libc_sysctl(SB)
+diff --git a/src/syscall/zsyscall_darwin_arm.go b/src/syscall/zsyscall_darwin_arm.go
+index 73ee205..2a643f2 100644
+--- a/src/syscall/zsyscall_darwin_arm.go
++++ b/src/syscall/zsyscall_darwin_arm.go
+@@ -1870,6 +1870,27 @@
+
+ // 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) {
++ var _p0 unsafe.Pointer
++ if len(mib) > 0 {
++ _p0 = unsafe.Pointer(&mib[0])
++ } else {
++ _p0 = unsafe.Pointer(&_zero)
++ }
++ _, _, e1 := syscall6(funcPC(libc_sysctl_trampoline), uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
++ if e1 != 0 {
++ err = errnoErr(e1)
++ }
++ return
++}
++
++func libc_sysctl_trampoline()
++
++//go:linkname libc_sysctl libc_sysctl
++//go:cgo_import_dynamic libc_sysctl sysctl "/usr/lib/libSystem.B.dylib"
++
++// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
++
+ func fcntlPtr(fd int, cmd int, arg unsafe.Pointer) (val int, err error) {
+ r0, _, e1 := syscall(funcPC(libc_fcntl_trampoline), uintptr(fd), uintptr(cmd), uintptr(arg))
+ val = int(r0)
+diff --git a/src/syscall/zsyscall_darwin_arm.s b/src/syscall/zsyscall_darwin_arm.s
+index 6462a198..c7cd83d 100644
+--- a/src/syscall/zsyscall_darwin_arm.s
++++ b/src/syscall/zsyscall_darwin_arm.s
+@@ -229,6 +229,8 @@
+ JMP libc_execve(SB)
+ TEXT ·libc_exit_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_exit(SB)
++TEXT ·libc_sysctl_trampoline(SB),NOSPLIT,$0-0
++ JMP libc_sysctl(SB)
+ TEXT ·libc_unlinkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_unlinkat(SB)
+ TEXT ·libc_openat_trampoline(SB),NOSPLIT,$0-0
+diff --git a/src/syscall/zsyscall_darwin_arm64.go b/src/syscall/zsyscall_darwin_arm64.go
+index bbe092c..0b77839 100644
+--- a/src/syscall/zsyscall_darwin_arm64.go
++++ b/src/syscall/zsyscall_darwin_arm64.go
+@@ -1870,6 +1870,27 @@
+
+ // 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) {
++ var _p0 unsafe.Pointer
++ if len(mib) > 0 {
++ _p0 = unsafe.Pointer(&mib[0])
++ } else {
++ _p0 = unsafe.Pointer(&_zero)
++ }
++ _, _, e1 := syscall6(funcPC(libc_sysctl_trampoline), uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
++ if e1 != 0 {
++ err = errnoErr(e1)
++ }
++ return
++}
++
++func libc_sysctl_trampoline()
++
++//go:linkname libc_sysctl libc_sysctl
++//go:cgo_import_dynamic libc_sysctl sysctl "/usr/lib/libSystem.B.dylib"
++
++// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
++
+ func fcntlPtr(fd int, cmd int, arg unsafe.Pointer) (val int, err error) {
+ r0, _, e1 := syscall(funcPC(libc_fcntl_trampoline), uintptr(fd), uintptr(cmd), uintptr(arg))
+ val = int(r0)
+diff --git a/src/syscall/zsyscall_darwin_arm64.s b/src/syscall/zsyscall_darwin_arm64.s
+index ec2210f..7b8b376 100644
+--- a/src/syscall/zsyscall_darwin_arm64.s
++++ b/src/syscall/zsyscall_darwin_arm64.s
+@@ -229,6 +229,8 @@
+ JMP libc_execve(SB)
+ TEXT ·libc_exit_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_exit(SB)
++TEXT ·libc_sysctl_trampoline(SB),NOSPLIT,$0-0
++ JMP libc_sysctl(SB)
+ TEXT ·libc_unlinkat_trampoline(SB),NOSPLIT,$0-0
+ JMP libc_unlinkat(SB)
+ TEXT ·libc_openat_trampoline(SB),NOSPLIT,$0-0