Parcourir la source

android: Add workaround for tailscale pidfd crash

世界 il y a 2 mois
Parent
commit
0a63049845
2 fichiers modifiés avec 21 ajouts et 0 suppressions
  1. 2 0
      cmd/internal/build_libbox/main.go
  2. 19 0
      experimental/libbox/pidfd_android.go

+ 2 - 0
cmd/internal/build_libbox/main.go

@@ -112,6 +112,8 @@ func buildAndroid() {
 		args = append(args, debugFlags...)
 	}
 
+	args = append(args, "-ldflags", "-checklinkname=0")
+
 	tags := append(sharedTags, memcTags...)
 	if debugEnabled {
 		tags = append(tags, debugTags...)

+ 19 - 0
experimental/libbox/pidfd_android.go

@@ -0,0 +1,19 @@
+package libbox
+
+import (
+	"os"
+	_ "unsafe"
+)
+
+// https://github.com/SagerNet/sing-box/issues/3233
+// https://github.com/golang/go/issues/70508
+// https://github.com/tailscale/tailscale/issues/13452
+
+//go:linkname checkPidfdOnce os.checkPidfdOnce
+var checkPidfdOnce func() error
+
+func init() {
+	checkPidfdOnce = func() error {
+		return os.ErrInvalid
+	}
+}