Re: [PATCH 3/4] random: get_source_long() function

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

 



On Thu, Feb 10, 2022 at 10:41:53PM +0800, Sandy Harris wrote:
> This function gets random data from the best available source
> 
> The current code has a sequence in several places that calls one or
> more of arch_get_random_long() or related functions, checks the
> return value(s) and on failure falls back to random_get_entropy().
> get_source long() is intended to replace all such sequences.
> 
> This is better in several ways. In the fallback case it gives
> much more random output than random_get_entropy(). It never
> wastes effort by calling arch_get_random_long() et al. when
> the relevant config variables are not set. When it does use
> arch_get_random_long(), it does not deliver raw output from
> that function but masks it by mixing with stored random data.
> 
> Signed-off-by: Sandy Harris <sandyinchina@xxxxxxxxx>
> ---
>  drivers/char/random.c | 74 +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 74 insertions(+)
> 
> diff --git a/drivers/char/random.c b/drivers/char/random.c
> index 9edf65ad4259..6c77fd056f66 100644
> --- a/drivers/char/random.c
> +++ b/drivers/char/random.c
> @@ -1031,6 +1031,80 @@ static void xtea_rekey(void)
>      xtea_iterations = 0 ;
>  }
> 
> +/**************************************************************************
> + * Load a 64-bit word with data from whatever source we have
> + *
> + *       arch_get_random_long()
> + *       hardware RNG
> + *       emulated HWRNG in a VM
> + *
> + * When there are two sources, alternate.
> + * If you have no better source, or if one fails,
> + * fall back to get_xtea_long()
> + *
> + * This function always succeeds, which allows some
> + * simplifications elsewhere in the code.
> + *
> + * This is intended only for use inside the kernel.
> + * Any data sent to user space should come from the
> + * chacha-based crng construction.
> + ***************************************************************************/
> +
> +static int load_count = 0;
> +#define COUNT_RESTART 128
> +
> +/*
> + * Add a mask variable so we can avoid using data
> + * from any source directly as output.
> + */
> +static unsigned long source_mask ;
> +
> +/*
> + * Use xtea sometimes even if we have a good source
> + * Avoids trusting the source completely
> + */
> +#define MIX_MASK 15
> +
> +static void get_source_long(unsigned long *x)
> +{
> +    int a, b ;
> +    int ret = 0 ;
> +

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- Your patch contains warnings and/or errors noticed by the
  scripts/checkpatch.pl tool.

- Your patch is malformed (tabs converted to spaces, linewrapped, etc.)
  and can not be applied.  Please read the file,
  Documentation/email-clients.txt in order to fix this.


If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux