aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authordcashman <dcashman@google.com>2016-02-24 13:27:06 -0800
committerZiyan <jaraidaniel@gmail.com>2016-10-29 01:33:54 +0200
commit4062b1eabf5f8b2c387a2a27297b109d0201373c (patch)
tree24ec5616688b05d7c32a92f38f33e37f52e02ea4 /include
parentbfb69c912b280fdf56fcf2c26d8fc996cabc9f87 (diff)
downloadkernel_samsung_tuna-4062b1eabf5f8b2c387a2a27297b109d0201373c.zip
kernel_samsung_tuna-4062b1eabf5f8b2c387a2a27297b109d0201373c.tar.gz
kernel_samsung_tuna-4062b1eabf5f8b2c387a2a27297b109d0201373c.tar.bz2
FROMLIST: drivers: char: random: add get_random_long()
(cherry picked from commit https://lkml.org/lkml/2016/2/4/831) d07e22597d1d355 ("mm: mmap: add new /proc tunable for mmap_base ASLR") added the ability to choose from a range of values to use for entropy count in generating the random offset to the mmap_base address. The maximum value on this range was set to 32 bits for 64-bit x86 systems, but this value could be increased further, requiring more than the 32 bits of randomness provided by get_random_int(), as is already possible for arm64. Add a new function: get_random_long() which more naturally fits with the mmap usage of get_random_int() but operates exactly the same as get_random_int(). Also, fix the shifting constant in mmap_rnd() to be an unsigned long so that values greater than 31 bits generate an appropriate mask without overflow. This is especially important on x86, as its shift instruction uses a 5-bit mask for the shift operand, which meant that any value for mmap_rnd_bits over 31 acts as a no-op and effectively disables mmap_base randomization. Finally, replace calls to get_random_int() with get_random_long() where appropriate. Bug: 26963541 Signed-off-by: Daniel Cashman <dcashman@android.com> Signed-off-by: Daniel Cashman <dcashman@google.com> Change-Id: Ie7552631b5db86f3482cf15e7dc916d89c1c502b
Diffstat (limited to 'include')
-rw-r--r--include/linux/random.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/linux/random.h b/include/linux/random.h
index 7e58ad2..766e669 100644
--- a/include/linux/random.h
+++ b/include/linux/random.h
@@ -63,6 +63,7 @@ extern const struct file_operations random_fops, urandom_fops;
#endif
unsigned int get_random_int(void);
+unsigned long get_random_long(void);
unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len);
u32 random32(void);