Re: [PATCH 2/2 v3] lib/vsprintf: Initialize vsprintf's pointer hash once the random core is ready.

From: Sebastian Andrzej Siewior
Date: Mon Aug 01 2022 - 08:49:41 EST


On 2022-08-01 14:36:48 [+0200], Jason A. Donenfeld wrote:
> > --- a/lib/vsprintf.c
> > +++ b/lib/vsprintf.c
> > @@ -751,31 +751,39 @@ static int __init debug_boot_weak_hash_e
> > early_param("debug_boot_weak_hash", debug_boot_weak_hash_enable);
> >
> > static bool filled_random_ptr_key;
> > +static siphash_key_t ptr_key __read_mostly;
> > +static void fill_ptr_key_workfn(struct work_struct *work);
> > +static DECLARE_DELAYED_WORK(fill_ptr_key_work, fill_ptr_key_workfn);
> > +
> > +static void fill_ptr_key_workfn(struct work_struct *work)
> > +{
> > + if (!rng_is_initialized()) {
> > + queue_delayed_work(system_unbound_wq, &fill_ptr_key_work, HZ * 2);
> > + return;
> > + }
>
> This seems kind of crazy and over-complex. You only need this on RT,
> right? Because of the raw lock issue? So just schedule it for the right
> time on RT and not elsewhere.

Then we have two code paths for RT and !RT and I would to avoid that
especially if it ends up as a user visible change.
And then there is lockdep which might yell on !RT if you acquire a
spinlock_t from context which won't work on RT.

> I'll send a more basic patch.

oki.

> Jason

Sebastian