mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-22 04:03:58 +08:00
Nasty side-effect of vmalloc'ing modules: their static vars cannot be put
into scatterlists. Jens has a check queued for this, so it shouldn't happen again. Thanks, Rusty. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAABAgAGBQJRNTJTAAoJENkgDmzRrbjxW9gQAIWBlCZre5eWYAny6/rnCoix Hj/5mH6PI1VZZw9S8vLyKdZ/DJDdsLQSFsofDBvQyEzJ1rTwNx0bnxXnlCgzX3WE 9/s2/oa49a4ceep8PCyz72N+eNIdRdhwhuRjRTBsT4o9Qle187WlZFPjMQdS+u96 U+sIhh7uWmRsob7QofjXW43K2DM9lKCKN3u3fTB7q4cZ1BDTnlOCwTXRBCZjInoc XgVXIf9my8/WXsWQZEYmnwUDg/smPXQCa+kxKewW00zXQ7A5K+Q6TXpKBj3o1C84 Y7mGozW5jcRw4bGxUj18Rq2e5VsgJ5ZZj25EuiBGGSvF+7DAUWIbZUkrf9HyUMc3 Z7MnEfNuwIOZ/YPyzcsRl+45sv6NI2bA429uiGVWlcnWh4uVbSMzFAvCjmc3BpAM zC+zazion8HG3Yr3veAqIT6N1KJu7qKfvmPxh4KaFCK/0DzQa7ENwttudwk+5zPs nSYPsfy6HlTkcGpglVWDELwPO85jBEmB8EMwPWCbw5dGfem/WjrbmvwNPxWjzvrw BqJOfm8pWqdW4c3Bu60u2py6tp4L44trVn8jfl0drspvT97lAwDLWD3Qtbh+Trlz fVqhVGpDttB+cYDQktXPOdKtp9Z4boQ4RnOv0GJIsogLulA/BY/hEZqYOKRGgwJC Zh5RYphDYiWP41FMSLLv =OHfs -----END PGP SIGNATURE----- Merge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux Pull virtio hwrng fix from Rusty Russell: "Nasty side-effect of vmalloc'ing modules: their static vars cannot be put into scatterlists. Jens has a check queued for this, so it shouldn't happen again. We could fix this in virtio_rng, but it's actually far easier to just do it in the core" * tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux: hw_random: make buffer usable in scatterlist.
This commit is contained in:
commit
d7b815d4da
@ -40,6 +40,7 @@
|
||||
#include <linux/init.h>
|
||||
#include <linux/miscdevice.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/slab.h>
|
||||
#include <asm/uaccess.h>
|
||||
|
||||
|
||||
@ -52,8 +53,12 @@ static struct hwrng *current_rng;
|
||||
static LIST_HEAD(rng_list);
|
||||
static DEFINE_MUTEX(rng_mutex);
|
||||
static int data_avail;
|
||||
static u8 rng_buffer[SMP_CACHE_BYTES < 32 ? 32 : SMP_CACHE_BYTES]
|
||||
__cacheline_aligned;
|
||||
static u8 *rng_buffer;
|
||||
|
||||
static size_t rng_buffer_size(void)
|
||||
{
|
||||
return SMP_CACHE_BYTES < 32 ? 32 : SMP_CACHE_BYTES;
|
||||
}
|
||||
|
||||
static inline int hwrng_init(struct hwrng *rng)
|
||||
{
|
||||
@ -116,7 +121,7 @@ static ssize_t rng_dev_read(struct file *filp, char __user *buf,
|
||||
|
||||
if (!data_avail) {
|
||||
bytes_read = rng_get_data(current_rng, rng_buffer,
|
||||
sizeof(rng_buffer),
|
||||
rng_buffer_size(),
|
||||
!(filp->f_flags & O_NONBLOCK));
|
||||
if (bytes_read < 0) {
|
||||
err = bytes_read;
|
||||
@ -307,6 +312,14 @@ int hwrng_register(struct hwrng *rng)
|
||||
|
||||
mutex_lock(&rng_mutex);
|
||||
|
||||
/* kmalloc makes this safe for virt_to_page() in virtio_rng.c */
|
||||
err = -ENOMEM;
|
||||
if (!rng_buffer) {
|
||||
rng_buffer = kmalloc(rng_buffer_size(), GFP_KERNEL);
|
||||
if (!rng_buffer)
|
||||
goto out_unlock;
|
||||
}
|
||||
|
||||
/* Must not register two RNGs with the same name. */
|
||||
err = -EEXIST;
|
||||
list_for_each_entry(tmp, &rng_list, list) {
|
||||
|
Loading…
Reference in New Issue
Block a user