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

Open
4a6f656c opened this issue Nov 2, 2023 · 10 comments
Open

all: stop using indirect system calls on openbsd #63900

4a6f656c opened this issue Nov 2, 2023 · 10 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

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 <gobot@golang.org>
Reviewed-by: Josh Rickmar <jrick@zettaport.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
@gopherbot
Copy link

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

@gopherbot
Copy link

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 <cherryyz@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Aaron Bieber <aaron@bolddaemon.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
@gopherbot
Copy link

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 <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Josh Rickmar <jrick@zettaport.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
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 <bcmills@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
@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

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

@gopherbot
Copy link

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

@gopherbot
Copy link

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 <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Josh Rickmar <jrick@zettaport.com>
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 <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Josh Rickmar <jrick@zettaport.com>
@gopherbot
Copy link

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 <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
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 <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
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