-
Notifications
You must be signed in to change notification settings - Fork 33
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
Synchronize haveged instances during switch root #74
Conversation
Thanks for the report and for the PR! I have run the checks and linking fails with:
From man page for I think we need to update
It works fine for me on a laptop. Could you please test it on your end as well and update the PR? Thanks a lot! |
You are right, I forgot to link pthread. Originally I added pthread only into our spec file. |
Thanks a lot for the fix! All tests are passing, I have merged the PR. Jirka |
This causes a fatal error "haveged: Couldn't create nammed semaphore haveged_sem error: Permission denied" in Debian |
I had to work around this error by issuing I don't switch-root haveged, instead its terminated at end of initramfs, and a new instance started by real init (if it has such a service). So personally I don't need this handover functionality at all, and would rather not require a semaphore (not to mention, terminate outright over not being able to create one - this could be a warning instead of a fatal error?). But I guess it's a case of can't make everyone happy. |
Hi all, Thanks for the discussion and the workaround. I don't use this feature. I have reviewed the PRs contributed by users and merged them. Looking at https://github.com/jirka-h/haveged/blob/master/src/haveged.c#L495 I can change this to a warning. Thanks |
Could you please review and test this change? |
This successfully prevents the lack of a semaphor from terminating haveged.
It turns out the problem is an over-eager app armor definition that doesn't allow permissions to write on /dev/shm/**:
This will need to be changed in Debian's package. There isn't an active maintainer for this package in Debian any more, though. Both existing ones retired. I may volunteer to take this on myself, but I do need to make sure I understand its workings well first. |
Thanks for following up on this one! I'm inclined to keep the changes in the code and only warn when semaphore creation fails. |
We found that with some system configurations zypper and lsof were complaining about haveged using deleted file (haveged binary itself) after each reboot of the system. On kernels =< 5.6 haveged is started early in the initramfs. Before switching to the permanent rootfs, haveged was supposed to do a chdir to
/sysroot
and re-executes the haveged binary from/sysroot
. This is supposed to be done by thehaveged-switch-root
service.The
haveged-switch-service
failed due to a communication problem. There are 2 haveged instances running on the system when thehaveged-switch-service
is started - one haveged daemon instance and one switch instances telling the daemon to switch its root directory.The two daemons communicate via abstract namespace unix socket. Depending on the scheduling of the process done by the kernel, some times the daemon instance is trying to read data from the socket which is not yet sent and here the problem happens. The problem is almost systematic on KVM VMs with one cpu.
This PR using a named semaphore to prevent reading from a socket until the second process has completed writing.
Thanks to @bkahla for finding this issue providing patch.