Re: [PATCH] x86/coco: Require seeding RNG with RDRAND on CoCo systems

Andi Kleen
2024-02-10T05:09:14Z

> + for (i = 0; i < ARRAY_SIZE(rng_seed); i += longs) {
> + longs = arch_get_random_longs(&rng_seed[i], ARRAY_SIZE(rng_seed) - i);
> +
> + /*
> + * A zero return value means that the guest is under attack,
> + * the hardware is broken, or some other mishap has occurred
> + * that means the RNG cannot be properly rng_seeded, which also
> + * likely means most crypto inside of the CoCo instance will be
> + * broken, defeating the purpose of CoCo in the first place. So
> + * just panic here because it's absolutely unsafe to continue
> + * executing.
> + */
> + BUG_ON(longs == 0);

BUG_ON doesn't necessarily panic. If you want panic, use panic.

-Andi