-
Notifications
You must be signed in to change notification settings - Fork 35
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
is haveged still useful/relevant? #57
Comments
Hi Kristian, thanks a lot for pointing me to the recent kernel development. After reading the LKML/LWN articles, I completely agree that the haveged service is now obsolete (starting from kernel 5.6). I have verified it experimentally on Fedora 32, running kernel 5.10
I'm happy that these changes made it into the mainline kernel. It's nice to see that the main idea behind HAVEGED has sustained time test! (It was published already in 2003 here: https://www.irisa.fr/caps/projects/hipsor/publications/havege-tomacs.pdf) I'm also glad that the HAVEGE algorithm is being further explored and examined - see the "CPU Jitter Random Number Generator" page at https://www.chronox.de/jent.html I will keep maintaining HAVEGED - most Linux installations are still running on the older kernel versions. HAVEGED can also be used as the userspace RNG to generate random numbers. See Last but not least, HAVEGED can be used as the RNG library. Thanks a lot Further references: |
See: jirka-h/haveged#57 (comment) Signed-off-by: BlackEagle <ike.devolder@gmail.com>
Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
So now with haveged deemed "obsolete" done and getting dropped all over the place because it doesn't do anything, how does your average joe linux hobbyist admin deal with crng init taking ages? That's still happening in recent kernels... and was the prime reason I installed haveged pretty much everywhere, only it's a no-op now. Bare metal (archlinux kernel 5.15):
In a KVM virtual machine (archlinux kernel 5.10):
Same virtual machine with manually tickling the random device early in initramfs:
So massaging the random device early still has an influence, and I'd love to continue using haveged for the job, but for that to work it would actually have to do something, like unconditionally feed some randomness on startup, either as a once-off or periodically... as far as random sources go, it's the more the merrier, isn't it? |
Hi Andreas, I have updated haveged to feed entropy to the kernel on start and then every 60 seconds. Please give it a try and let me know if it works for you. See commits b0d1b0e and c35c6f4 I have tested it on x86_64 running kernel 5.15 (./haveged --Foreground) and it works fine there. Thanks a lot |
Now does it make sense to revert cef1d42? |
It seems to work fine for me. Without haveged:
With haveged:
(random fast init message is mysteriously missing. haveged itself spawns around the [ 0.8xxx] ~ [ 0.9xxx] mark.) Using a simple initcpio hook (archlinux specific):
So nothing fancy, it simply starts haveged early initramfs and kills it late initramfs. haveged works its magic in the meantime. haveged as a service to be spawned again later on by the real init system. |
It is not mysteriously. As enough entropy is available
I could add something like this in the package....
With the switch from above it would be possible to keep the current service |
I'm a bit puzzled why the jitter entropy in the kernel (merge commit, commit, LKML) isn't working. Is there anything exotic about your setup @frostschutz? Edit: Is it blocking boot @frostschutz? |
👍 I like it! I have added a new switch Thanks a lot! |
commit 98ead65 |
My desktop is a standard arch linux install with a custom encryption hook since I have more than just the one LUKS device. But in the end it still runs a standard My virtual server is a little exotic in that its encrypted and uses cryptsetup very early to check or change the passphrase. So it actually wants to use the random device very early, hence the warnings about cryptsetup reading random before crng is fully initialized. It is not blocking in either case, so maybe this is for cosmetics only, it just doesn't give me a good feeling to see such warning messages or late initializations. The kernel is very conservative about randomness/entropy (for good reasons, I'm sure) but even if the kernel 'fixes' it, I still want to keep using haveged... I also have other things in place like an early random seed (the systemd random seed service runs long after initramfs is done so maybe a little late) but I did not use those in the above tests. Basically however good the kernels random implementation is or will be, I still feel that userspace should mess with it just a little regardless, and for that purpose I'd love to continue using haveged, both in initramfs as well as a service that just keeps running indefinitely. So this is my personal feeling but I'd still love the kernel 5.6 condition to go away, after all I installed the thing and enabled the service because I want it to run and do something. ;-) I'm sure there will be people who don't need it but they simply won't install or activate it either? I can patch the service file locally or just install my own, but I can't patch haveged itself, so @jirka-h thanks a lot for doing that especially between the years — I really appreciate it. |
@frostschutz, do you have initramfs with or without |
I don't use systemd in initramfs yet. Traditional busybox-based initcpio for me. Otherwise, the hook I posted above also would not work. |
Ah, got it. Missed it was your post. 🙈 |
Would be nice to have |
Ok, this is my log now... Does not look successful, though
Used this for
Possibly we could drop even more settings for initramfs... Not sure. |
BTW,
... so I dropped it from my service. |
@frostschutz, can you please test this package? Should contain everything needed... |
Thanks a lot for the testing and packaging! I have done couple of changes:
Could you please test the latest version? Thanks a lot! |
Thanks for the changes! Away from keyboard till next year. 😳😆 |
Tested it and the (non-systemd) hook works for me, haven't tested any of the systemd stuff though. |
Thanks a lot! |
This is with current git master (1f6a41a):
It does work, but I think I did not notice before because I dropped |
Oh, and the man page is missing |
Thanks for the testing - good catch! I have fixed the exit status when using Could you please verify the fix? |
Looks good now, thanks! |
This think this could be used in |
The kernel's jitter entropy is only running if needed, so the crng initializing very late in this case is expected: /*
* Wait for the urandom pool to be seeded and thus guaranteed to supply
* cryptographically secure random numbers. This applies to: the /dev/urandom
* device, the get_random_bytes function, and the get_random_{u32,u64,int,long}
* family of functions. Using any of these functions without first calling
* this function forfeits the guarantee of security.
*
* Returns: 0 if the urandom pool has been seeded.
* -ERESTARTSYS if the function was interrupted by a signal.
*/
int wait_for_random_bytes(void)
That is expected, as
It sounds like mostly a cosmetic thing to me :) The warning caused by
Make sense, I just don't like users installing |
👍 I completely agree! |
Thanks for the testing! I have finalized the changes and released v1.9.16 https://github.com/jirka-h/haveged/releases/tag/v1.9.16 |
That's very unfortunate. It means throwing nearly 10 years worth of re-education out the window ( Just use /dev/urandom! ). I really don't want to use If the random jitter works, then it seems to me like the kernel should be using it unconditionally, early, and for both random and urandom reads equally. High time to put the final nail in the coffin for the /dev/random legacy device. It's unfathomable to me why reading /dev/random over /dev/urandom should help at all. This kind of hoop jumping should be unnecessary. I want a random device that "just works", no blocking, no shouting cryptic warnings at me, leaving me to figure things out on my own, which I'm ill equipped to do anyway, since I'm no cryptographer or kernel developer. I shouldn't even have to know or care about these implementation details. Which might just change again from one kernel version to the next. But that's something for the kernel devs to figure out.
There are plenty of guides out there that lead straight to data loss. haveged is a service that uses next to no resources, so worst case should be... still no harm done. If so, why bother so much. If other ways to tweak the random device are still valid and necessary and even strongly recommended (like the random seed), then why not haveged too. haveged has provided where kernel has left us hanging, for years. Otherwise it would not have been developed and not become remotely popular. Changing this mindset will take some time... |
Hallo Andreas, I fully agree that https://lkml.org/lkml/2021/11/21/143 I'm afraid that it will take a long time to improve the situation. Jirka |
So after all the above discussion is haveged still useful currently? |
Hi Juha, yes, it's still useful. It can provide entropy early in the boot when /dev/random is not fully utilized. On a fully booted system, it can be still used as an additional entropy source. It will insert entropy into the kernel every 60 seconds, thus diversifying your entropy sources. I hope this helps |
Note that Kernel 5.10 still needs haveged;
and /dev/urandom / GRND_INSECURE are about to be disabled so haveged is more relevant than ever. |
Thanks for that link! I think it indeed makes I'm running kernel 5.16 and I can confirm that on a fully booted system, What haveged does in this case, it provides an additional entropy source. It does not affect the speed but makes kernel RNG more trusted. [1]
|
Currently the first thing that README.md mentions is that haveged is obsolete with recent kernels. Maybe that could be improved, since haveged still has its uses, even with recent kernels. https://github.com/jirka-h/haveged/blob/master/README.md |
Good point, Juha! I have updated the https://github.com/jirka-h/haveged/blob/master/README.md - check this commit: bfff89f |
Starting from kernels 5.6 haveged is obsolete. Therefore remove it in Ubuntu 22.04. See jirka-h/haveged#57
Starting from kernels 5.6 haveged is obsolete. Therefore remove it in Ubuntu 22.04. See jirka-h/haveged#57
Starting from kernels 5.6 haveged is obsolete. Therefore remove it in Ubuntu 22.04. See jirka-h/haveged#57
Starting from kernels 5.6 haveged is obsolete. Therefore remove it in Ubuntu 22.04. See jirka-h/haveged#57
Hi
Sorry for the harsh question, but with the jitter entropy added in v5.4 (merge commit, commit, LKML) and removal of the
/dev/random
blocking pool in v5.6 (commit, LWN), ishaveged
still useful/relevant? If yes, under what circumstances?- Kristian
The text was updated successfully, but these errors were encountered: