<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le dim. 7 juin 2020 à 22:14, Norbert Lange <<a href="mailto:nolange79@gmail.com">nolange79@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Am So., 7. Juni 2020 um 22:07 Uhr schrieb Jérémy ROSEN <<a href="mailto:jeremy.rosen@smile.fr" target="_blank">jeremy.rosen@smile.fr</a>>:<br>
><br>
><br>
><br>
> Le dim. 7 juin 2020 à 21:59, Norbert Lange <<a href="mailto:nolange79@gmail.com" target="_blank">nolange79@gmail.com</a>> a écrit :<br>
>><br>
>> Am So., 7. Juni 2020 um 21:47 Uhr schrieb Jérémy ROSEN <<a href="mailto:jeremy.rosen@smile.fr" target="_blank">jeremy.rosen@smile.fr</a>>:<br>
>> ><br>
>> ><br>
>> ><br>
>> > Le dim. 7 juin 2020 à 21:42, Norbert Lange <<a href="mailto:nolange79@gmail.com" target="_blank">nolange79@gmail.com</a>> a écrit :<br>
>> >><br>
>> >> Am So., 7. Juni 2020 um 21:27 Uhr schrieb Jérémy ROSEN <<a href="mailto:jeremy.rosen@smile.fr" target="_blank">jeremy.rosen@smile.fr</a>>:<br>
>> >> ><br>
>> >> ><br>
>> >> ><br>
>> >> > Le dim. 7 juin 2020 à 21:18, Norbert Lange <<a href="mailto:nolange79@gmail.com" target="_blank">nolange79@gmail.com</a>> a écrit :<br>
>> >> >><br>
>> >> >> Am So., 7. Juni 2020 um 21:05 Uhr schrieb Jérémy ROSEN <<a href="mailto:jeremy.rosen@smile.fr" target="_blank">jeremy.rosen@smile.fr</a>>:<br>
>> >> >> ><br>
>> >> >> ><br>
>> >> >> ><br>
>> >> >> > Le dim. 7 juin 2020 à 20:35, Norbert Lange <<a href="mailto:nolange79@gmail.com" target="_blank">nolange79@gmail.com</a>> a écrit :<br>
>> >> >> >><br>
>> >> >> >> Am So., 7. Juni 2020 um 12:35 Uhr schrieb Jérémy ROSEN <<a href="mailto:jeremy.rosen@smile.fr" target="_blank">jeremy.rosen@smile.fr</a>>:<br>
>> >> >> >> ><br>
>> >> >> >> ><br>
>> >> >> >> ><br>
>> >> >> >> > Le sam. 6 juin 2020 à 00:55, Norbert Lange <<a href="mailto:nolange79@gmail.com" target="_blank">nolange79@gmail.com</a>> a écrit :<br>
>> >> >> >> >><br>
>> >> >> >> >> Drop default dependencies, haveged needs nothing but<br>
>> >> >> >> >> local sockets and /dev/random.<br>
>> >> >> >> >> This allows the entropy to be available earlier.<br>
>> >> >> >> >><br>
>> >> >> >> >> Signed-off-by: Norbert Lange <<a href="mailto:nolange79@gmail.com" target="_blank">nolange79@gmail.com</a>><br>
>> >> >> >> >> ---<br>
>> >> >> >> >>  package/haveged/haveged.service | 5 ++++-<br>
>> >> >> >> >>  1 file changed, 4 insertions(+), 1 deletion(-)<br>
>> >> >> >> >><br>
>> >> >> >> >> diff --git a/package/haveged/haveged.service b/package/haveged/haveged.service<br>
>> >> >> >> >> index 91035c6711..ed9f043a91 100644<br>
>> >> >> >> >> --- a/package/haveged/haveged.service<br>
>> >> >> >> >> +++ b/package/haveged/haveged.service<br>
>> >> >> >> >> @@ -1,10 +1,13 @@<br>
>> >> >> >> >>  [Unit]<br>
>> >> >> >> >>  Description=Entropy Harvesting Daemon<br>
>> >> >> >> >>  Documentation=man:haveged(8)<br>
>> >> >> >> >> +DefaultDependencies=no<br>
>> >> >> >> >> +Conflicts=shutdown.target<br>
>> >> >> >> >> +Before=sysinit.target shutdown.target systemd-update-done.service<br>
>> >> >> >> >><br>
>> >> >> >> > Since v243 (quoting  systemd's NEWS file) :<br>
>> >> >> >> ><br>
>> >> >> >> > * systemd-random-seed.service is now a synchronization point for full<br>
>> >> >> >> >           initialization of the kernel's entropy pool. Services that require<br>
>> >> >> >> >           /dev/urandom to be correctly initialized should be ordered after this<br>
>> >> >> >> >           service.<br>
>> >> >> >> ><br>
>> >> >> >> > so... in that case it might make sense to add Before=systemd-random-seed.service<br>
>> >> >> >> > (assuming that works. This a very early point, so it needs some testing)<br>
>> >> >> >><br>
>> >> >> >><br>
>> >> >> >> No, doesnt make sense, a "before"  only means the service is *started before*,<br>
>> >> >> >> not the process did do anything worthwile. (That's the reason for my<br>
>> >> >> >> openssh patch BTW)<br>
>> >> >> >> systemd-random-seed.service is a one-shot, so a "before" *that*<br>
>> >> >> >> service means the dependants wait till it is finished.<br>
>> >> >> >><br>
>> >> >> > (note that I don't really understand what haveged does, so I might be completely wrong in my<br>
>> >> >> > understanding)<br>
>> >> >> ><br>
>> >> >> > systemd-random-seed is the sync point, that means that any service that needs<br>
>> >> >> > random numbers should  be ordered after random-seed.<br>
>> >> >> ><br>
>> >> >> > So, to me, it makes sense that we want to have haveged started before that point. Thus<br>
>> >> >> > having haveged ordered before random-seed.<br>
>> >> >> ><br>
>> >> >> > and I don't really understand your sentence above...<br>
>> >> >> > if you add Before=systemd-random-seed, it's systemd-random-seed that will wait for<br>
>> >> >> > haveged to be started, not the other way round. (which seems to be what you say ??)<br>
>> >> >><br>
>> >> >><br>
>> >> >>  Yes, systemd-random-seed will wait for haveged to be *startet* (and<br>
>> >> >> maybe its immediatly preempted),<br>
>> >> >> but it takes several seconds after that till /dev/urandom is "ready"<br>
>> >> >> (what that means changed in the last few years multiple times)<br>
>> >> >><br>
>> >> > ... yeah ...<br>
>> >> >><br>
>> >> >> ><br>
>> >> >> > now... if haveged needs some time to "do something usefull" then it means that haveged<br>
>> >> >> > is badly synchronised on startup. The Ready signal in systemd is defined as "the point<br>
>> >> >> > at which the service is able to render the service expected for it'<br>
>> >> >><br>
>> >> >><br>
>> >> >> Yes, but haveged does not send such a signal (and systemd only wait<br>
>> >> >> for that if the Type=notify).<br>
>> >> ><br>
>> >> ><br>
>> >> > There is a workaround for that. Add an ExecStartPost that detects readiness.<br>
>> >> > (mentionning that for completeness sake, not sure if it's worth doing here.)<br>
>> >> ><br>
>> >> >><br>
>> >> >> Further the service only feeds data to the kernel, and the only valid<br>
>> >> >> meaning of /dev/urandom is "ready"<br>
>> >> >> comes from the kernel.<br>
>> >> >><br>
>> >> > and random-seed will wait for that, so syncronisation will work correctly<br>
>> >><br>
>> >> Nope, it does not. It's a (poor) substitute to wait after some entropy<br>
>> >> was fed to the kernel.<br>
>> >><br>
>> > comment at the bottom of random-seed.service:<br>
>> ><br>
>> > # This service waits until the kernel's entropy pool is initialized, and may be<br>
>> > # used as ordering barrier for service that require an initialized entropy<br>
>> > # pool. Since initialization can take a while on entropy-starved systems, let's<br>
>> > # increase the time-out substantially here.<br>
>> ><br>
>> > and from the man page<br>
>> ><br>
>> >  This new seed is  retrieved synchronously from the kernel, which means the<br>
>> > service will not complete start-up until the random pool is fully initialized.<br>
>> ><br>
>> >  I might misread stuff, as you stated randomness handing in linux is complicated<br>
>> > but I really think that the initial idea behind that service was synchronisation...<br>
>><br>
>><br>
>> No you are correct, Ive been proven wrong. Did not know reading the<br>
>> seed would sync to the entropy pool being ready.<br>
>><br>
>> ><br>
>> ><br>
>> >> ><br>
>> >> >><br>
>> >> >>  The point of waiting for "systemd-random-seed" is a substitute if you<br>
>> >> >> are in a really tough spot,<br>
>> >> >> and independent of what haveged does.<br>
>> >> >><br>
>> >> > No, it's more than a substitute. it's a sync point.<br>
>> >> > It doesn't just load entropy into the kernel, it also blocks until the kernel reports<br>
>> >> > that /dev/urandom is ready<br>
>> >><br>
>> >> Show me where?<br>
>> >><br>
>> >> ><br>
>> >> > IOW the only way to make sure that haveged is started "at the right point" in a generic<br>
>> >> > way is to add that Before=<br>
>> >> ><br>
>> >> > That would allow any service that needs reliable randomness to be correctly synced<br>
>> >> > with haveged, even if they are not aware that haveged is here...<br>
>> >><br>
>> >> Well, consider that systemd-random-seed would block for that (which it<br>
>> >> does not),<br>
>> >> then it does not matter *when* haveged is started, only that it is not<br>
>> >> blocked (and it is not).<br>
>> >> In other words, it would make no difference.<br>
>><br>
>><br>
>> That point still stands though.<br>
>> -   haveged will be "startable" as early as systemd-random-seed,<br>
>> potentially before (does not need a filesystem).<br>
>> -   even if it is started later, systemd-random-seed will block until<br>
>> haveged was running long enough to feed entropy to the kernel<br>
><br>
><br>
> not if there are other sources of entropy available and the kernel marks<br>
>  urandom  as ready before haveged is started<br>
><br>
> more importantly, I am worried about "the promise".<br>
> A user installing haveged will want to rely on it to provide improved<br>
> randomness. by not syncing correctly, we are missing on that promise.<br>
><br>
> Overall, I think it's good practice. Haveged should be aware of<br>
> systemd-random-seed and should be started before systemd-random-seed.<br>
><br>
> Having it explicitely before is more readable, safer, and doesn't rely on a<br>
> kernel sync that is hard to understand.<br>
><br>
> The more I think about it, the more I think you should add that...<br>
> It's just a line in a config file and it might really improve clarity, avoid<br>
> potential bugs and better guarantee that services needing high<br>
> quality randomness will have it properly.<br>
<br>
haveged is *not* a prefered source of entropy,<br>
it's there that VMs and embedded systems don't stall for minutes at bootup<br>
(I use that with a ConditionVirtualization to test my rootfs under qemu)<br>
<br>
So I'd prefer any other sources to feed the kernel, this is the<br>
software fallback.<br>
</blockquote></div><div><br></div>Ok, but with that i'm not sure what the proper configurtion for<div>buildroot in general should be...</div><div><br></div><div><div>I mean... if it's not high grade entropy, it shouldn't credit the kernel entropy</div><div>pool,and if the user is ok with unreliable entropy, systemd-random-seed is </div><div>probably a faster way to get some.</div><div><br></div><div>I'm a bit confused at this point. I'm not sure what the correct default should be.</div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><table border="0" style="border-collapse:collapse;border-spacing:0px;color:rgb(51,51,51);font-family:Raleway,regular;font-size:14px;padding:20px"><tbody><tr><td style="padding:0px 30px 0px 0px;font-size:13px;color:rgb(255,128,84);text-align:center"><a href="http://www.smile.eu/" style="background-color:transparent;color:rgb(221,72,20)" target="_blank"><img src="http://ftp.smile.fr/client/Communication/signature/img/Logo-new.png" alt="SMILE" style="border: 0px; vertical-align: middle; max-width: 100%; height: auto;"> </a><br><br><p style="margin:0px 0px 10px">20 rue des Jardins<br>92600 Asnières-sur-Seine</p></td><td style="padding:0px 0px 0px 20px;border-left:1px solid rgb(59,127,254);font-size:13px;color:rgb(255,128,84)"><div style="font-size:14px"><b>Jérémy ROSEN</b></div><div style="color:rgb(59,127,254)">Architecte technique<br></div><br><div style="color:rgb(59,127,254)"><span style="white-space:nowrap"><img src="http://ftp.smile.fr/client/Communication/signature/img/mail.png" alt="email" width="12" height="10" style="border: 0px; vertical-align: middle; margin-right: 5px;"> <a href="mailto:jeremy.rosen@smile.fr" style="background-color:transparent;color:rgb(59,127,254)" target="_blank">jeremy.rosen@smile.fr</a> </span><br><span style="white-space:nowrap"><img src="http://ftp.smile.fr/client/Communication/signature/img/phone.png" alt="phone" width="10" height="10" style="border: 0px; vertical-align: middle; margin-right: 5px;"></span>  +33 6 88 25 87 42 <br><span style="white-space:nowrap"><img src="http://ftp.smile.fr/client/Communication/signature/img/web.png" alt="url" width="12" height="12" style="border: 0px; vertical-align: middle; margin-right: 5px;"> <a href="http://www.smile.eu/" style="background-color:transparent;color:rgb(59,127,254)" target="_blank">http://www.smile.eu</a></span></div><br><div><span><a href="https://twitter.com/GroupeSmile" style="background-color:transparent;color:rgb(221,72,20);margin-right:5px" target="_blank"><img src="http://ftp.smile.fr/client/Communication/signature/img/rs-twitter.png" alt="Twitter" style="border: 0px; vertical-align: middle; max-width: 100%; height: auto;"></a></span> <span><a href="https://www.facebook.com/smileopensource" style="background-color:transparent;color:rgb(221,72,20);margin-right:5px" target="_blank"><img src="http://ftp.smile.fr/client/Communication/signature/img/rs-facebook.png" alt="Facebook" style="border: 0px; vertical-align: middle; max-width: 100%; height: auto;"></a></span> <span><a href="https://www.linkedin.com/company/smile" style="background-color:transparent;color:rgb(221,72,20);margin-right:5px" target="_blank"><img src="http://ftp.smile.fr/client/Communication/signature/img/rs-linkedin.png" alt="LinkedIn" style="border: 0px; vertical-align: middle; max-width: 100%; height: auto;"></a></span> <span><a href="https://github.com/Smile-SA" style="background-color:transparent;color:rgb(221,72,20);margin-right:5px" target="_blank"><img src="http://ftp.smile.fr/client/Communication/signature/img/rs-github.png" alt="Github" style="border: 0px; vertical-align: middle; max-width: 100%; height: auto;"></a></span></div></td></tr></tbody></table><br style="color:rgb(51,51,51);font-family:Raleway,regular;font-size:14px"><div style="color:rgb(51,51,51);font-family:Raleway,regular;font-size:14px"><a href="https://www.smile.eu/fr/publications/livres-blancs/yocto?utm_source=signature&utm_medium=email&utm_campaign=signature" style="background-color:transparent;color:rgb(221,72,20)" target="_blank"><img src="https://signature.smile.eu/assets/img/bandeaux_signature_mail_yocto.gif.gif" alt="Découvrez l’univers Smile, rendez-vous sur smile.eu" border="0" style="border: 0px; vertical-align: middle;"></a></div></div></div></div></div></div></div>