diff options
Diffstat (limited to 'src/runtime/os_linux.go')
| -rw-r--r-- | src/runtime/os_linux.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go index e18ef8e776..979761cc6a 100644 --- a/src/runtime/os_linux.go +++ b/src/runtime/os_linux.go @@ -31,6 +31,10 @@ type mOS struct { // needPerThreadSyscall indicates that a per-thread syscall is required // for doAllThreadsSyscall. needPerThreadSyscall atomic.Uint8 + + // This is a pointer to a chunk of memory allocated with a special + // mmap invocation in vgetrandomGetState(). + vgetrandomState uintptr } //go:noescape @@ -344,6 +348,7 @@ func osinit() { ncpu = getproccount() physHugePageSize = getHugePageSize() osArchInit() + vgetrandomInit() } var urandom_dev = []byte("/dev/urandom\x00") @@ -400,6 +405,10 @@ func unminit() { // Called from exitm, but not from drop, to undo the effect of thread-owned // resources in minit, semacreate, or elsewhere. Do not take locks after calling this. func mdestroy(mp *m) { + if mp.vgetrandomState != 0 { + vgetrandomPutState(mp.vgetrandomState) + mp.vgetrandomState = 0 + } } // #ifdef GOARCH_386 |
