-
Notifications
You must be signed in to change notification settings - Fork 17.4k
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
proposal: runtime: export runtime.getAuxv() #68089
Comments
The |
Let's treat this as a dup of #67839. I don't think we need two different proposals for the same idea. Thanks. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Proposal Details
This proposal is based on the initiative started with go.dev/issue/67401 to lock down future use of
//go:linkname
. runtime.getAuxv() is one of the functions inruntime
that is used with//go:linkname
in other Go packages.At program start, auxiliary vectors provide a way for the kernel to share essential details about the system with user processes. An auxiliary vector holds an even number of elements, (tag, value) pairs. The possible types can be added and exposed via golang.org/x/sys/unix. For the Linux kernel, the types are defined in include/uapi/linux/auxvec.h. To some extent, the information that is shared with the user process can be retrieved in other ways. As an example, the real uid (
AT_UID
) can also be retrieved using os.Getuid(). But the auxiliary vector also provides information that is not covered by other packages, likeAT_CLKTCK
(Frequency of times()) orAT_SYSINFO_EHDR
. Due to security related restrictions or isolation techniques, it is not possible in some environments to access/proc/<PID>/auxv
to retrieve the auxiliary vector.As only the Go runtime does have access to the auxiliary vector, this proposal advocates on adding
runtime.GetAuxv()
as API to the runtime.The exact format of the newly added API for
GetAuxv()
is subject to change and up for discussion with this proposal.For platforms where the auxiliary vector is not an established concept, like windows,
runtime.GetAuxv()
should returnnil
.Exposing
runtime.GetAuxv()
should not impact future internal or external changes to the runtime. The runtime should only expose the information it holds of the auxiliary vector that it receives at startup.With go.dev/cl/458256 access to
runtime.getAuxv()
(via//go:linkname
) was added to golang.org/x/sys/cpu. @prattmic mentioned in the review of this CL that some sort of access to the auxiliary vectors should be added in the future.An alternative, also mentioned in go.dev/issue/67839#issuecomment-2150542705, to
runtime.Getauxv()
could be to make the auxiliary vector available via golang.org/x/sys/unix by limiting the access toruntime.getAuxv()
to golang.org/x/sys/unix only.Related issue(s):
os
package.The text was updated successfully, but these errors were encountered: