diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-12 02:34:10 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-10-12 02:34:10 +0200 |
commit | a379f71a30dddbd2e7393624e455ce53c87965d1 (patch) | |
tree | c9c71b3eb19ff7e8618ff29e9d5ac99882b823e1 /drivers/char | |
parent | Merge tag 'media/v4.9-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mch... (diff) | |
parent | mm: split gfp_mask and mapping flags into separate fields (diff) | |
download | linux-a379f71a30dddbd2e7393624e455ce53c87965d1.tar.xz linux-a379f71a30dddbd2e7393624e455ce53c87965d1.zip |
Merge branch 'akpm' (patches from Andrew)
Merge more updates from Andrew Morton:
- a few block updates that fell in my lap
- lib/ updates
- checkpatch
- autofs
- ipc
- a ton of misc other things
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (100 commits)
mm: split gfp_mask and mapping flags into separate fields
fs: use mapping_set_error instead of opencoded set_bit
treewide: remove redundant #include <linux/kconfig.h>
hung_task: allow hung_task_panic when hung_task_warnings is 0
kthread: add kerneldoc for kthread_create()
kthread: better support freezable kthread workers
kthread: allow to modify delayed kthread work
kthread: allow to cancel kthread work
kthread: initial support for delayed kthread work
kthread: detect when a kthread work is used by more workers
kthread: add kthread_destroy_worker()
kthread: add kthread_create_worker*()
kthread: allow to call __kthread_create_on_node() with va_list args
kthread/smpboot: do not park in kthread_create_on_cpu()
kthread: kthread worker API cleanup
kthread: rename probe_kthread_data() to kthread_probe_data()
scripts/tags.sh: enable code completion in VIM
mm: kmemleak: avoid using __va() on addresses that don't have a lowmem mapping
kdump, vmcoreinfo: report memory sections virtual addresses
ipc/sem.c: add cond_resched in exit_sme
...
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/random.c | 36 | ||||
-rw-r--r-- | drivers/char/virtio_console.c | 1 |
2 files changed, 25 insertions, 12 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c index 3efb3bf0ab83..d131e152c8ce 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -2100,23 +2100,37 @@ unsigned long get_random_long(void) } EXPORT_SYMBOL(get_random_long); -/* - * randomize_range() returns a start address such that +/** + * randomize_page - Generate a random, page aligned address + * @start: The smallest acceptable address the caller will take. + * @range: The size of the area, starting at @start, within which the + * random address must fall. + * + * If @start + @range would overflow, @range is capped. * - * [...... <range> .....] - * start end + * NOTE: Historical use of randomize_range, which this replaces, presumed that + * @start was already page aligned. We now align it regardless. * - * a <range> with size "len" starting at the return value is inside in the - * area defined by [start, end], but is otherwise randomized. + * Return: A page aligned address within [start, start + range). On error, + * @start is returned. */ unsigned long -randomize_range(unsigned long start, unsigned long end, unsigned long len) +randomize_page(unsigned long start, unsigned long range) { - unsigned long range = end - len - start; + if (!PAGE_ALIGNED(start)) { + range -= PAGE_ALIGN(start) - start; + start = PAGE_ALIGN(start); + } - if (end <= start + len) - return 0; - return PAGE_ALIGN(get_random_int() % range + start); + if (start > ULONG_MAX - range) + range = ULONG_MAX - start; + + range >>= PAGE_SHIFT; + + if (range == 0) + return start; + + return start + (get_random_long() % range << PAGE_SHIFT); } /* Interface for in-kernel drivers of true hardware RNGs. diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 8114744bf30c..d433b1db1fdd 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -38,7 +38,6 @@ #include <linux/workqueue.h> #include <linux/module.h> #include <linux/dma-mapping.h> -#include <linux/kconfig.h> #include "../tty/hvc/hvc_console.h" #define is_rproc_enabled IS_ENABLED(CONFIG_REMOTEPROC) |