Re: [PATCH] mmc: core: Add CIDs for cards to the entropy pool

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 16 Apr 2022 at 00:31, Linus Walleij <linus.walleij@xxxxxxxxxx> wrote:
>
> To make the entropy pool a bit better we can toss in the
> CID for eMMC and SD cards into it, usually the serial
> number portion is at least unique.
>
> This does not count as improvement of the entropy but
> in practice it makes it a bit more random to mix in these
> numbers.
>
> Cc: Theodore Ts'o <tytso@xxxxxxx>
> Cc: Jason A. Donenfeld <Jason@xxxxxxxxx>
> Signed-off-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
> ---
>  drivers/mmc/core/mmc.c | 7 +++++++
>  drivers/mmc/core/sd.c  | 7 +++++++
>  2 files changed, 14 insertions(+)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index e7ea45386c22..974d8a02b966 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -12,6 +12,7 @@
>  #include <linux/slab.h>
>  #include <linux/stat.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/random.h>
>  #include <linux/sysfs.h>
>
>  #include <linux/mmc/host.h>
> @@ -1673,6 +1674,12 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,
>                 err = mmc_decode_cid(card);
>                 if (err)
>                         goto free_card;
> +               /*
> +                * Add card ID (cid) data to the entropy pool.
> +                * It doesn't matter that not all of it is unique,
> +                * it's just bonus entropy.
> +                */
> +               add_device_randomness(&card->cid, sizeof(card->cid));

We can move this into mmc_decode_cid() instead, to avoid open coding.
Moreover, this would make it work for SDIO/SD combo cards too,
whatever that matters.

One thing though, what is the typical execution time to do this?
Probably negligible, but as this may be a card that holds the rootfs,
it could delay the boot to be completed.

[...]

Kind regards
Uffe



[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux