Hello! (+Cc: Leo for randomness input.) ludo@gnu.org (Ludovic Courtès) skribis: > Clément Lassieur skribis: > >> Mark H Weaver writes: > > [...] > >>> I suggest doing a git bisect on the 4.16.y branch of the linux-stable >>> git repository, between the 4.16.3 and 4.16.4 tags. >> >> I did it, here is the result: > > Impressive, thanks a lot! Did you have a script to do that or > something? > >> cd8d7a5778a4abf76ee8fe8f1bfcf78976029f8d is the first bad commit >> commit cd8d7a5778a4abf76ee8fe8f1bfcf78976029f8d >> Author: Theodore Ts'o >> Date: Wed Apr 11 13:27:52 2018 -0400 >> >> random: fix crng_ready() test >> >> commit 43838a23a05fbd13e47d750d3dfd77001536dd33 upstream. >> >> The crng_init variable has three states: >> >> 0: The CRNG is not initialized at all >> 1: The CRNG has a small amount of entropy, hopefully good enough for >> early-boot, non-cryptographical use cases >> 2: The CRNG is fully initialized and we are sure it is safe for >> cryptographic use cases. >> >> The crng_ready() function should only return true once we are in the >> last state. This addresses CVE-2018-1108. > > What happens I think is that libparted/fs/r/fat/fat.c:fat_create calls > ‘generate_random_uint32’, which in turn indirectly calls > ‘get_random_bytes’ from libuuid (package ‘e2fsprogs’). And I suppose > that’s where it blocks, even though it’s supposed to be using > /dev/urandom, which is not supposed to block. I was looking at the wrong code: we’re using libuuid from util-linux, which in turn uses getrandom(2). Since it doesn’t pass the GRND_NONBLOCK flag, it ends up blocking forever because too little entropy is available in the VM. The following patches work around that: 1. Parted now explicitly uses getrandom(2) with GRND_NONBLOCK instead of libuuid’s ‘uuid_generate’, which is good enough for this purpose. I’ll submit it upstream. 2. e2fsprogs is changed to use a libuuid that passes GRND_NONBLOCK. It does the job, but it’s quite inelegant. Another approach I looked at was to seed the VM’s PRNG from /dev/hwrng, which I thought was connected to the host via ‘virtio-rng-pci’, but I get ENODEV while trying to read from /dev/hwrng in the guest like this: