Glibc Patch Being Reviewed For getrandom vDSO Support

Written by Michael Larabel in Programming on 31 July 2024 at 06:48 AM EDT. 1 Comment
PROGRAMMING
One of the many exciting features merged for Linux 6.11 is getrandom() in the vDSO for very fast yet secure random number generation. Now that the kernel bits have landed, it's on to making use of it in the GNU C Library and other libc implementations.

Going back to early getrandom in the vDSO work from 2022, there's been a glibc patch for testing while this week developer Jason Donenfeld sent out the firmed up patch now that the kernel support is upstream. Donenfeld wrote in that glibc patch:
"Linux 6.11 gains support for calling getrandom() from the vDSO. It operates on a thread-local opaque state allocated with mmap using flags specified by the vDSO.

Multiple states are allocated at once, as many as fit into a page, and these are held in an array of available states to be doled out to each thread upon first use, and recycled when a thread terminates. As these states run low, more are allocated.

To make this procedure async-signal-safe, a simple guard is used in the LSB of the opaque state address, falling back to the syscall if there's reentrancy contention.

This implementation is intentionally kept somewhat basic. We can add optimizations later, but for now, the idea is to get the bones set.

It's currently enabled for x86_64. As the kernel support gains more platforms (arm64 is in the works), this can be easily turned on for those."

The glibc patch is now under review.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week