-
Notifications
You must be signed in to change notification settings - Fork 52
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
VirtIO RNG and unexpected behavior of arc4random_buf() standard function of C #68
Comments
Quoted from https://en.wikipedia.org/wiki//dev/random:
Entropy injection (VirtIO RNG)
Check also: |
This commit introduces the VirtIO entropy device, also known as virtio-rng in QEMU or the Linux kernel. Randomness is a precious resource in the system. Without sufficient entropy, functions like arc4random_buf() in the standard C library may not work properly since they rely on the blocking device /dev/random. Closed sysprog21#68.
#70 resolves the issue here. |
This issue was identified during the development of #34 , where kmscube was found to have an extremely high chance of hanging during startup.
Upon investigation, I discovered that the reason kmscube hangs is due to the use of arc4random_buf(), a standard C library function. Since Buildroot packages are mostly built from source, I was able to trace the issue directly to its source.
Firstly, kmscube has the following package dependencies:
kmscube
->Mesa3D
->libgbm
(Generic Buffer Management) -> libexpat (an XML parser)During its startup, kmscube calls a libgbm function that reads application and driver settings from 00-mesa-defaults.conf. This process involves libexpat to parse XML syntax.
It turns out that during initialization, the parser calculates a salt hash, which requires using
arc4random_buf()
to generate a random number. However, due to an unknown issue,arc4random_buf()
often hangs, preventing kmscube from starting.Currently, we can work around the issue by modifying the following file:
It's unclear if this issue is related to #67, but we may need to further investigate the random number generation within the emulated environment.
The text was updated successfully, but these errors were encountered: