efi: random: Properly limit the size of the random seed
PATCH 1/1 efi: random: Properly limit the size of the random seed
Commit be36f9e7517e ("efi: READ_ONCE rng seed size before munmap") added a READ_ONCE() and also changed the call to add_bootloader_randomness() to use the local size variable. Neither of these changes was actually needed and this was not backported to the 4.14 stable branch.
Commit 161a438d730d ("efi: random: reduce seed size to 32 bytes") reverted the addition of READ_ONCE() and added a limit to the value of size. This depends on the earlier commit, because size can now differ from seed->size, but it was wrongly backported to the 4.14 stable branch by itself.
Apply the missing change to the add_bootloader_randomness() parameter (except that here we are still using add_device_randomness()).
--- drivers/firmware/efi/efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/efi/efi.c +1 -1
@@ -541,7 +541,7 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, seed =early_memremap (efi.rng_seed,sizeof (*seed) + size);if (seed !=NULL ) { -add_device_randomness (seed->bits, seed->size); +add_device_randomness (seed->bits, size);early_memunmap (seed,sizeof (*seed) + size);pr_notice ("seeding entropy pool\n" ); }else {
Quoted 6 lines · Ben Hutchings
Commit
be36f9e7517e("efi:READ_ONCErng seed size before munmap") added aREAD_ONCE()and also changed the call toadd_bootloader_randomness()to use the local size variable. Neither of these changes was actually needed and this was not backported to the 4.14 stable branch.
Quoted 8 lines
Commit
161a438d730d("efi: random: reduce seed size to 32 bytes") reverted the addition ofREAD_ONCE()and added a limit to the value of size. This depends on the earlier commit, because size can now differ fromseed->size, but it was wrongly backported to the 4.14 stable branch by itself.Apply the missing change to the
add_bootloader_randomness()parameter (except that here we are still usingadd_device_randomness()).
[...]
This made me wonder: shouldn't commit 18b915ac6b0a ("efi/random: Treat EFI_RNG_PROTOCOL output as bootloader randomness") be applied to these older stable branches? Without that, the EFI RNG can't be distrusted if necessary.
Ben.
Signature · 2 lines
Ben Hutchings compatible: Gracefully accepts erroneous data from any source
Quoted 13 lines · Ben Hutchings
Quoted 12 lines · Ben Hutchings
Commit
be36f9e7517e("efi:READ_ONCErng seed size before munmap") added aREAD_ONCE()and also changed the call toadd_bootloader_randomness()to use the local size variable. Neither of these changes was actually needed and this was not backported to the 4.14 stable branch.Commit
161a438d730d("efi: random: reduce seed size to 32 bytes") reverted the addition ofREAD_ONCE()and added a limit to the value of size. This depends on the earlier commit, because size can now differ fromseed->size, but it was wrongly backported to the 4.14 stable branch by itself.
Quoted 8 lines
Quoted 2 lines
Apply the missing change to the
add_bootloader_randomness()parameter (except that here we are still usingadd_device_randomness()).[...]
This made me wonder: shouldn't commit
18b915ac6b0a("efi/random: TreatEFI_RNG_PROTOCOLoutput as bootloader randomness") be applied to these older stable branches? Without that, the EFI RNG can't be distrusted if necessary.
Makes sense, want to send a backport on top of this one as the original will not work?
greg k-h
Greg KH
maintainerQuoted 12 lines · Ben Hutchings
Commit
be36f9e7517e("efi:READ_ONCErng seed size before munmap") added aREAD_ONCE()and also changed the call toadd_bootloader_randomness()to use the local size variable. Neither of these changes was actually needed and this was not backported to the 4.14 stable branch.Commit
161a438d730d("efi: random: reduce seed size to 32 bytes") reverted the addition ofREAD_ONCE()and added a limit to the value of size. This depends on the earlier commit, because size can now differ fromseed->size, but it was wrongly backported to the 4.14 stable branch by itself.
Quoted 8 lines
Apply the missing change to the
add_bootloader_randomness()parameter (except that here we are still usingadd_device_randomness()).Fixes 700485f70e50 ("efi: random: reduce seed size to 32 bytes")Signed-off-by Ben Hutchings <[email protected]>--- drivers/firmware/efi/efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Both now queued up, thanks,
greg k-h