Skip to content

Commit 8841f50

Browse files
committed
syscall: reroute SYS_IOCTL and SYS_SYSCTL on openbsd
OpenBSD 7.5 no longer supports indirect syscalls. A number of Go packages make use of syscall.Syscall with SYS_IOCTL or SYS_SYSCTL, since neither is well supported by golang.org/x/sys/unix. Reroute calls with either of these system call numbers to the respective libc stub so that they continue to work. Updates #63900 Change-Id: I3323a3fa311ee9227e6220417834253763866881 Reviewed-on: https://go-review.googlesource.com/c/go/+/582256 Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: David Chase <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 17fce63 commit 8841f50

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/syscall/syscall_openbsd_libc.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,26 @@ func init() {
1919
//sys directSyscall(trap uintptr, a1 uintptr, a2 uintptr, a3 uintptr, a4 uintptr, a5 uintptr) (ret uintptr, err error) = SYS_syscall
2020

2121
func syscallInternal(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
22+
// OpenBSD 7.5+ no longer supports indirect syscalls. A number of Go
23+
// packages make use of syscall.Syscall with SYS_IOCTL since it is
24+
// not well supported by golang.org/x/sys/unix. Reroute this system
25+
// call number to the respective libc stub so that it continues to
26+
// work for the time being. See #63900 for further details.
27+
if trap == SYS_IOCTL {
28+
return syscallX(abi.FuncPCABI0(libc_ioctl_trampoline), a1, a2, a3)
29+
}
2230
return syscall6X(abi.FuncPCABI0(libc_syscall_trampoline), trap, a1, a2, a3, 0, 0)
2331
}
2432

2533
func syscall6Internal(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
34+
// OpenBSD 7.5+ no longer supports indirect syscalls. A number of Go
35+
// packages make use of syscall.Syscall with SYS___SYSCTL since it is
36+
// not well supported by golang.org/x/sys/unix. Reroute this system
37+
// call number to the respective libc stub so that it continues to
38+
// work for the time being. See #63900 for further details.
39+
if trap == SYS___SYSCTL {
40+
return syscall6X(abi.FuncPCABI0(libc_sysctl_trampoline), a1, a2, a3, a4, a5, a6)
41+
}
2642
return syscall10X(abi.FuncPCABI0(libc_syscall_trampoline), trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
2743
}
2844

0 commit comments

Comments
 (0)