Messages in this thread | | | From | Ard Biesheuvel <> | Date | Tue, 7 Jun 2022 13:10:52 +0200 | Subject | Re: [PATCH] random: do not use jump labels before they are initialized |
| |
On Tue, 7 Jun 2022 at 13:04, Jason A. Donenfeld <Jason@zx2c4.com> wrote: > > Hi Ard, > > On Tue, Jun 07, 2022 at 12:56:20PM +0200, Ard Biesheuvel wrote: > > Could we do this to defer the static key manipulation? That way, the > > first call to crng_reseed() that occurs after the static keys API > > becomes available will set the static key, and patch itself away at > > the same time. > > That's almost the same as the patch I just posted, except you > pushed the logic down into crng_reseed() instead of credit_init_bits().
Sure.
> (A previous mini-project aimed to remove as much logic as possible from > crng_reseed(), counting on those blocks in crng_init_bits() to only ever > run once.) What this means is that the static key won't get changed > until whenever the next reseeding is. I guess that's "fine" but I think > I'd prefer to keep the entropy counting stuff as separate from the init > bits stuff as possible. >
Fair enough. What I would like is to remove the need to play around with the placement of jump_label_init() across architectures. Jump labels are fundamentally a performance optimization, so unless you can explain how setting it as early as possible makes a material difference, performance or otherwise, I really think we should pursue a solution that does the static key manipulation at some later time.
> >> As a third, I could just defer doing anything with the bootloader seed > >> until random_init(). This might actually be the simplest solution... > >> I'll sketch something out. A downside, which might be sort of > >> significant, is that a few odd things actually use randomness before > >> random_init() is called. So these would miss out on having that seed. > >> I'll have to look what exactly to see if we're actually getting anything > >> real out of that. > >> > > > > This is kind of the point of using a firmware provided seed, i.e., > > that it is available much earlier than anything else. > > I'll send a patch for this anyway because I'm sort of curious now. Maybe > it'll be a dead end, for the reason you mentioned, but I think I'll > still try to evaluate it. >
Sure. Anything that can be deferred to an initcall() should be, as the early arch code is much too fragile to much around with.
| |