ssize_t vgetrandom(void *buffer, size_t len, unsigned int flags,
void *opaque_state, size_t opaque_len);
// If buffer = len = flags = 0 && opaque_len = ~0, opaque_state is set to the struct:
struct vgetrandom_opaque_params {
__u32 size_of_opaque_state;
__u32 mmap_prot;
__u32 mmap_flags;
__u32 reserved[13];
};
Note that it isn't as simple as calling vgetrandom, callers need to pre-allocate memory to pass to the syscall.
Go recently implemented support in golang/go/issues/69577 (see https://go-review.googlesource.com/c/go/+/614835 for the patchset). Note that this impl allocates a pool of states per the number of CPUs, and uses a lock to fetch an unused state.
Linux 6.11 added
getrandom
to the vdso. The supported architectures are:The API is:
Note that it isn't as simple as calling
vgetrandom
, callers need to pre-allocate memory to pass to the syscall.Go recently implemented support in golang/go/issues/69577 (see https://go-review.googlesource.com/c/go/+/614835 for the patchset). Note that this impl allocates a pool of states per the number of CPUs, and uses a lock to fetch an unused state.