Re: [PATCH] char_driver_warn_unseeded_randomness: Add null check
From: Greg KH
Date: Thu Jun 04 2020 - 02:30:19 EST
On Wed, Jun 03, 2020 at 10:29:07PM -0400, gaurav singh wrote:
> File: drivers/char/random.c
> Function: _warn_unseeded_randomness
>
> There is a check for previous(ptr) before dereferencing:
>
> if (print_once ||
> crng_ready() ||
> (previous && (caller == READ_ONCE(*previous))))
> return;
>
> However, after this, it is dereferenced without checking:
> WRITE_ONCE(*previous, caller);
>
> To fix this, add a null check
>
> Please find the patch below. Let me know if there's any issue.
>
> Thanks,
> Gaurav.
>
>
> >From 5e53cbce018c4d57753a6740c22d826bae0aab3f Mon Sep 17 00:00:00 2001
> From: Gaurav Singh <gaurav1086@xxxxxxxxx>
> Date: Wed, 3 Jun 2020 22:23:47 -0400
> Subject: [PATCH] char_driver_warn_unseeded_randomness: Add null check for
> previous
>
> Signed-off-by: Gaurav Singh <gaurav1086@xxxxxxxxx>
> ---
> drivers/char/random.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/char/random.c b/drivers/char/random.c
> index 0d10e31fd342..4f1975e7f201 100644
> --- a/drivers/char/random.c
> +++ b/drivers/char/random.c
> @@ -1526,7 +1526,9 @@ static void _warn_unseeded_randomness(const char
> *func_name, void *caller,
> crng_ready() ||
> (previous && (caller == READ_ONCE(*previous))))
> return;
> - WRITE_ONCE(*previous, caller);
> +
> + if (previous)
> + WRITE_ONCE(*previous, caller);
> #ifndef CONFIG_WARN_ALL_UNSEEDED_RANDOM
> print_once = true;
> #endif
> --
> 2.17.1
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 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.
- You did not specify a description of why the patch is needed, or
possibly, any description at all, in the email body. Please read the
section entitled "The canonical patch format" in the kernel file,
Documentation/SubmittingPatches for what is needed in order to
properly describe the change.
- You did not write a descriptive Subject: for the patch, allowing Greg,
and everyone else, to know what this patch is all about. Please read
the section entitled "The canonical patch format" in the kernel file,
Documentation/SubmittingPatches for what a proper Subject: line should
look like.
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