Skip to content

Commit

Permalink
syscall: remove references to SYS_syscall on openbsd
Browse files Browse the repository at this point in the history
OpenBSD 7.5 no longer has a syscall symbol in libc. This will
typically result in external linking failures since the syscall
package still has a reference to an undefined `syscall' symbol.
Remove these references and return ENOSYS if syscall.Syscall* or
syscall.RawSyscall* are used for a system call number that does not
currently have an internal remapping.

Fixes golang#63900

Change-Id: Ic757bf8872ad98a92dd5b34cf58312c32fbc9a96
Reviewed-on: https://go-review.googlesource.com/c/go/+/582257
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
  • Loading branch information
4a6f656c committed May 4, 2024
1 parent 8841f50 commit 20130cc
Show file tree
Hide file tree
Showing 13 changed files with 5 additions and 110 deletions.
12 changes: 5 additions & 7 deletions src/syscall/syscall_openbsd_libc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ func init() {
execveOpenBSD = execve
}

//sys directSyscall(trap uintptr, a1 uintptr, a2 uintptr, a3 uintptr, a4 uintptr, a5 uintptr) (ret uintptr, err error) = SYS_syscall

func syscallInternal(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
// OpenBSD 7.5+ no longer supports indirect syscalls. A number of Go
// packages make use of syscall.Syscall with SYS_IOCTL since it is
Expand All @@ -27,7 +25,7 @@ func syscallInternal(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
if trap == SYS_IOCTL {
return syscallX(abi.FuncPCABI0(libc_ioctl_trampoline), a1, a2, a3)
}
return syscall6X(abi.FuncPCABI0(libc_syscall_trampoline), trap, a1, a2, a3, 0, 0)
return 0, 0, ENOSYS
}

func syscall6Internal(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
Expand All @@ -39,19 +37,19 @@ func syscall6Internal(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err
if trap == SYS___SYSCTL {
return syscall6X(abi.FuncPCABI0(libc_sysctl_trampoline), a1, a2, a3, a4, a5, a6)
}
return syscall10X(abi.FuncPCABI0(libc_syscall_trampoline), trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
return 0, 0, ENOSYS
}

func rawSyscallInternal(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
return rawSyscall6X(abi.FuncPCABI0(libc_syscall_trampoline), trap, a1, a2, a3, 0, 0)
return 0, 0, ENOSYS
}

func rawSyscall6Internal(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
return rawSyscall10X(abi.FuncPCABI0(libc_syscall_trampoline), trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
return 0, 0, ENOSYS
}

func syscall9Internal(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) {
return rawSyscall10X(abi.FuncPCABI0(libc_syscall_trampoline), trap, a1, a2, a3, a4, a5, a6, a7, a8, a9)
return 0, 0, ENOSYS
}

// Implemented in the runtime package (runtime/sys_openbsd3.go)
Expand Down
15 changes: 0 additions & 15 deletions src/syscall/zsyscall_openbsd_386.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/syscall/zsyscall_openbsd_386.s
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
TEXT ·libc_utimensat_trampoline(SB),NOSPLIT,$0-0
JMP libc_utimensat(SB)
TEXT ·libc_syscall_trampoline(SB),NOSPLIT,$0-0
JMP libc_syscall(SB)
TEXT ·libc_lseek_trampoline(SB),NOSPLIT,$0-0
JMP libc_lseek(SB)
TEXT ·libc_getcwd_trampoline(SB),NOSPLIT,$0-0
Expand Down
15 changes: 0 additions & 15 deletions src/syscall/zsyscall_openbsd_amd64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/syscall/zsyscall_openbsd_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
TEXT ·libc_utimensat_trampoline(SB),NOSPLIT,$0-0
JMP libc_utimensat(SB)
TEXT ·libc_syscall_trampoline(SB),NOSPLIT,$0-0
JMP libc_syscall(SB)
TEXT ·libc_lseek_trampoline(SB),NOSPLIT,$0-0
JMP libc_lseek(SB)
TEXT ·libc_getcwd_trampoline(SB),NOSPLIT,$0-0
Expand Down
15 changes: 0 additions & 15 deletions src/syscall/zsyscall_openbsd_arm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/syscall/zsyscall_openbsd_arm.s
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
TEXT ·libc_utimensat_trampoline(SB),NOSPLIT,$0-0
JMP libc_utimensat(SB)
TEXT ·libc_syscall_trampoline(SB),NOSPLIT,$0-0
JMP libc_syscall(SB)
TEXT ·libc_lseek_trampoline(SB),NOSPLIT,$0-0
JMP libc_lseek(SB)
TEXT ·libc_getcwd_trampoline(SB),NOSPLIT,$0-0
Expand Down
15 changes: 0 additions & 15 deletions src/syscall/zsyscall_openbsd_arm64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/syscall/zsyscall_openbsd_arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
TEXT ·libc_utimensat_trampoline(SB),NOSPLIT,$0-0
JMP libc_utimensat(SB)
TEXT ·libc_syscall_trampoline(SB),NOSPLIT,$0-0
JMP libc_syscall(SB)
TEXT ·libc_lseek_trampoline(SB),NOSPLIT,$0-0
JMP libc_lseek(SB)
TEXT ·libc_getcwd_trampoline(SB),NOSPLIT,$0-0
Expand Down
15 changes: 0 additions & 15 deletions src/syscall/zsyscall_openbsd_ppc64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/syscall/zsyscall_openbsd_ppc64.s
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,6 @@ TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
TEXT ·libc_utimensat_trampoline(SB),NOSPLIT,$0-0
CALL libc_utimensat(SB)
RET
TEXT ·libc_syscall_trampoline(SB),NOSPLIT,$0-0
CALL libc_syscall(SB)
RET
TEXT ·libc_lseek_trampoline(SB),NOSPLIT,$0-0
CALL libc_lseek(SB)
RET
Expand Down
15 changes: 0 additions & 15 deletions src/syscall/zsyscall_openbsd_riscv64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions src/syscall/zsyscall_openbsd_riscv64.s
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
JMP libc_getfsstat(SB)
TEXT ·libc_utimensat_trampoline(SB),NOSPLIT,$0-0
JMP libc_utimensat(SB)
TEXT ·libc_syscall_trampoline(SB),NOSPLIT,$0-0
JMP libc_syscall(SB)
TEXT ·libc_lseek_trampoline(SB),NOSPLIT,$0-0
JMP libc_lseek(SB)
TEXT ·libc_getcwd_trampoline(SB),NOSPLIT,$0-0
Expand Down

0 comments on commit 20130cc

Please sign in to comment.