# Re: \[PATCH 1/2\] random32: make prandom\_u32() output unpredictable

- From: Yann Ylavic \<hidden\>
- Date: 2020-09-01 08:34:06 
- List: netdev
- Page: https://ratatoskr.run/netdev/2020/09/6089203
- Thread: https://ratatoskr.run/netdev/2020/09/6089090/t.md

```text
On Tue, Sep 1, 2020 at 8:45 AM Willy Tarreau [ref] wrote:
>
> +/*
> + *     Generate some initially weak seeding values to allow
> + *     the prandom_u32() engine to be started.
> + */
> +static int __init prandom_init_early(void)
> +{
> +       int i;
> +       unsigned long v0, v1, v2, v3;
> +
> +       if (!arch_get_random_long(&v0))
> +               v0 = jiffies;
> +       if (!arch_get_random_long(&v1))
> +               v0 = random_get_entropy();

Shouldn't the above be:
                  v1 = random_get_entropy();
?

> +       v2 = v0 ^ PRND_K0;
> +       v3 = v1 ^ PRND_K1;
> +
> +       for_each_possible_cpu(i) {
> +               struct siprand_state *state;
> +
> +               v3 ^= i;
> +               PRND_SIPROUND(v0, v1, v2, v3);
> +               PRND_SIPROUND(v0, v1, v2, v3);
> +               v0 ^= i;
> +
> +               state = per_cpu_ptr(&net_rand_state, i);
> +               state->v0 = v0;  state->v1 = v1;
> +               state->v2 = v2;  state->v3 = v3;
> +       }
> +
> +       return 0;
> +}
> +core_initcall(prandom_init_early);


Regards;
Yann.
```
