All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] randomize_range: use random long instead of int
@ 2016-07-25 18:25 william.c.roberts
  2016-07-25 18:54 ` Kees Cook
                   ` (2 more replies)
  0 siblings, 3 replies; 34+ messages in thread
From: william.c.roberts @ 2016-07-25 18:25 UTC (permalink / raw)
  To: linux-mm, linux-kernel
  Cc: linux, akpm, keescook, tytso, arnd, gregkh, catalin.marinas,
	will.deacon, ralf, benh, paulus, mpe, davem, tglx, mingo, hpa,
	x86, viro, nnk, jeffv, salyzyn, dcashman, William Roberts

From: William Roberts <william.c.roberts@intel.com>

Use a long when generating the random range rather than
an int. This will produce better random distributions as
well as matching all the types at hand.

Signed-off-by: William Roberts <william.c.roberts@intel.com>
---
 drivers/char/random.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 0158d3b..bbf11b5 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1837,7 +1837,8 @@ randomize_range(unsigned long start, unsigned long end, unsigned long len)
 
 	if (end <= start + len)
 		return 0;
-	return PAGE_ALIGN(get_random_int() % range + start);
+
+	return PAGE_ALIGN(get_random_long() % range + start);
 }
 
 /* Interface for in-kernel drivers of true hardware RNGs.
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2016-07-28 19:02 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-25 18:25 [PATCH] randomize_range: use random long instead of int william.c.roberts
2016-07-25 18:54 ` Kees Cook
2016-07-26  2:18 ` Jason Cooper
2016-07-26  3:01 ` [RFC patch 1/6] random: Simplify API for random address requests Jason Cooper
2016-07-26  3:01   ` [kernel-hardening] " Jason Cooper
2016-07-26  3:01   ` [RFC patch 2/6] x86: Use simpler " Jason Cooper
2016-07-26  3:01     ` [kernel-hardening] " Jason Cooper
2016-07-26  3:01   ` [RFC patch 3/6] ARM: " Jason Cooper
2016-07-26  3:01     ` [kernel-hardening] " Jason Cooper
2016-07-26  3:01   ` [RFC patch 4/6] arm64: " Jason Cooper
2016-07-26  3:01     ` [kernel-hardening] " Jason Cooper
2016-07-26  3:01   ` [RFC patch 5/6] tile: " Jason Cooper
2016-07-26  3:01     ` [kernel-hardening] " Jason Cooper
2016-07-26  3:02   ` [RFC patch 6/6] unicore32: " Jason Cooper
2016-07-26  3:02     ` [kernel-hardening] " Jason Cooper
2016-07-26  3:30   ` [RFC patch 1/6] random: Simplify " Jason Cooper
2016-07-26  3:30     ` [kernel-hardening] " Jason Cooper
2016-07-26  4:39     ` Kees Cook
2016-07-26  4:39       ` [kernel-hardening] " Kees Cook
2016-07-26 17:00       ` Jason Cooper
2016-07-26 17:00         ` [kernel-hardening] " Jason Cooper
2016-07-26 17:07         ` Kees Cook
2016-07-26 17:07           ` [kernel-hardening] " Kees Cook
2016-07-28 19:02           ` Jason Cooper
2016-07-28 19:02             ` [kernel-hardening] " Jason Cooper
2016-07-26 17:33     ` Roberts, William C
2016-07-26 17:33       ` [kernel-hardening] " Roberts, William C
2016-07-26  4:44   ` Kees Cook
2016-07-26  4:44     ` [kernel-hardening] " Kees Cook
2016-07-26 15:55     ` Jason Cooper
2016-07-26 15:55       ` [kernel-hardening] " Jason Cooper
2016-07-26 16:40       ` Kees Cook
2016-07-26 16:40         ` [kernel-hardening] " Kees Cook
2016-07-27 13:51   ` [kernel-hardening] " Yann Droneaud

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.