Re: [patch] binfmt_elf.c: use get_random_int() to fix entropy depleting fix

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

 



On Mon, 30 Jun 2014 15:52:05 -0700 (PDT) David Rientjes <rientjes@xxxxxxxxxx> wrote:

> The type of size_t on am33 is unsigned int for gcc major versions >= 4.
> 
> ...
>
> --- a/fs/binfmt_elf.c
> +++ b/fs/binfmt_elf.c
> @@ -155,7 +155,7 @@ static void get_atrandom_bytes(unsigned char *buf, size_t nbytes)
>  
>  	while (nbytes) {
>  		unsigned int random_variable;
> -		size_t chunk = min(nbytes, sizeof(random_variable));
> +		size_t chunk = min(nbytes, (size_t)sizeof(random_variable));
>  
>  		random_variable = get_random_int();
>  		memcpy(p, &random_variable, chunk);

I did it using min_t the other day.  I suppose using the cast is a
little clearer about the cause of the problem, but if it doesn't have a
code comment the janitors will come along and convert it to min_t.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]