Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: stop using indirect system calls on openbsd #63900

Closed
4a6f656c opened this issue Nov 2, 2023 · 13 comments
Closed

all: stop using indirect system calls on openbsd #63900

4a6f656c opened this issue Nov 2, 2023 · 13 comments
Labels
NeedsFix The path to resolution is known, but the work has not been done. OS-OpenBSD
Milestone

Comments

@4a6f656c
Copy link
Contributor

4a6f656c commented Nov 2, 2023

The indirect syscall call interface (syscall(2)) will be removed from OpenBSD, most likely before the 7.5 release. This effectively means that Go's syscall.Syscall* interfaces will no longer work on this platform and that direct system calls (using the appropriate libc system call stub) will need to be used instead.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/538736 mentions this issue: syscall: call getfsstat via libc on openbsd

gopherbot pushed a commit that referenced this issue Nov 2, 2023
On openbsd, call getfsstat directly via libc, instead of calling it
via syscall.Syscall.

Updates #63900

Change-Id: Ib4c581160b170e6cc6017c42e959e647d97ac993
Reviewed-on: https://go-review.googlesource.com/c/go/+/538736
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Josh Rickmar <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
Run-TryBot: Joel Sing <[email protected]>
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/468095 mentions this issue: unix: use libc stubs for OpenBSD pledge+unveil

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/538995 mentions this issue: unix: use fcntl(2) libc stub on OpenBSD

@jrick
Copy link
Contributor

jrick commented Nov 2, 2023

I would perhaps reword this issue, as "direct system calls" could be misinterpreted to mean applications performing syscall instructions in their text, instead of using the particular libc stubs.

When we started requiring libc for system calls in dynamically linked executables, that was also referred to switching away from "direct system calls": #36435.

@bcmills bcmills changed the title all: use direct system calls on openbsd all: use libc system call wrappers on openbsd Nov 2, 2023
@cherrymui cherrymui added OS-OpenBSD NeedsFix The path to resolution is known, but the work has not been done. labels Nov 2, 2023
@cherrymui cherrymui added this to the Backlog milestone Nov 2, 2023
gopherbot pushed a commit to golang/sys that referenced this issue Nov 3, 2023
Future OpenBSD releases will remove the syscall(2) interface.
This converts the Pledge and Unveil calls to use pledge(2) and
unveil(2) from libc, rather than indirectly through syscall(2).

Updates golang/go#63900.

Change-Id: I61e22d8f52f16c8f5e4c0717acae0d5bf4271503
GitHub-Last-Rev: ebc0461
GitHub-Pull-Request: #146
Reviewed-on: https://go-review.googlesource.com/c/sys/+/468095
Reviewed-by: Cherry Mui <[email protected]>
Reviewed-by: Mauri de Souza Meneguzzo <[email protected]>
Reviewed-by: Joel Sing <[email protected]>
Reviewed-by: Tobias Klauser <[email protected]>
Run-TryBot: Joel Sing <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Aaron Bieber <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/538976 mentions this issue: syscall: call getfsstat via libc on openbsd

gopherbot pushed a commit to golang/sys that referenced this issue Nov 3, 2023
On openbsd, call getfsstat directly via libc, instead of calling it
via syscall.Syscall.

Updates golang/go#63900

Change-Id: I99a3555b3207754b107dbabf63440569fca93eea
Reviewed-on: https://go-review.googlesource.com/c/sys/+/538976
Reviewed-by: Cherry Mui <[email protected]>
Run-TryBot: Joel Sing <[email protected]>
Reviewed-by: Tobias Klauser <[email protected]>
Reviewed-by: Josh Rickmar <[email protected]>
Reviewed-by: Bryan Mills <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
jrick added a commit to jrick/sys that referenced this issue Nov 3, 2023
Future OpenBSD releases will remove the syscall(2) interface.
This converts the Fcntl functions to use fcntl(2) from libc,
rather than indirectly through syscall(2).

Updates golang/go#63900.
gopherbot pushed a commit to golang/sys that referenced this issue Nov 6, 2023
Future OpenBSD releases will remove the syscall(2) interface.
This converts the Fcntl functions to use fcntl(2) from libc,
rather than indirectly through syscall(2).

Updates golang/go#63900.

Change-Id: I50c3b91cb40245653c772e65b0b15c625974bebe
GitHub-Last-Rev: 9c62104
GitHub-Pull-Request: #179
Reviewed-on: https://go-review.googlesource.com/c/sys/+/538995
Reviewed-by: Bryan Mills <[email protected]>
Reviewed-by: Joel Sing <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
Run-TryBot: Joel Sing <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Mauri de Souza Meneguzzo <[email protected]>
@4a6f656c 4a6f656c changed the title all: use libc system call wrappers on openbsd all: stop using indirect system calls on openbsd Nov 6, 2023
@4a6f656c
Copy link
Contributor Author

4a6f656c commented Nov 6, 2023

I would perhaps reword this issue, as "direct system calls" could be misinterpreted to mean applications performing syscall instructions in their text, instead of using the particular libc stubs.

When we started requiring libc for system calls in dynamically linked executables, that was also referred to switching away from "direct system calls": #36435.

Naming and descriptions are hard - in this case, we are moving from "indirect system calls" (i.e. syscall(2)) to "direct system calls" albeit ones via the libc stubs. In this case we're already using the libc system call stubs, it is just that we're using syscall(2) which provides indirect system calls, rather than using the libc system call stub for a specific system call.

I've retitled #36435 to explicitly state "non-libc system calls", which is hopefully clearer.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/540020 mentions this issue: os/signal,syscall: avoid calling ioctl via syscall.Syscall on BSDs

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/540019 mentions this issue: syscall: provide and use ioctlPtr for all BSD platforms

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/540018 mentions this issue: syscall: provide and use fcntlPtr for all BSD platforms

gopherbot pushed a commit that referenced this issue Nov 7, 2023
Provide fcntlPtr for all BSD platforms, then use this for FcntlFlock.
This reduces darwin and openbsd specific code, as well as avoiding
the use of an indirect system call on OpenBSD.

Updates #63900

Change-Id: I5c701f0d8413fab5477b9e21381395621d1fb6d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/540018
Reviewed-by: Bryan Mills <[email protected]>
Reviewed-by: Heschi Kreinick <[email protected]>
Run-TryBot: Joel Sing <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Josh Rickmar <[email protected]>
gopherbot pushed a commit that referenced this issue Nov 7, 2023
Provide ioctlPtr for all BSD platforms, then use this for BPF.
This reduces darwin specific code, as well as avoiding the use of
an indirect system call on OpenBSD.

Updates #63900

Change-Id: I81f3e74a3149150abe972f106903310e3cf26929
Reviewed-on: https://go-review.googlesource.com/c/go/+/540019
Reviewed-by: Bryan Mills <[email protected]>
Reviewed-by: Heschi Kreinick <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Run-TryBot: Joel Sing <[email protected]>
Reviewed-by: Josh Rickmar <[email protected]>
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/572155 mentions this issue: syscall: export Tc{get,set}pgrp for testing

gopherbot pushed a commit that referenced this issue Mar 20, 2024
Provide appropriate implementations of internal/syscall/unix.Tcsetpgrp
and use this for runSessionLeader in os/signal/signal_cgo_test.go.
This avoids calling syscall.Syscall with SYS_IOCTL on BSDs.

Updates #59667
Updates #63900

Change-Id: Ifa4696bba9f1eb68e81e7103f030bc254adaf0af
Reviewed-on: https://go-review.googlesource.com/c/go/+/540020
Reviewed-by: Ian Lance Taylor <[email protected]>
Reviewed-by: David Chase <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Run-TryBot: Joel Sing <[email protected]>
gopherbot pushed a commit that referenced this issue Mar 22, 2024
Provide appropriate implementations of Tc{get,set}pgrp and export
these for use in the TestForeground* tests in exec_unix_test.go.
This avoids calling ioctl via syscall.Syscall on BSDs.

Fixes #59667
Updates #63900

Change-Id: Ice4dcedae1f0931c026bddf33043d3864a52d44e
Reviewed-on: https://go-review.googlesource.com/c/go/+/572155
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: David Chase <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Run-TryBot: Joel Sing <[email protected]>
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/582255 mentions this issue: cmd/dist,internal/platform: temporarily disable race detector on openbsd/amd64

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/582257 mentions this issue: syscall: remove references to SYS_syscall on openbsd

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/582256 mentions this issue: syscall: reroute SYS_IOCTL and SYS_SYSCTL on openbsd

gopherbot pushed a commit that referenced this issue May 4, 2024
…bsd/amd64

Unfortunately, LLVM TSAN decided to remove OpenBSD support, which
means that the syso files cannot currently be regenerated (see #52090).
The race_openbsd.syso contains a reference to the syscall symbol,
which has been removed from OpenBSD's libc in 7.5. As such, this
means that the race detector no longer works on openbsd/amd64 (at
least until LLVM TSAN support is reinstated for OpenBSD).

Updates #63900

Change-Id: I3474fc43a94e5197815862b7dc420b71d5e08815
Reviewed-on: https://go-review.googlesource.com/c/go/+/582255
Reviewed-by: Ian Lance Taylor <[email protected]>
Run-TryBot: Joel Sing <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: David Chase <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
gopherbot pushed a commit that referenced this issue May 4, 2024
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done. OS-OpenBSD
Projects
None yet
Development

No branches or pull requests

4 participants