lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200821034209.GA25401@gondor.apana.org.au>
Date:   Fri, 21 Aug 2020 13:42:09 +1000
From:   Herbert Xu <herbert@...dor.apana.org.au>
To:     Laurent Vivier <lvivier@...hat.com>
Cc:     linux-kernel@...r.kernel.org, linux-crypto@...r.kernel.org,
        Amit Shah <amit@...nel.org>
Subject: Re: [PATCH] hwrng: core - allocate a one page buffer

On Thu, Aug 06, 2020 at 05:28:14PM +0200, Laurent Vivier wrote:
.
> +static size_t rng_max_buffer_size(struct hwrng *rng)
> +{
> +	size_t size;
> +
> +	size = max_t(size_t, rng->buffer_size, SMP_CACHE_BYTES);
> +
> +	/* rng_buffer can store up to PAGE_SIZE */
> +	return min(PAGE_SIZE, size);
>  }

Rather than checking this on every read, just do it once at driver
registration time.

> @@ -614,11 +629,11 @@ static int __init hwrng_modinit(void)
>  	int ret;
>  
>  	/* kmalloc makes this safe for virt_to_page() in virtio_rng.c */
> -	rng_buffer = kmalloc(rng_buffer_size(), GFP_KERNEL);
> +	rng_buffer = (u8 *)get_zeroed_page(GFP_KERNEL);
>  	if (!rng_buffer)
>  		return -ENOMEM;

Why a zeroed page? Also please fix the out-of-sync comment.

Thanks,
-- 
Email: Herbert Xu <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ