rockchip: board: Increase rng-seed size to make it sufficient for modern Linux
Subsystems (3)
PATCH 1/1 rockchip: board: Increase rng-seed size to make it sufficient for modern Linux
Modern Linux requires 32 byte seed to initialize random pool, but u-boot currently provides only 8 bytes. Increase rng-seed size to make Linux happy and initialize rng pool instantly.
Boot with 8 byte rng-seed:
# dmesg | grep crng
[ 12.089286] random: crng init done
Boot with 32 byte rng-seed:
# dmesg | grep crng
[ 0.000000] random: crng init done---
arch/arm/mach-rockchip/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-rockchip/board.c +1 -1
@@ -472,7 +472,7 @@ __weak int misc_init_r(void)__weak int board_rng_seed (struct abuf *buf) {struct udevice *dev; -size_t len =0x8 ; +size_t len =32 ;u64 *data; data =malloc (len);
Signature · 1 line
2.34.1
Quoted 11 lines · Alex Shumsky
Modern Linux requires 32 byte seed to initialize random pool, but u-boot currently provides only 8 bytes. Increase rng-seed size to make Linux happy and initialize rng pool instantly.
Boot with 8 byte rng-seed:
# dmesg | grep crng [ 12.089286] random: crng init done Boot with 32 byte rng-seed: # dmesg | grep crng [ 0.000000] random: crng init done
Quoted 4 lines
Signed-off-by Alex Shumsky <[email protected]>Fixes d2048ba ("rockchip: board: Add board_rng_seed() for all Rockchip devices")
Fixes uses 12-character commit SHA.
Quoted 10 lines
---
arch/arm/mach-rockchip/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/mach-rockchip/board.c +0
-0
arch/arm/mach-rockchip/board.c __weak int misc_init_r(void) · line 475
Quoted 5 lines
arch/arm/mach-rockchip/board.c +1
-1@@ -472,7 +472,7 @@ __weak int misc_init_r(void)__weak int board_rng_seed (struct abuf *buf) {struct udevice *dev; -size_t len =0x8 ; +size_t len =32 ;
Let's make this override-able via environment variable, because this might be growing in the future again. Does this work ?
size_t len = env_get_ulong("kaslrseed_size", 10, 32);
Quoted 4 lines · Marek Vasut
Let's make this override-able via environment variable, because this might be growing in the future again. Does this work ?
size_tlen =env_get_ulong("kaslrseed_size", 10, 32);
Maybe env_get_hex("rng_seed_size", 32) would be better? As most other env are hexadecimal.
Actually it seems that entropy required to init pool early has decreased in Linux 5.19 from 64 bytes (2 * CHACHA_KEY_SIZE) to 32 bytes (BLAKE2S_HASH_SIZE)
https://elixir.bootlin.com/linux/v5.18/source/drivers/char/random.c#L236
https://elixir.bootlin.com/linux/v5.19/source/drivers/char/random.c#L551
Anyway config knob should not harm.
Hello,
Quoted 9 lines · Alex ThreeD
Quoted 4 lines · Marek Vasut
Let's make this override-able via environment variable, because this might be growing in the future again. Does this work ?
size_tlen =env_get_ulong("kaslrseed_size", 10, 32);Maybe
env_get_hex("rng_seed_size", 32)would be better? As most other env are hexadecimal.
Quoted 6 lines
Actually it seems that entropy required to init pool early has decreased in Linux 5.19 from 64 bytes (2 *
CHACHA_KEY_SIZE) to 32 bytes (BLAKE2S_HASH_SIZE)
https://elixir.bootlin.com/linux/v5.18/source/drivers/char/random.c#L236
https://elixir.bootlin.com/linux/v5.19/source/drivers/char/random.c#L551
Anyway config knob should not harm.
I think that the value received from the new environment variable should be accepted only if it's greater than some hardcoded value, in this case 32. That way, someone won't be able to misconfigure their board environment and cause the early random pool initialization to be postponed.
Quoted 19 lines · Dragan Simic
Hello,
Quoted 9 lines · Alex ThreeD
Quoted 4 lines · Marek Vasut
Let's make this override-able via environment variable, because this might be growing in the future again. Does this work ?
size_tlen =env_get_ulong("kaslrseed_size", 10, 32);Maybe
env_get_hex("rng_seed_size", 32)would be better? As most other env are hexadecimal.Quoted 6 lines
Actually it seems that entropy required to init pool early has decreased in Linux 5.19 from 64 bytes (2 *
CHACHA_KEY_SIZE) to 32 bytes (BLAKE2S_HASH_SIZE)
https://elixir.bootlin.com/linux/v5.18/source/drivers/char/random.c#L236
https://elixir.bootlin.com/linux/v5.19/source/drivers/char/random.c#L551
Anyway config knob should not harm.
Quoted 5 lines
I think that the value received from the new environment variable should be accepted only if it's greater than some hardcoded value, in this case 32. That way, someone won't be able to misconfigure their board environment and cause the early random pool initialization to be postponed.
Using low number could be useful for testing. Print a WARNING if the number is too low perhaps ?
Hello Marek,
Quoted 18 lines · Marek Vasut
Quoted 17 lines · Dragan Simic
Quoted 15 lines · Alex ThreeD
Quoted 4 lines · Marek Vasut
Let's make this override-able via environment variable, because this might be growing in the future again. Does this work ?
size_tlen =env_get_ulong("kaslrseed_size", 10, 32);Maybe
env_get_hex("rng_seed_size", 32)would be better? As most other env are hexadecimal.Actually it seems that entropy required to init pool early has decreased in Linux 5.19 from 64 bytes (2 *
CHACHA_KEY_SIZE) to 32 bytes (BLAKE2S_HASH_SIZE)
https://elixir.bootlin.com/linux/v5.18/source/drivers/char/random.c#L236
https://elixir.bootlin.com/linux/v5.19/source/drivers/char/random.c#L551
Anyway config knob should not harm.
Quoted 8 lines
Quoted 5 lines
I think that the value received from the new environment variable should be accepted only if it's greater than some hardcoded value, in this case 32. That way, someone won't be able to misconfigure their board environment and cause the early random pool initialization to be postponed.
Using low number could be useful for testing. Print a WARNING if the number is too low perhaps?
Yes, testing with low values has also crossed my mind. Priting such warnings would be a viable option.
Quoted 27 lines · Dragan Simic
Hello Marek,
Quoted 24 lines · Marek Vasut
Quoted 22 lines · Dragan Simic
Quoted 9 lines · Alex ThreeD
Quoted 4 lines · Marek Vasut
Let's make this override-able via environment variable, because this might be growing in the future again. Does this work ?
size_tlen =env_get_ulong("kaslrseed_size", 10, 32);Maybe
env_get_hex("rng_seed_size", 32)would be better? As most other env are hexadecimal.Quoted 6 lines
Actually it seems that entropy required to init pool early has decreased in Linux 5.19 from 64 bytes (2 *
CHACHA_KEY_SIZE) to 32 bytes (BLAKE2S_HASH_SIZE)
https://elixir.bootlin.com/linux/v5.18/source/drivers/char/ random.c#L236
https://elixir.bootlin.com/linux/v5.19/source/drivers/char/ random.c#L551 Anyway config knob should not harm.I think that the value received from the new environment variable should be accepted only if it's greater than some hardcoded value, in this case 32. That way, someone won't be able to misconfigure their board environment and cause the early random pool initialization to be postponed.
Quoted 5 lines
Quoted 2 lines
Using low number could be useful for testing. Print a WARNING if the number is too low perhaps?
Yes, testing with low values has also crossed my mind. Priting such warnings would be a viable option.
Sounds good then, thanks !
Quoted 26 lines · Marek Vasut
Quoted 25 lines · Dragan Simic
Quoted 24 lines · Marek Vasut
Quoted 22 lines · Dragan Simic
Quoted 9 lines · Alex ThreeD
Quoted 4 lines · Marek Vasut
Let's make this override-able via environment variable, because this might be growing in the future again. Does this work ?
size_tlen =env_get_ulong("kaslrseed_size", 10, 32);Maybe
env_get_hex("rng_seed_size", 32)would be better? As most other env are hexadecimal.Quoted 6 lines
Actually it seems that entropy required to init pool early has decreased in Linux 5.19 from 64 bytes (2 *
CHACHA_KEY_SIZE) to 32 bytes (BLAKE2S_HASH_SIZE)
https://elixir.bootlin.com/linux/v5.18/source/drivers/char/ random.c#L236
https://elixir.bootlin.com/linux/v5.19/source/drivers/char/ random.c#L551 Anyway config knob should not harm.I think that the value received from the new environment variable should be accepted only if it's greater than some hardcoded value, in this case 32. That way, someone won't be able to misconfigure their board environment and cause the early random pool initialization to be postponed.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Using low number could be useful for testing. Print a WARNING if the number is too low perhaps?
Yes, testing with low values has also crossed my mind. Priting such warnings would be a viable option.
Sounds good then, thanks!
Thank you. :) My early thoughts were like "wow, someone can break their early random pool initialization this way", but right after that something like "well, breaking many other things is already possible in the same way" crossed my mind. :)
So, yes, just printing such warnings is perfectly fine.
Quoted 33 lines · Dragan Simic
Quoted 32 lines · Marek Vasut
Quoted 30 lines · Dragan Simic
Quoted 18 lines · Marek Vasut
Quoted 17 lines · Dragan Simic
Quoted 15 lines · Alex ThreeD
Quoted 4 lines · Marek Vasut
Let's make this override-able via environment variable, because this might be growing in the future again. Does this work ?
size_tlen =env_get_ulong("kaslrseed_size", 10, 32);Maybe
env_get_hex("rng_seed_size", 32)would be better? As most other env are hexadecimal.Actually it seems that entropy required to init pool early has decreased in Linux 5.19 from 64 bytes (2 *
CHACHA_KEY_SIZE) to 32 bytes (BLAKE2S_HASH_SIZE)
https://elixir.bootlin.com/linux/v5.18/source/drivers/char/ random.c#L236
https://elixir.bootlin.com/linux/v5.19/source/drivers/char/ random.c#L551 Anyway config knob should not harm.Quoted 8 lines
Quoted 5 lines
I think that the value received from the new environment variable should be accepted only if it's greater than some hardcoded value, in this case 32. That way, someone won't be able to misconfigure their board environment and cause the early random pool initialization to be postponed.
Using low number could be useful for testing. Print a WARNING if the number is too low perhaps?
Yes, testing with low values has also crossed my mind. Priting such warnings would be a viable option.
Quoted 6 lines
Quoted 1 line
Sounds good then, thanks!
Thank you. :) My early thoughts were like "wow, someone can break their early random pool initialization this way", but right after that something like "well, breaking many other things is already possible in the same way" crossed my mind. :)
That crossed my mind too, but ...
Quoted 1 line
So, yes, just printing such warnings is perfectly fine.
... right. U-Boot is a debug tool and boot monitor, so it gives user the freedom to do whatever they want/need/..., which includes the obligatory footgun .
If the concern is lockdown of U-Boot env so it cannot induce negative side effects, there is CONFIG_ENV_WRITEABLE_LIST and others for those purposes.
Quoted 41 lines · Marek Vasut
Quoted 33 lines · Dragan Simic
Quoted 32 lines · Marek Vasut
Quoted 30 lines · Dragan Simic
Quoted 18 lines · Marek Vasut
Quoted 17 lines · Dragan Simic
Quoted 15 lines · Alex ThreeD
Quoted 4 lines · Marek Vasut
Let's make this override-able via environment variable, because this might be growing in the future again. Does this work ?
size_tlen =env_get_ulong("kaslrseed_size", 10, 32);Maybe
env_get_hex("rng_seed_size", 32)would be better? As most other env are hexadecimal.Actually it seems that entropy required to init pool early has decreased in Linux 5.19 from 64 bytes (2 *
CHACHA_KEY_SIZE) to 32 bytes (BLAKE2S_HASH_SIZE)
https://elixir.bootlin.com/linux/v5.18/source/drivers/char/ random.c#L236
https://elixir.bootlin.com/linux/v5.19/source/drivers/char/ random.c#L551 Anyway config knob should not harm.Quoted 8 lines
Quoted 5 lines
I think that the value received from the new environment variable should be accepted only if it's greater than some hardcoded value, in this case 32. That way, someone won't be able to misconfigure their board environment and cause the early random pool initialization to be postponed.
Using low number could be useful for testing. Print a WARNING if the number is too low perhaps?
Yes, testing with low values has also crossed my mind. Priting such warnings would be a viable option.
Quoted 6 lines
Quoted 1 line
Sounds good then, thanks!
Thank you. :) My early thoughts were like "wow, someone can break their early random pool initialization this way", but right after that something like "well, breaking many other things is already possible in the same way" crossed my mind. :)
Quoted 7 lines
That crossed my mind too, but ...
Quoted 1 line
So, yes, just printing such warnings is perfectly fine.
... right. U-Boot is a debug tool and boot monitor, so it gives user the freedom to do whatever they want/need/..., which includes the obligatory footgun .
Haha, foot gun, that brought a smile to my face! :) Well said.
Quoted 3 lines
If the concern is lockdown of U-Boot env so it cannot induce negative side effects, there is
CONFIG_ENV_WRITEABLE_LISTand others for those purposes.
Yes, while in the default configuration, U-Boot gives virtually full freedom to its users, which is good.
Quoted 8 lines · Alex ThreeD
Quoted 4 lines · Marek Vasut
Let's make this override-able via environment variable, because this might be growing in the future again. Does this work ?
size_tlen =env_get_ulong("kaslrseed_size", 10, 32);Maybe
env_get_hex("rng_seed_size", 32)would be better? As most other env are hexadecimal.
The env vars are a mixed bag, this one is clearly decimal though.
Quoted 6 lines
Actually it seems that entropy required to init pool early has decreased in Linux 5.19 from 64 bytes (2 *
CHACHA_KEY_SIZE) to 32 bytes (BLAKE2S_HASH_SIZE)
https://elixir.bootlin.com/linux/v5.18/source/drivers/char/random.c#L236
https://elixir.bootlin.com/linux/v5.19/source/drivers/char/random.c#L551
Anyway config knob should not harm.
A couple more random numbers would cover all the bases then.
Quoted 6 lines · Marek Vasut
Quoted 4 lines
Actually it seems that entropy required to init pool early has decreased in Linux 5.19 from 64 bytes (2 *
CHACHA_KEY_SIZE) to 32 bytes (BLAKE2S_HASH_SIZE)A couple more random numbers would cover all the bases then.
Oops, missed this in v2. Is it vital to add support for 2.5 years old linux? Old devices probably stay with older uboot, and new devices will get new linux (maybe not that new but not 2.5 years old).
Quoted 9 lines · Alex ThreeD
Quoted 6 lines · Marek Vasut
Quoted 4 lines
Actually it seems that entropy required to init pool early has decreased in Linux 5.19 from 64 bytes (2 *
CHACHA_KEY_SIZE) to 32 bytes (BLAKE2S_HASH_SIZE)A couple more random numbers would cover all the bases then.
Oops, missed this in v2. Is it vital to add support for 2.5 years old linux?
Some of those old kernel versions are LTS and are going to be maintained for a while, so yes.
Quoted 2 lines
Old devices probably stay with older uboot, and new devices will get new linux (maybe not that new but not 2.5 years old).
It is easy to cover all the based, so let's do that.