You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 in runtime 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, like AT_CLKTCK (Frequency of times()) or AT_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.
func Getauxv() []uintptr
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 return nil.
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.
The unix package seems like the more appropriate place for this feature, since it is UNIX-specific. (The closest analogue in Windows is the Process Environment Block, but its structure and function are completely different in the details.)
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: