Re: [PATCH] timekeeping: contribute wall clock to rng on time change

From: Jason A. Donenfeld
Date: Thu Jun 23 2022 - 14:59:54 EST


Hi Eric,

On Thu, Jun 23, 2022 at 7:39 PM Eric Biggers <ebiggers@xxxxxxxxxx> wrote:
> This doesn't compile:

Doh. I had the missing include, but missed it in `git add -p`. Will be
fixed for v2.

> > @@ -1346,6 +1346,9 @@ int do_settimeofday64(const struct timespec64 *ts)
> > if (!ret)
> > audit_tk_injoffset(ts_delta);
> >
> > + ktime_get_real_ts64(&xt);
> > + add_device_randomness(&xt, sizeof(xt));
> > +
> > return ret;
>
> Isn't the new time already available in 'ts'? Is the call to
> ktime_get_real_ts64() necessary?

Good point; you're right. Will simplify as such.

> > ntp_notify_cmos_timer();
> >
> > + ktime_get_real_ts64(&ts);
> > + add_device_randomness(&ts, sizeof(ts));
> > +
> > return ret;
> > }
>
> adjtimex() actually triggers a gradual adjustment of the clock, rather than
> setting it immediately. Is there a way to mix in the target time rather than
> the current time as this does?

Hmm... I have no idea. But maybe instead I can just call
`add_device_randomness()` on that big struct of offsets and things. If
the kernel is able to use it to set the time, then probably it's a
sufficient encoding of that end state.

Jason