From: Greg Kroah-Hartman Date: Wed, 6 Mar 2013 04:54:20 +0000 (+0800) Subject: 3.0-stable patches X-Git-Tag: v3.8.3~35 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3216de1835cfd8bb1defd9c4f7e7e3950a915af6;p=thirdparty%2Fkernel%2Fstable-queue.git 3.0-stable patches added patches: hw_random-make-buffer-usable-in-scatterlist.patch --- diff --git a/queue-3.0/hw_random-make-buffer-usable-in-scatterlist.patch b/queue-3.0/hw_random-make-buffer-usable-in-scatterlist.patch new file mode 100644 index 00000000000..1f537b97e56 --- /dev/null +++ b/queue-3.0/hw_random-make-buffer-usable-in-scatterlist.patch @@ -0,0 +1,75 @@ +From f7f154f1246ccc5a0a7e9ce50932627d60a0c878 Mon Sep 17 00:00:00 2001 +From: Rusty Russell +Date: Tue, 5 Mar 2013 10:07:08 +1030 +Subject: hw_random: make buffer usable in scatterlist. + +From: Rusty Russell + +commit f7f154f1246ccc5a0a7e9ce50932627d60a0c878 upstream. + +virtio_rng feeds the randomness buffer handed by the core directly +into the scatterlist, since commit bb347d98079a547e80bd4722dee1de61e4dca0e8. + +However, if CONFIG_HW_RANDOM=m, the static buffer isn't a linear address +(at least on most archs). We could fix this in virtio_rng, but it's actually +far easier to just do it in the core as virtio_rng would have to allocate +a buffer every time (it doesn't know how much the core will want to read). + +Reported-by: Aurelien Jarno +Tested-by: Aurelien Jarno +Signed-off-by: Rusty Russell +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/char/hw_random/core.c | 19 ++++++++++++++++--- + 1 file changed, 16 insertions(+), 3 deletions(-) + +--- a/drivers/char/hw_random/core.c ++++ b/drivers/char/hw_random/core.c +@@ -40,6 +40,7 @@ + #include + #include + #include ++#include + #include + + +@@ -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 + + 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) { diff --git a/queue-3.0/series b/queue-3.0/series index d3df148fe69..99e0687e8a7 100644 --- a/queue-3.0/series +++ b/queue-3.0/series @@ -5,3 +5,4 @@ target-pscsi-fix-page-increment.patch btrfs-init-io_lock-after-cloning-btrfs-device-struct.patch cifs-ensure-that-cifs_get_root-only-traverses-directories.patch sunrpc-don-t-start-the-retransmission-timer-when-out-of-socket-space.patch +hw_random-make-buffer-usable-in-scatterlist.patch