Does it read entropy from /dev/urandom to protect hash table against "Algorithmic Complexity Attacks"? Is getrandom(2) the solution? Or init API that receives entropy from caller?
On Linux, getrandom is always the right approach. The /dev/urandom and /dev/random APIs are obsolescent. They aren't always available since they require access to a populated /dev, there's the dynamic failure case from using dynamic allocation (of files) and the early init bug.
The maintainers should fix the early init security bug in /dev/urandom, but they aren't yet willing to do it based on the lackluster kernel entropy generation combined with broad deployment of broken environments not providing entropy such as poor virtual machine implementations.
To save you some trouble: We're primarily talking about Linux systems where getrandom syscall returns ENOSYS or where there is no such syscall and there getentropy and friends all open /dev/urandom.
The right approach to take when there's not supposed to be a failure case and there's no secure alternatives is to abort. The getrandom system call was introduced in 2014 with the release of Linux 3.17. I doubt the systems you're talking about receive meaningful security updates.
Preaching to the choir. But, people still ask for Android O support and somebody from Google shared some info with me about the significance of Android O deployment. Last I looked some Enterprise Linux LTS stuff still doesn't have it either.
Minimum kernel version for Android O is specified to be 3.18 even for devices that were only upgraded to Android O. Linux 3.18 is also the oldest supported LTS branch for the Android common kernel and by the downstream SoC vendors. If it's older, it's going to be insecure anyway.
Yes, but I guess there are Android devices without getrandom, for whatever reason, and people (developers) would rather have their app "work" on those devices (securely or not) rather than not even start. Pretty unlikely /dev/urandom isn't seeded for a normal Android app, right?
In early init, Android copies over a massive amount of entropy from the hardware CSPRNG (which is supported on all Snapdragon devices, at a minimum) and restores entropy from previous boots. It also attempts to regularly reseed from hw CSPRNG but this is broken on some devices.
It's not really an issue for Android app, but it is an issue for something like a hardened malloc implementation on Android. It can be expected that the CSPRNG is not seeded in early boot for init itself and blocking for getrandom can add some time to the boot process but works.