lkml.org 
[lkml]   [2022]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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

\
 
 \ /
  Last update: 2022-08-01 09:33    [W:0.099 / U:0.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site