Messages in this thread | | | Date | Mon, 1 Aug 2022 09:32:46 +0200 | From | Sebastian Andrzej Siewior <> | Subject | Re: [PATCH 2/2 v2] lib/vsprintf: Initialize vsprintf's pointer hash once the random core is ready. |
| |
On 2022-07-30 01:29:12 [+0200], Jason A. Donenfeld wrote: > On Fri, Jul 29, 2022 at 05:47:16PM +0200, Sebastian Andrzej Siewior wrote: > > +static void fill_ptr_key_workfn(struct work_struct *work) > > +{ > > + int ret; > > + > > + ret = get_random_bytes_wait(&ptr_key, sizeof(ptr_key)); > > > +static int vsprintf_init_hashval(void) > > +{ > > + static DECLARE_WORK(fill_ptr_key_work, fill_ptr_key_workfn); > > + > > + queue_work(system_unbound_wq, &fill_ptr_key_work); > > + return 0; > > +} > > +subsys_initcall(vsprintf_init_hashval) > > I'm unsure how good of an idea this is; it'll wind up setting off the > jitter entropy thing very early in init. It's probably a better idea to > just schedule the worker the first time that the RNG is already > initialized by some other means. Check `in_hardirq()` or something if > you're worried about missing the first message.
I'm aware of in_hardirq() and this not the only I have to worry about. The same is true for interrupts-off, preempt-off, BH-disabled, rcu-read section. If you don't want me to use get_random_bytes_wait(), would you prefer to delay it to late_initcall() or would you rather prefer to schedule a worker every other second until the RNG is ready?
> Jason
Sebastian
| |